Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1346)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/SelectPopupDropdown.java

Issue 603303002: Fix crash when showing multiple popups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/input/SelectPopupDropdown.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/SelectPopupDropdown.java b/content/public/android/java/src/org/chromium/content/browser/input/SelectPopupDropdown.java
index 475cfae2b80b329775035bc50320df3df6425c21..4604d45fe3b88766eac81fc7ae42f6f324d1c319 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/SelectPopupDropdown.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/SelectPopupDropdown.java
@@ -25,10 +25,10 @@ public class SelectPopupDropdown implements SelectPopup {
private final ContentViewCore mContentViewCore;
private final Context mContext;
+ private final DropdownPopupWindow mDropdownPopupWindow;
- private DropdownPopupWindow mDropdownPopupWindow;
private int mInitialSelection = -1;
- private boolean mAlreadySelectedItems = false;
+ private boolean mSelectionNotified;
public SelectPopupDropdown(ContentViewCore contentViewCore, List<SelectPopupItem> items,
Rect bounds, int[] selected) {
@@ -39,9 +39,7 @@ public class SelectPopupDropdown implements SelectPopup {
mDropdownPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- int[] selectedIndices = {position};
- mContentViewCore.selectPopupMenuItems(selectedIndices);
- mAlreadySelectedItems = true;
+ notifySelection(new int[] {position});
hide();
}
});
@@ -64,13 +62,17 @@ public class SelectPopupDropdown implements SelectPopup {
new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
- if (!mAlreadySelectedItems) {
- mContentViewCore.selectPopupMenuItems(null);
- }
+ notifySelection(null);
}
});
}
+ private void notifySelection(int[] indicies) {
+ if (mSelectionNotified) return;
+ mContentViewCore.selectPopupMenuItems(indicies);
+ mSelectionNotified = true;
+ }
+
@Override
public void show() {
mDropdownPopupWindow.show();
@@ -82,5 +84,6 @@ public class SelectPopupDropdown implements SelectPopup {
@Override
public void hide() {
mDropdownPopupWindow.dismiss();
+ notifySelection(null);
}
}

Powered by Google App Engine
This is Rietveld 408576698