Bug 1366352 - Post: check anchor is set before trying to show GeckoPopupMenu
This means we'll at least see a sensible exception, instead of an NPE when
no anchor is set. That makes it easier to debug cases where no anchor was
set (see e.g. the main commit from this bug).
MozReview-Commit-ID: CzsZaHvnZ6y
--- a/mobile/android/base/java/org/mozilla/gecko/widget/GeckoPopupMenu.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/GeckoPopupMenu.java
@@ -132,16 +132,20 @@ public class GeckoPopupMenu implements G
public void setOnMenuItemLongClickListener(OnMenuItemLongClickListener listener) {
mLongClickListener = listener;
}
/**
* Show the inflated menu.
*/
public void show() {
+ if (mAnchor == null) {
+ throw new IllegalStateException("GeckoPopupMenu.show() called without preceeding call to setAnchor()");
+ }
+
if (!mMenuPopup.isShowing())
mMenuPopup.showAsDropDown(mAnchor);
}
/**
* Hide the inflated menu.
*/
public void dismiss() {