當AsyncTask結束時,我會摧毀progress dialog。在摧毀progress dialog之前我是否要檢查isShowing的值?
我試圖不檢查,同樣會正常運行,但是不是有隱藏的漏洞?
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
似乎是在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();
}
}