summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui
diff options
context:
space:
mode:
authorChao Zhang <chaoz@codeaurora.org>2016-03-23 14:04:27 +0800
committerChao Zhang <chaoz@codeaurora.org>2016-03-23 14:12:04 +0800
commitecd50c1cecb8baec1d705354551776393ab25622 (patch)
tree523f70e37776d03f37ffc1e2c5b573d50f7c7d05 /src/com/android/gallery3d/ui
parent2c07233db1d15bc5cae3dc899cd1982693b7377b (diff)
downloadandroid_packages_apps_Gallery2-ecd50c1cecb8baec1d705354551776393ab25622.tar.gz
android_packages_apps_Gallery2-ecd50c1cecb8baec1d705354551776393ab25622.tar.bz2
android_packages_apps_Gallery2-ecd50c1cecb8baec1d705354551776393ab25622.zip
Gallery2: fix no prompt when select a album which include 300 photos.
when select a album, it need calculate the count of all items. Change-Id: Id137b8da9cec520106aa5c87ccaeed2bb519357e CRs-Fixed: 989257
Diffstat (limited to 'src/com/android/gallery3d/ui')
-rw-r--r--src/com/android/gallery3d/ui/ActionModeHandler.java33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/com/android/gallery3d/ui/ActionModeHandler.java b/src/com/android/gallery3d/ui/ActionModeHandler.java
index 19a7c5885..226dcea10 100644
--- a/src/com/android/gallery3d/ui/ActionModeHandler.java
+++ b/src/com/android/gallery3d/ui/ActionModeHandler.java
@@ -41,6 +41,7 @@ import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.MediaObject.PanoramaSupportCallback;
+import com.android.gallery3d.data.MediaSet;
import com.android.gallery3d.data.Path;
import com.android.gallery3d.ui.MenuExecutor.ProgressListener;
import com.android.gallery3d.util.Future;
@@ -219,6 +220,9 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
String format = mActivity.getResources().getQuantityString(
R.plurals.number_of_items_selected, count);
setTitle(String.format(format, count));
+ if (count == 0) {
+ mShareMaxDialog = false;
+ }
// For clients who call SelectionManager.selectAll() directly, we need to ensure the
// menu status is consistent with selection manager.
@@ -319,6 +323,26 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
return operation;
}
+ private boolean computeCanShare(ArrayList<MediaObject> selected, int max) {
+ int numSelected = selected.size();
+ if (numSelected > max) {
+ return false;
+ }
+
+ numSelected = 0;
+ for (MediaObject mediaObject : selected) {
+ if (mediaObject instanceof MediaSet) {
+ numSelected = numSelected + ((MediaSet) mediaObject).getTotalMediaItemCount();
+ } else {
+ numSelected = numSelected + 1;
+ }
+ if (numSelected > max) {
+ return false;
+ }
+ }
+ return true;
+ }
+
@TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
private void setNfcBeamPushUris(Uri[] uris) {
if (mNfcAdapter != null && ApiHelper.HAS_SET_BEAM_PUSH_URIS) {
@@ -442,11 +466,10 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
if (jc.isCancelled()) {
return null;
}
- int numSelected = selected.size();
- final boolean canSharePanoramas =
- numSelected <= MAX_SELECTED_ITEMS_FOR_PANORAMA_SHARE_INTENT;
- final boolean canShare =
- numSelected <= MAX_SELECTED_ITEMS_FOR_SHARE_INTENT;
+ final boolean canSharePanoramas = computeCanShare(selected,
+ MAX_SELECTED_ITEMS_FOR_PANORAMA_SHARE_INTENT);
+ final boolean canShare = computeCanShare(selected,
+ MAX_SELECTED_ITEMS_FOR_SHARE_INTENT);
final GetAllPanoramaSupports supportCallback = canSharePanoramas ?
new GetAllPanoramaSupports(selected, jc)