Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class BaseActivity extends AppCompatActivity {
private ProgressDialog progressDialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
progressDialog = new ProgressDialog(this);
progressDialog.setTitle("Title here");
progressDialog.setMessage("Message here");
}
protected void showLoadingDialog() {
hideLoadingDialog();
progressDialog.show();
}
protected void hideLoadingDialog() {
if (progressDialog != null && progressDialog.isShowing())
progressDialog.dismiss();
}
}
public class TestActivity extends BaseActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
showLoadingDialog();
}
@Override
protected void onStop() {
super.onStop();
hideLoadingDialog();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment