ProgressDialog is deprecated.What is the alternate one to use?

后端 未结 17 1051
面向向阳花
面向向阳花 2020-11-27 09:11

I have come across to see that ProgressDialog is now deprecated. What would be alternate one to use in place of that apart from ProgressBar. I am

17条回答
  •  我在风中等你
    2020-11-27 09:35

    You can use this class I wrote. It offers only the basic functions. If you want a fully functional ProgressDialog, then use this lightweight library.

    Gradle Setup

    Add the following dependency to module/build.gradle:

    compile 'com.lmntrx.android.library.livin.missme:missme:0.1.5'
    

    How to use it?

    Usage is similar to original ProgressDialog

    ProgressDialog progressDialog = new 
    progressDialog(YourActivity.this);
    progressDialog.setMessage("Please wait");
    progressDialog.setCancelable(false);
    progressDialog.show();
    progressDialog.dismiss();
    

    NB: You must override activity's onBackPressed()

    Java8 Implementation:

    @Override
    public void onBackPressed() {
        progressDialog.onBackPressed(
                () -> {
                    super.onBackPressed();
                    return null;
                }
        );
    }
    

    Kotlin Implementation:

    override fun onBackPressed() {
       progressDialog.onBackPressed { super.onBackPressed() }
    }
    
    • Refer Sample App for the full implementation
    • Full documentation can be found here

提交回复
热议问题