Search in sources :

Example 21 with MediaItem

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

the class MediaItemsLoader method loadInBackground.

@Override
public Cursor loadInBackground() {
    // TODO: This probably doesn't work
    mMediaSet.reload();
    final MatrixCursor cursor = new MatrixCursor(PhotoSetLoader.PROJECTION);
    final Object[] row = new Object[PhotoSetLoader.PROJECTION.length];
    final SparseArray<MediaItem> mediaItems = new SparseArray<MediaItem>();
    mMediaSet.enumerateTotalMediaItems(new ItemConsumer() {

        @Override
        public void consume(int index, MediaItem item) {
            row[PhotoSetLoader.INDEX_ID] = index;
            row[PhotoSetLoader.INDEX_DATA] = item.getContentUri().toString();
            row[PhotoSetLoader.INDEX_DATE_ADDED] = item.getDateInMs();
            row[PhotoSetLoader.INDEX_HEIGHT] = item.getHeight();
            row[PhotoSetLoader.INDEX_WIDTH] = item.getWidth();
            row[PhotoSetLoader.INDEX_WIDTH] = item.getWidth();
            int rawMediaType = item.getMediaType();
            int mappedMediaType = FileColumns.MEDIA_TYPE_NONE;
            if (rawMediaType == MediaItem.MEDIA_TYPE_IMAGE) {
                mappedMediaType = FileColumns.MEDIA_TYPE_IMAGE;
            } else if (rawMediaType == MediaItem.MEDIA_TYPE_VIDEO) {
                mappedMediaType = FileColumns.MEDIA_TYPE_VIDEO;
            }
            row[PhotoSetLoader.INDEX_MEDIA_TYPE] = mappedMediaType;
            row[PhotoSetLoader.INDEX_SUPPORTED_OPERATIONS] = item.getSupportedOperations();
            cursor.addRow(row);
            mediaItems.append(index, item);
        }
    });
    synchronized (mMediaSet) {
        mMediaItems = mediaItems;
    }
    return cursor;
}
Also used : ItemConsumer(com.android.gallery3d.data.MediaSet.ItemConsumer) SparseArray(android.util.SparseArray) MediaItem(com.android.gallery3d.data.MediaItem) MediaObject(com.android.gallery3d.data.MediaObject) MatrixCursor(android.database.MatrixCursor)

Example 22 with MediaItem

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

the class MediaItemsLoader method uriForItem.

@Override
public Uri uriForItem(Cursor item) {
    int index = item.getInt(PhotoSetLoader.INDEX_ID);
    MediaItem mi = mMediaItems.get(index);
    return mi == null ? null : mi.getContentUri();
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem)

Example 23 with MediaItem

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

the class LocalPhotoSource method getImage.

@Override
public Bitmap getImage(int index) {
    if (index >= mPhotos.size())
        return null;
    long id = mPhotos.get(index);
    MediaItem image = (MediaItem) mDataManager.getMediaObject(LOCAL_IMAGE_ROOT.getChild(id));
    if (image == null)
        return null;
    return WidgetUtils.createWidgetBitmap(image);
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem)

Example 24 with MediaItem

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

the class TimeLinePage method prepareAnimationBackToFilmstrip.

private void prepareAnimationBackToFilmstrip(int slotIndex) {
    if (mAlbumDataAdapter == null || !mAlbumDataAdapter.isActive(slotIndex))
        return;
    MediaItem item = mAlbumDataAdapter.get(slotIndex);
    if (item == null)
        return;
    TransitionStore transitions = mActivity.getTransitionStore();
    transitions.put(PhotoPage.KEY_INDEX_HINT, slotIndex);
    transitions.put(PhotoPage.KEY_OPEN_ANIMATION_RECT, mSlotView.getSlotRect(slotIndex, mRootPane));
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem)

Example 25 with MediaItem

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

the class SlideshowPage method findMediaItem.

private static MediaItem findMediaItem(MediaSet mediaSet, int index) {
    for (int i = 0, n = mediaSet.getSubMediaSetCount(); i < n; ++i) {
        MediaSet subset = mediaSet.getSubMediaSet(i);
        int count = subset.getTotalMediaItemCount();
        if (index < count) {
            return findMediaItem(subset, index);
        }
        index -= count;
    }
    ArrayList<MediaItem> list = mediaSet.getMediaItem(index, 1);
    return list.isEmpty() ? null : list.get(0);
}
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