From 5afe58bbb2af4045b122a138438b4018486456a9 Mon Sep 17 00:00:00 2001 From: yongga Date: Tue, 12 Jan 2016 14:23:17 +0800 Subject: CMFileManager: Do not create multiple action dialogs Multiple instances of ActionsDialog are created if the user clicks the menu too quickly. Do not create an instance if a dialog has already been displayed. CRs-Fixed: 960229, 970649 Change-Id: I610331cf71cb1b59aef6f89d8fdcb1c6ccda6044 --- .../filemanager/activities/NavigationActivity.java | 12 ++++++++---- .../cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java | 10 ++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java b/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java index e1e4a35f..cc9ecce5 100755 --- a/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java +++ b/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java @@ -207,6 +207,7 @@ public class NavigationActivity extends Activity private InputMethodManager mImm; private FilesystemInfoDialog.OnConfigChangeListener mOnConfigChangeListener; private ListPopupWindow mPopupWindow; + private ActionsDialog mActionsDialog; private final BroadcastReceiver mNotificationReceiver = new BroadcastReceiver() { @Override @@ -2526,10 +2527,13 @@ public class NavigationActivity extends Activity // For this to work, SecureConsole NEEDS to be refactored. // Show the dialog - ActionsDialog dialog = new ActionsDialog(this, this, item, global, false); - dialog.setOnRequestRefreshListener(this); - dialog.setOnSelectionListener(getCurrentNavigationView()); - dialog.show(); + if (mActionsDialog != null && mActionsDialog.isShowing()) { + return; + } + mActionsDialog = new ActionsDialog(this, this, item, global, false); + mActionsDialog.setOnRequestRefreshListener(this); + mActionsDialog.setOnSelectionListener(getCurrentNavigationView()); + mActionsDialog.show(); } /** diff --git a/src/com/cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java b/src/com/cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java index 753c382f..4d0c436a 100644 --- a/src/com/cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java +++ b/src/com/cyanogenmod/filemanager/ui/dialogs/ActionsDialog.java @@ -198,6 +198,16 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen DialogHelper.delegateDialogShow(this.mContext, this.mDialog); } + /** + * Method that judges whether the dialog is showing. + */ + public boolean isShowing() { + if (this.mDialog != null) { + return this.mDialog.isShowing(); + } + return false; + } + /** * {@inheritDoc} */ -- cgit v1.2.3