Fixed a crash when dismissing popup windows

pull/14/head
Sam Bosley 13 years ago
parent 31c21d5117
commit 2645d542ad

@ -41,6 +41,7 @@ import android.view.View;
import android.view.View.OnTouchListener; import android.view.View.OnTouchListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.PopupWindow;
import android.widget.TextView; import android.widget.TextView;
import com.todoroo.andlib.data.Property; 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
}
}
} }

@ -462,14 +462,10 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
if (listsPopover != null) AndroidUtilities.tryDismissPopup(this, listsPopover);
listsPopover.dismiss(); AndroidUtilities.tryDismissPopup(this, editPopover);
if (editPopover != null) AndroidUtilities.tryDismissPopup(this, mainMenuPopover);
editPopover.dismiss(); AndroidUtilities.tryDismissPopup(this, commentsPopover);
if (mainMenuPopover != null)
mainMenuPopover.dismiss();
if (commentsPopover != null)
commentsPopover.dismiss();
} }
@Override @Override

Loading…
Cancel
Save