use of com.android.gallery3d.ui.ScreenNail 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.ScreenNail in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoDataAdapter method updateTileProvider.
private void updateTileProvider(ImageEntry entry) {
ScreenNail screenNail = getTargetScreenNail(entry);
BitmapRegionDecoder fullImage = entry.fullImage;
if (screenNail != null) {
if (fullImage != null) {
mTileProvider.setScreenNail(screenNail, fullImage.getWidth(), fullImage.getHeight());
mTileProvider.setRegionDecoder(fullImage);
} else {
int width = screenNail.getWidth();
int height = screenNail.getHeight();
mTileProvider.setScreenNail(screenNail, width, height);
}
} else {
mTileProvider.clear();
}
}
use of com.android.gallery3d.ui.ScreenNail 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.ScreenNail 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;
}
Aggregations