Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 404ad5b7 authored by Chao Zhang's avatar Chao Zhang
Browse files

Gallery2: fix share abnormal when select 300 photos.

SelectManager add all path in ArrayList,
so selected count is not the same as actual count.

Just add selectable path in SelectManager.

Change-Id: I76cc1505e65fceff1785a02badd17569e46b4947
CRs-Fixed: 963290
parent f4c20173
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -173,4 +173,12 @@ public abstract class MediaObject {
        }
        throw new IllegalArgumentException();
    }

    /** Some Media Item is not selectable such as Title item in TimeLine. */
    public boolean isSelectable() {
        if (getMediaType() == MediaObject.MEDIA_TYPE_TIMELINE_TITLE) {
            return false;
        }
        return true;
    }
}
+3 −11
Original line number Diff line number Diff line
@@ -285,21 +285,13 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
                return null;
            }
            MediaObject mediaObject = manager.getMediaObject(path);
            if (checkMediaTypeSelectable(mediaObject.getMediaType())) {
            if (mediaObject != null && mediaObject.isSelectable()) {
                selected.add(mediaObject);
            }
        }
        return selected;
    }

    /** Some Media Item is not selectable such as Title item in TimeLine. */
    private boolean checkMediaTypeSelectable(int type) {
        if (type == MediaObject.MEDIA_TYPE_TIMELINE_TITLE) {
            return false;
        }
        return true;
    }

    // Menu options are determined by selection set itself.
    // We cannot expand it because MenuExecuter executes it based on
    // the selection set instead of the expanded result.
@@ -452,9 +444,9 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
                }
                int numSelected = selected.size();
                final boolean canSharePanoramas =
                        numSelected < MAX_SELECTED_ITEMS_FOR_PANORAMA_SHARE_INTENT;
                        numSelected <= MAX_SELECTED_ITEMS_FOR_PANORAMA_SHARE_INTENT;
                final boolean canShare =
                        numSelected < MAX_SELECTED_ITEMS_FOR_SHARE_INTENT;
                        numSelected <= MAX_SELECTED_ITEMS_FOR_SHARE_INTENT;

                final GetAllPanoramaSupports supportCallback = canSharePanoramas ?
                        new GetAllPanoramaSupports(selected, jc)
+14 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.gallery3d.ui;
import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.MediaSet;
import com.android.gallery3d.data.Path;

@@ -227,7 +228,7 @@ public class SelectionManager {
                                return null;
                            }
                        } else {
                            selected.add(id);
                            addPathIfSelectable(selected, id);
                            if (selected.size() > maxSelection) {
                                return null;
                            }
@@ -242,7 +243,7 @@ public class SelectionManager {
                            return null;
                        }
                    } else {
                        selected.add(id);
                        addPathIfSelectable(selected, id);
                        if (selected.size() > maxSelection) {
                            return null;
                        }
@@ -259,7 +260,7 @@ public class SelectionManager {
                    for (MediaItem item : list) {
                        Path id = item.getPath();
                        if (!mClickedSet.contains(id)) {
                            selected.add(id);
                            addPathIfSelectable(selected, id);
                            if (selected.size() > maxSelection) {
                                return null;
                            }
@@ -269,7 +270,7 @@ public class SelectionManager {
                }
            } else {
                for (Path id : mClickedSet) {
                    selected.add(id);
                    addPathIfSelectable(selected, id);
                    if (selected.size() > maxSelection) {
                        return null;
                    }
@@ -279,6 +280,15 @@ public class SelectionManager {
        return selected;
    }

    private void addPathIfSelectable(ArrayList<Path> selected, Path path) {
        if (mDataManager != null) {
            MediaObject mediaObject = mDataManager.getMediaObject(path);
            if (mediaObject != null && mediaObject.isSelectable()) {
                selected.add(path);
            }
        }
    }

    public void setSourceMediaSet(MediaSet set) {
        mSourceMediaSet = set;
        mTotal = -1;