diff --git a/api/src/com/todoroo/andlib/utility/AndroidUtilities.java b/api/src/com/todoroo/andlib/utility/AndroidUtilities.java index f6a8778c0..f91a0de11 100644 --- a/api/src/com/todoroo/andlib/utility/AndroidUtilities.java +++ b/api/src/com/todoroo/andlib/utility/AndroidUtilities.java @@ -41,6 +41,7 @@ import android.view.View; import android.view.View.OnTouchListener; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; +import android.widget.PopupWindow; import android.widget.TextView; import com.todoroo.andlib.data.Property; @@ -846,4 +847,20 @@ public class AndroidUtilities { } } + /** + * Dismiss a popup window (should call from main thread) + * + * @param activity + * @param popup + */ + public static void tryDismissPopup(Activity activity, final PopupWindow popup) { + if (popup == null) + return; + try { + popup.dismiss(); + } catch (Exception e) { + // window already closed or something + } + } + } diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index 13354e243..c47429dd3 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -462,14 +462,10 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener @Override protected void onPause() { super.onPause(); - if (listsPopover != null) - listsPopover.dismiss(); - if (editPopover != null) - editPopover.dismiss(); - if (mainMenuPopover != null) - mainMenuPopover.dismiss(); - if (commentsPopover != null) - commentsPopover.dismiss(); + AndroidUtilities.tryDismissPopup(this, listsPopover); + AndroidUtilities.tryDismissPopup(this, editPopover); + AndroidUtilities.tryDismissPopup(this, mainMenuPopover); + AndroidUtilities.tryDismissPopup(this, commentsPopover); } @Override