Search in sources :

Example 36 with MediaItem

use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.

the class SelectionManager method getSelected.

public ArrayList<Path> getSelected(boolean expandSet, int maxSelection) {
    ArrayList<Path> selected = new ArrayList<Path>();
    if (mIsAlbumSet) {
        if (mInverseSelection) {
            int total = getTotalCount();
            for (int i = 0; i < total; i++) {
                MediaSet set = mSourceMediaSet.getSubMediaSet(i);
                Path id = set.getPath();
                if (!mClickedSet.contains(id)) {
                    if (expandSet) {
                        if (!expandMediaSet(selected, set, maxSelection)) {
                            return null;
                        }
                    } else {
                        addPathIfSelectable(selected, id);
                        if (selected.size() > maxSelection) {
                            return null;
                        }
                    }
                }
            }
        } else {
            for (Path id : mClickedSet) {
                if (expandSet) {
                    if (!expandMediaSet(selected, mDataManager.getMediaSet(id), maxSelection)) {
                        return null;
                    }
                } else {
                    addPathIfSelectable(selected, id);
                    if (selected.size() > maxSelection) {
                        return null;
                    }
                }
            }
        }
    } else {
        if (mInverseSelection) {
            int total = getTotalCount();
            int index = 0;
            while (index < total) {
                int count = Math.min(total - index, MediaSet.MEDIAITEM_BATCH_FETCH_COUNT);
                ArrayList<MediaItem> list = mSourceMediaSet.getMediaItem(index, count);
                for (MediaItem item : list) {
                    Path id = item.getPath();
                    if (!mClickedSet.contains(id)) {
                        addPathIfSelectable(selected, id);
                        if (selected.size() > maxSelection) {
                            return null;
                        }
                    }
                }
                index += count;
            }
        } else {
            for (Path id : mClickedSet) {
                addPathIfSelectable(selected, id);
                if (selected.size() > maxSelection) {
                    return null;
                }
            }
        }
    }
    return selected;
}
Also used : Path(com.android.gallery3d.data.Path) MediaItem(com.android.gallery3d.data.MediaItem) MediaSet(com.android.gallery3d.data.MediaSet) ArrayList(java.util.ArrayList)

Example 37 with MediaItem

use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.

the class AlbumSetSlidingWindow method updateAlbumSetEntry.

private void updateAlbumSetEntry(AlbumSetEntry entry, int slotIndex) {
    MediaSet album = mSource.getMediaSet(slotIndex);
    MediaItem cover = mSource.getCoverItem(slotIndex);
    int totalCount = mSource.getTotalCount(slotIndex);
    entry.album = album;
    entry.setDataVersion = getDataVersion(album);
    entry.cacheFlag = identifyCacheFlag(album);
    entry.cacheStatus = identifyCacheStatus(album);
    entry.setPath = (album == null) ? null : album.getPath();
    String title = (album == null) ? "" : Utils.ensureNotNull(album.getName());
    int sourceType = DataSourceType.identifySourceType(album);
    if (isLabelChanged(entry, title, totalCount, sourceType)) {
        entry.title = title;
        entry.totalCount = totalCount;
        entry.sourceType = sourceType;
        if (entry.labelLoader != null) {
            entry.labelLoader.recycle();
            entry.labelLoader = null;
            entry.labelTexture = null;
        }
        if (album != null) {
            entry.labelLoader = new AlbumLabelLoader(slotIndex, title, totalCount, sourceType);
        }
    }
    entry.coverItem = cover;
    if (getDataVersion(cover) != entry.coverDataVersion) {
        entry.coverDataVersion = getDataVersion(cover);
        entry.rotation = (cover == null) ? 0 : cover.getRotation();
        if (entry.coverLoader != null) {
            entry.coverLoader.recycle();
            entry.coverLoader = null;
            entry.bitmapTexture = null;
            entry.content = null;
        }
        if (cover != null) {
            entry.coverLoader = new AlbumCoverLoader(slotIndex, cover);
        }
    }
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem) MediaSet(com.android.gallery3d.data.MediaSet)

Aggregations

MediaItem (com.android.gallery3d.data.MediaItem)37 MediaSet (com.android.gallery3d.data.MediaSet)9 LocalMediaItem (com.android.gallery3d.data.LocalMediaItem)8 Path (com.android.gallery3d.data.Path)8 Intent (android.content.Intent)6 Uri (android.net.Uri)3 Bundle (android.os.Bundle)3 TiledScreenNail (com.android.gallery3d.ui.TiledScreenNail)3 ArrayList (java.util.ArrayList)3 Activity (android.app.Activity)2 MatrixCursor (android.database.MatrixCursor)2 View (android.view.View)2 ThreeDimensionalActivity (com.android.gallery3d.app.dualcam3d.ThreeDimensionalActivity)2 ClusterAlbum (com.android.gallery3d.data.ClusterAlbum)2 DataManager (com.android.gallery3d.data.DataManager)2 MediaObject (com.android.gallery3d.data.MediaObject)2 FilterShowActivity (com.android.gallery3d.filtershow.FilterShowActivity)2 BitmapScreenNail (com.android.gallery3d.ui.BitmapScreenNail)2 ScreenNail (com.android.gallery3d.ui.ScreenNail)2 ResolveInfo (android.content.pm.ResolveInfo)1