use of com.android.gallery3d.ui.TiledScreenNail in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoDataAdapter method updateScreenNail.
private void updateScreenNail(Path path, Future<ScreenNail> future) {
ImageEntry entry = mImageCache.get(path);
ScreenNail screenNail = future.get();
if (entry == null || entry.screenNailTask != future) {
if (screenNail != null)
screenNail.recycle();
return;
}
entry.screenNailTask = null;
// Combine the ScreenNails if we already have a BitmapScreenNail
if (entry.screenNail instanceof TiledScreenNail) {
TiledScreenNail original = (TiledScreenNail) entry.screenNail;
screenNail = original.combine(screenNail);
}
if (screenNail == null) {
entry.failToLoad = true;
} else {
entry.failToLoad = false;
entry.screenNail = screenNail;
}
for (int i = -SCREEN_NAIL_MAX; i <= SCREEN_NAIL_MAX; ++i) {
if (path == getPath(mCurrentIndex + i)) {
if (i == 0)
updateTileProvider(entry);
mPhotoView.notifyImageChange(i);
break;
}
}
updateImageRequests();
updateScreenNailUploadQueue();
}
use of com.android.gallery3d.ui.TiledScreenNail in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoDataAdapter method uploadScreenNail.
private void uploadScreenNail(int offset) {
int index = mCurrentIndex + offset;
if (index < mActiveStart || index >= mActiveEnd)
return;
MediaItem item = getItem(index);
if (item == null)
return;
ImageEntry e = mImageCache.get(item.getPath());
if (e == null)
return;
ScreenNail s = e.screenNail;
if (s instanceof TiledScreenNail) {
TiledTexture t = ((TiledScreenNail) s).getTexture();
if (t != null && !t.isReady())
mUploader.addTexture(t);
}
}
use of com.android.gallery3d.ui.TiledScreenNail in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoDataAdapter method updateImageCache.
private void updateImageCache() {
HashSet<Path> toBeRemoved = new HashSet<Path>(mImageCache.keySet());
for (int i = mActiveStart; i < mActiveEnd; ++i) {
MediaItem item = mData[i % DATA_CACHE_SIZE];
if (item == null)
continue;
Path path = item.getPath();
ImageEntry entry = mImageCache.get(path);
toBeRemoved.remove(path);
if (entry != null) {
if (Math.abs(i - mCurrentIndex) > 1) {
if (entry.fullImageTask != null) {
entry.fullImageTask.cancel();
entry.fullImageTask = null;
}
entry.fullImage = null;
entry.requestedFullImage = MediaObject.INVALID_DATA_VERSION;
}
if (entry.requestedScreenNail != item.getDataVersion()) {
// still a placeholder.
if (entry.screenNail instanceof TiledScreenNail) {
TiledScreenNail s = (TiledScreenNail) entry.screenNail;
s.updatePlaceholderSize(item.getWidth(), item.getHeight());
}
}
if (Math.abs(i - mCurrentIndex) > 0) {
if (entry.gifDecoderTask != null) {
entry.gifDecoderTask.cancel();
entry.gifDecoderTask = null;
}
entry.gifDecoder = null;
entry.requestedGif = MediaItem.INVALID_DATA_VERSION;
if (null != entry.currentGifFrame) {
// recycle cached gif frame
entry.currentGifFrame.recycle();
entry.currentGifFrame = null;
}
}
} else {
entry = new ImageEntry();
mImageCache.put(path, entry);
}
}
// Clear the data and requests for ImageEntries outside the new window.
for (Path path : toBeRemoved) {
ImageEntry entry = mImageCache.remove(path);
if (entry.fullImageTask != null)
entry.fullImageTask.cancel();
if (entry.screenNailTask != null)
entry.screenNailTask.cancel();
if (entry.screenNail != null)
entry.screenNail.recycle();
}
updateScreenNailUploadQueue();
}
Aggregations