use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoDataAdapter method getScreenNail.
@Override
public ScreenNail getScreenNail(int offset) {
int index = mCurrentIndex + offset;
if (index < 0 || index >= mSize || !mIsActive)
return null;
Utils.assertTrue(index >= mActiveStart && index < mActiveEnd);
MediaItem item = getItem(index);
if (item == null)
return null;
ImageEntry entry = mImageCache.get(item.getPath());
if (entry == null)
return null;
ScreenNail targetScreenNail = getTargetScreenNail(entry);
if (targetScreenNail != null)
return targetScreenNail;
// except for camera that a black screen is better than a gray tile.
if (entry.screenNail == null && !isCamera(offset)) {
entry.screenNail = newPlaceholderScreenNail(item);
if (offset == 0)
updateTileProvider(entry);
}
return entry.screenNail;
}
use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoDataAdapter method startTaskIfNeeded.
// Returns the task if we started the task or the task is already started.
private Future<?> startTaskIfNeeded(int index, int which) {
if (index < mActiveStart || index >= mActiveEnd)
return null;
ImageEntry entry = mImageCache.get(getPath(index));
if (entry == null)
return null;
MediaItem item = mData[index % DATA_CACHE_SIZE];
Utils.assertTrue(item != null);
long version = item.getDataVersion();
if (which == BIT_SCREEN_NAIL && entry.screenNailTask != null && entry.requestedScreenNail == version) {
return entry.screenNailTask;
} else if (which == BIT_FULL_IMAGE && entry.fullImageTask != null && entry.requestedFullImage == version) {
return entry.fullImageTask;
} else if (which == BIT_GIF_ANIMATION && entry.gifDecoderTask != null && entry.requestedGif == version) {
return entry.gifDecoderTask;
}
if (which == BIT_SCREEN_NAIL && entry.requestedScreenNail != version) {
entry.requestedScreenNail = version;
entry.screenNailTask = mThreadPool.submit(new ScreenNailJob(item), new ScreenNailListener(item));
// request screen nail
return entry.screenNailTask;
}
if (which == BIT_FULL_IMAGE && entry.requestedFullImage != version && (item.getSupportedOperations() & MediaItem.SUPPORT_FULL_IMAGE) != 0) {
entry.requestedFullImage = version;
entry.fullImageTask = mThreadPool.submit(new FullImageJob(item), new FullImageListener(item));
// request full image
return entry.fullImageTask;
}
if (which == BIT_GIF_ANIMATION && (entry.requestedGif != version) && isGif(0)) {
entry.requestedGif = version;
entry.gifDecoderTask = mThreadPool.submit(new GifDecoderJob(item), new GifDecoderListener(item.getPath()));
// request gif decoder
return entry.gifDecoderTask;
}
return null;
}
use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoDataAdapter method getImageSize.
@Override
public void getImageSize(int offset, PhotoView.Size size) {
MediaItem item = getItem(mCurrentIndex + offset);
if (item == null) {
size.width = 0;
size.height = 0;
} else {
size.width = item.getWidth();
size.height = item.getHeight();
}
}
use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.
the class TimeLinePage method onLongTap.
public void onLongTap(int slotIndex, boolean isTitle) {
if (mGetContent)
return;
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.setAutoLeaveSelectionMode(true);
mSelectionManager.toggleTimeLineSet(paths);
mSlotView.invalidate();
} else {
MediaItem item = mAlbumDataAdapter.get(slotIndex);
if (item == null)
return;
mSelectionManager.setAutoLeaveSelectionMode(true);
mSelectionManager.toggle(item.getPath());
mSlotView.invalidate();
}
}
use of com.android.gallery3d.data.MediaItem 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);
}
}
Aggregations