Search in sources :

Example 16 with MediaSet

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

the class TimeLinePage method onSingleTapUp.

private void onSingleTapUp(int slotIndex, boolean isTitle) {
    if (!mIsActive)
        return;
    if (mSelectionManager.inSelectionMode()) {
        if (isTitle) {
            MediaSet targetSet = mAlbumDataAdapter.getMediaSet(slotIndex);
            if (targetSet == null)
                return;
            ArrayList<Path> paths = ((ClusterAlbum) targetSet).getMediaItems();
            if (paths == null || paths.size() <= 0)
                return;
            mSelectionManager.toggleTimeLineSet(paths);
            mSlotView.invalidate();
        } else {
            MediaItem item = mAlbumDataAdapter.get(slotIndex);
            // Item not ready yet, ignore the click
            if (item == null)
                return;
            if (mSelectionManager.getSelectedCount() > 0) {
                if (!ActionModeHandler.isThreadComplete)
                    return;
            }
            mSelectionManager.toggle(item.getPath());
            mSlotView.invalidate();
        }
    } else if (!isTitle) {
        // Render transition in pressed state
        mAlbumView.setPressedIndex(slotIndex);
        mAlbumView.setPressedUp();
        mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_PICK_PHOTO, slotIndex, 0), FadeTexture.DURATION);
    }
}
Also used : Path(com.android.gallery3d.data.Path) ClusterAlbum(com.android.gallery3d.data.ClusterAlbum) MediaItem(com.android.gallery3d.data.MediaItem) MediaSet(com.android.gallery3d.data.MediaSet)

Example 17 with MediaSet

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

the class AlbumSetPage method onSingleTapUp.

public void onSingleTapUp(int slotIndex) {
    if (!mIsActive)
        return;
    if (mSelectionManager.inSelectionMode()) {
        MediaSet targetSet = mAlbumSetDataAdapter.getMediaSet(slotIndex);
        // Content is dirty, we shall reload soon
        if (targetSet == null)
            return;
        mSelectionManager.toggle(targetSet.getPath());
        mSlotView.invalidate();
    } else {
        // Show pressed-up animation for the single-tap.
        mAlbumSetView.setPressedIndex(slotIndex);
        mAlbumSetView.setPressedUp();
        mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_PICK_ALBUM, slotIndex, 0), FadeTexture.DURATION);
    }
}
Also used : MediaSet(com.android.gallery3d.data.MediaSet)

Example 18 with MediaSet

use of com.android.gallery3d.data.MediaSet 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 19 with MediaSet

use of com.android.gallery3d.data.MediaSet 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)

Example 20 with MediaSet

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

the class GalleryWidgetMigrator method migrateGalleryWidgetsInternal.

private static void migrateGalleryWidgetsInternal(Context context) {
    GalleryApp galleryApp = (GalleryApp) context.getApplicationContext();
    DataManager manager = galleryApp.getDataManager();
    WidgetDatabaseHelper dbHelper = new WidgetDatabaseHelper(context);
    // only need to migrate local-album entries of type TYPE_ALBUM
    List<Entry> entries = dbHelper.getEntries(WidgetDatabaseHelper.TYPE_ALBUM);
    if (entries == null)
        return;
    // Check each entry's relativePath. If exists, update bucket id using relative
    // path combined with external storage path. Otherwise, iterate through old external
    // storage paths to find the relative path that matches the old bucket id, and then update
    // bucket id and relative path
    HashMap<Integer, Entry> localEntries = new HashMap<Integer, Entry>(entries.size());
    for (Entry entry : entries) {
        Path path = Path.fromString(entry.albumPath);
        MediaSet mediaSet = (MediaSet) manager.getMediaObject(path);
        if (mediaSet instanceof LocalAlbum) {
            if (entry.relativePath != null && entry.relativePath.length() > 0) {
                // update entry using relative path + external storage path
                updateEntryUsingRelativePath(entry, dbHelper);
            } else {
                int bucketId = Integer.parseInt(path.getSuffix());
                localEntries.put(bucketId, entry);
            }
        }
    }
    if (!localEntries.isEmpty())
        migrateLocalEntries(context, localEntries, dbHelper);
}
Also used : Path(com.android.gallery3d.data.Path) Entry(com.android.gallery3d.gadget.WidgetDatabaseHelper.Entry) HashMap(java.util.HashMap) WidgetDatabaseHelper(com.android.gallery3d.gadget.WidgetDatabaseHelper) MediaSet(com.android.gallery3d.data.MediaSet) LocalAlbum(com.android.gallery3d.data.LocalAlbum) DataManager(com.android.gallery3d.data.DataManager) GalleryApp(com.android.gallery3d.app.GalleryApp)

Aggregations

MediaSet (com.android.gallery3d.data.MediaSet)20 MediaItem (com.android.gallery3d.data.MediaItem)9 Path (com.android.gallery3d.data.Path)9 Uri (android.net.Uri)3 DataManager (com.android.gallery3d.data.DataManager)3 ArrayList (java.util.ArrayList)3 Activity (android.app.Activity)2 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 View (android.view.View)2 GalleryApp (com.android.gallery3d.app.GalleryApp)2 ClusterAlbum (com.android.gallery3d.data.ClusterAlbum)2 LocalAlbum (com.android.gallery3d.data.LocalAlbum)2 MediaObject (com.android.gallery3d.data.MediaObject)2 MatrixCursor (android.database.MatrixCursor)1 Message (android.os.Message)1 BottomNavigationView (android.support.design.widget.BottomNavigationView)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1