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;
}
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();
}
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);
}
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));
}
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);
}
Aggregations