Im dismissing progress dialog when AsyncTask is finished. Should i check isShowing before dismissing it?
I've tried remove this check and it works normally, but may be there are hidden traps?
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
You shouldnt have to check for isShowing to dismiss it. If you dont check for isShowing it will just ignore the dismiss() is the progressbar isnt showing.
But checking for isShowing is a good practice. So it wont hurt to continue to check for it.
Is seems that is checked inside implementation:
public void dismiss() {
if (Thread.currentThread() != mUiThread) {
mHandler.post(mDismissAction);
} else {
mDismissAction.run();
}
}
private void dismissDialog() {
if (mDecor == null || !mShowing) {
return;
}
try {
mWindowManager.removeView(mDecor);
} finally {
mDecor = null;
mWindow.closeAllPanels();
onStop();
mShowing = false;
sendDismissMessage();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With