Search in sources :

Example 1 with ScreenNail

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();
}
Also used : TiledScreenNail(com.android.gallery3d.ui.TiledScreenNail) BitmapScreenNail(com.android.gallery3d.ui.BitmapScreenNail) ScreenNail(com.android.gallery3d.ui.ScreenNail) TiledScreenNail(com.android.gallery3d.ui.TiledScreenNail)

Example 2 with ScreenNail

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();
    }
}
Also used : BitmapRegionDecoder(android.graphics.BitmapRegionDecoder) TiledScreenNail(com.android.gallery3d.ui.TiledScreenNail) BitmapScreenNail(com.android.gallery3d.ui.BitmapScreenNail) ScreenNail(com.android.gallery3d.ui.ScreenNail)

Example 3 with ScreenNail

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);
    }
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem) LocalMediaItem(com.android.gallery3d.data.LocalMediaItem) TiledTexture(com.android.gallery3d.glrenderer.TiledTexture) TiledScreenNail(com.android.gallery3d.ui.TiledScreenNail) BitmapScreenNail(com.android.gallery3d.ui.BitmapScreenNail) ScreenNail(com.android.gallery3d.ui.ScreenNail) TiledScreenNail(com.android.gallery3d.ui.TiledScreenNail)

Example 4 with ScreenNail

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;
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem) LocalMediaItem(com.android.gallery3d.data.LocalMediaItem) TiledScreenNail(com.android.gallery3d.ui.TiledScreenNail) BitmapScreenNail(com.android.gallery3d.ui.BitmapScreenNail) ScreenNail(com.android.gallery3d.ui.ScreenNail)

Aggregations

BitmapScreenNail (com.android.gallery3d.ui.BitmapScreenNail)4 ScreenNail (com.android.gallery3d.ui.ScreenNail)4 TiledScreenNail (com.android.gallery3d.ui.TiledScreenNail)4 LocalMediaItem (com.android.gallery3d.data.LocalMediaItem)2 MediaItem (com.android.gallery3d.data.MediaItem)2 BitmapRegionDecoder (android.graphics.BitmapRegionDecoder)1 TiledTexture (com.android.gallery3d.glrenderer.TiledTexture)1