Last active
March 18, 2016 02:13
-
-
Save rajohns08/e241e087d9a780e82eb6 to your computer and use it in GitHub Desktop.
Android - Custom progress dialog loading indicator utility class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyProgressDialog { | |
private static ProgressDialog progressDialog; | |
public static void show(Context context, int messageResourceId) { | |
if (progressDialog != null) { | |
progressDialog.dismiss(); | |
} | |
int style; | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
style = android.R.style.Theme_Material_Light_Dialog; | |
} else { | |
//noinspection deprecation | |
style = ProgressDialog.THEME_HOLO_LIGHT; | |
} | |
progressDialog = new ProgressDialog(context, style); | |
progressDialog.setMessage(context.getResources().getString(messageResourceId)); | |
progressDialog.setCancelable(false); | |
progressDialog.show(); | |
} | |
public static void dismiss() { | |
if (progressDialog != null && progressDialog.isShowing()) { | |
progressDialog.dismiss(); | |
progressDialog = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment