Search in sources :

Example 6 with MediaSet

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

the class ActionModeHandler method computeCanShare.

private boolean computeCanShare(ArrayList<MediaObject> selected, int max) {
    int numSelected = selected.size();
    boolean ret = computeCanShare(numSelected, max);
    if (!ret)
        return false;
    numSelected = 0;
    for (MediaObject mediaObject : selected) {
        if (mediaObject instanceof MediaSet) {
            numSelected = numSelected + ((MediaSet) mediaObject).getTotalMediaItemCount();
        } else {
            numSelected = numSelected + 1;
        }
        ret = computeCanShare(numSelected, max);
        if (!ret)
            return false;
    }
    return true;
}
Also used : MediaSet(com.android.gallery3d.data.MediaSet) MediaObject(com.android.gallery3d.data.MediaObject)

Example 7 with MediaSet

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

the class WidgetConfigure method setChoosenAlbum.

private void setChoosenAlbum(Intent data) {
    String albumPath = data.getStringExtra(AlbumPicker.KEY_ALBUM_PATH);
    WidgetDatabaseHelper helper = new WidgetDatabaseHelper(this);
    try {
        String relativePath = null;
        GalleryApp galleryApp = (GalleryApp) getApplicationContext();
        DataManager manager = galleryApp.getDataManager();
        Path path = Path.fromString(albumPath);
        MediaSet mediaSet = (MediaSet) manager.getMediaObject(path);
        if (mediaSet instanceof LocalAlbum) {
            int bucketId = Integer.parseInt(path.getSuffix());
            // If the chosen album is a local album, find relative path
            // Otherwise, leave the relative path field empty
            relativePath = LocalAlbum.getRelativePath(bucketId);
            Log.i(TAG, "Setting widget, album path: " + albumPath + ", relative path: " + relativePath);
        }
        helper.setWidget(mAppWidgetId, WidgetDatabaseHelper.TYPE_ALBUM, albumPath, relativePath);
        updateWidgetAndFinish(helper.getEntry(mAppWidgetId));
    } finally {
        helper.close();
    }
}
Also used : Path(com.android.gallery3d.data.Path) MediaSet(com.android.gallery3d.data.MediaSet) LocalAlbum(com.android.gallery3d.data.LocalAlbum) DataManager(com.android.gallery3d.data.DataManager) GalleryApp(com.android.gallery3d.app.GalleryApp)

Example 8 with MediaSet

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

the class MediaSetLoader method uriForItem.

@Override
public Uri uriForItem(Cursor item) {
    int index = item.getInt(AlbumSetLoader.INDEX_ID);
    MediaSet ms = mMediaSet.getSubMediaSet(index);
    return ms == null ? null : ms.getContentUri();
}
Also used : MediaSet(com.android.gallery3d.data.MediaSet)

Example 9 with MediaSet

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

the class MediaSetLoader method urisForSubItems.

@Override
public ArrayList<Uri> urisForSubItems(Cursor item) {
    int index = item.getInt(AlbumSetLoader.INDEX_ID);
    MediaSet ms = mMediaSet.getSubMediaSet(index);
    if (ms == null)
        return null;
    final ArrayList<Uri> result = new ArrayList<Uri>();
    ms.enumerateMediaItems(new MediaSet.ItemConsumer() {

        @Override
        public void consume(int index, MediaItem item) {
            if (item != null) {
                result.add(item.getContentUri());
            }
        }
    });
    return result;
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem) MediaSet(com.android.gallery3d.data.MediaSet) ArrayList(java.util.ArrayList) Uri(android.net.Uri)

Example 10 with MediaSet

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

the class MediaSetLoader method loadInBackground.

@Override
public Cursor loadInBackground() {
    // TODO: This probably doesn't work
    mMediaSet.reload();
    final MatrixCursor cursor = new MatrixCursor(AlbumSetLoader.PROJECTION);
    final Object[] row = new Object[AlbumSetLoader.PROJECTION.length];
    int count = mMediaSet.getSubMediaSetCount();
    ArrayList<MediaItem> coverItems = new ArrayList<MediaItem>(count);
    for (int i = 0; i < count; i++) {
        MediaSet m = mMediaSet.getSubMediaSet(i);
        m.reload();
        row[AlbumSetLoader.INDEX_ID] = i;
        row[AlbumSetLoader.INDEX_TITLE] = m.getName();
        row[AlbumSetLoader.INDEX_COUNT] = m.getMediaItemCount();
        row[AlbumSetLoader.INDEX_SUPPORTED_OPERATIONS] = m.getSupportedOperations();
        MediaItem coverItem = m.getCoverMediaItem();
        if (coverItem != null) {
            row[AlbumSetLoader.INDEX_TIMESTAMP] = coverItem.getDateInMs();
        }
        coverItems.add(coverItem);
        cursor.addRow(row);
    }
    synchronized (mMediaSet) {
        mCoverItems = coverItems;
    }
    return cursor;
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem) MediaSet(com.android.gallery3d.data.MediaSet) ArrayList(java.util.ArrayList) MediaObject(com.android.gallery3d.data.MediaObject) MatrixCursor(android.database.MatrixCursor)

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