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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/SelectPopupDialog.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/SelectPopupDialog.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/SelectPopupDialog.java b/content/public/android/java/src/org/chromium/content/browser/input/SelectPopupDialog.java
index 1ebbbf7da49296b4e30f66d4dc529bf798248236..803db1e2c3e0b87ff59251850772a2caabc9700a 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/SelectPopupDialog.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/SelectPopupDialog.java
@@ -29,11 +29,12 @@ public class SelectPopupDialog implements SelectPopup {
};
// The dialog hosting the popup list view.
- private AlertDialog mListBoxPopup = null;
-
+ private final AlertDialog mListBoxPopup;
private final ContentViewCore mContentViewCore;
private final Context mContext;
+ private boolean mSelectionNotified;
+
public SelectPopupDialog(ContentViewCore contentViewCore, List<SelectPopupItem> items,
boolean multiple, int[] selected) {
mContentViewCore = contentViewCore;
@@ -50,14 +51,14 @@ public class SelectPopupDialog implements SelectPopup {
b.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- mContentViewCore.selectPopupMenuItems(getSelectedIndices(listView));
+ notifySelection(getSelectedIndices(listView));
}
});
b.setNegativeButton(android.R.string.cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- mContentViewCore.selectPopupMenuItems(null);
+ notifySelection(null);
}
});
}
@@ -78,7 +79,7 @@ public class SelectPopupDialog implements SelectPopup {
@Override
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
- mContentViewCore.selectPopupMenuItems(getSelectedIndices(listView));
+ notifySelection(getSelectedIndices(listView));
mListBoxPopup.dismiss();
}
});
@@ -90,7 +91,7 @@ public class SelectPopupDialog implements SelectPopup {
mListBoxPopup.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
- mContentViewCore.selectPopupMenuItems(null);
+ notifySelection(null);
}
});
}
@@ -104,7 +105,7 @@ public class SelectPopupDialog implements SelectPopup {
return resourceId;
}
- private int[] getSelectedIndices(ListView listView) {
+ private static int[] getSelectedIndices(ListView listView) {
jdduke (slow) 2014/09/25 21:43:30 Woo!
SparseBooleanArray sparseArray = listView.getCheckedItemPositions();
int selectedCount = 0;
for (int i = 0; i < sparseArray.size(); ++i) {
@@ -121,6 +122,12 @@ public class SelectPopupDialog implements SelectPopup {
return indices;
}
+ private void notifySelection(int[] indicies) {
+ if (mSelectionNotified) return;
+ mContentViewCore.selectPopupMenuItems(indicies);
+ mSelectionNotified = true;
+ }
+
@Override
public void show() {
mListBoxPopup.show();
@@ -129,5 +136,6 @@ public class SelectPopupDialog implements SelectPopup {
@Override
public void hide() {
mListBoxPopup.cancel();
+ notifySelection(null);
}
}

Powered by Google App Engine
This is Rietveld 408576698