Search in sources :

Example 31 with MediaItem

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

Example 32 with MediaItem

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

Example 33 with MediaItem

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

Example 34 with MediaItem

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();
    }
}
Also used : Path(com.android.gallery3d.data.Path) ClusterAlbum(com.android.gallery3d.data.ClusterAlbum) MediaItem(com.android.gallery3d.data.MediaItem) MediaSet(com.android.gallery3d.data.MediaSet)

Example 35 with MediaItem

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);
    }
}
Also used : Path(com.android.gallery3d.data.Path) ClusterAlbum(com.android.gallery3d.data.ClusterAlbum) MediaItem(com.android.gallery3d.data.MediaItem) MediaSet(com.android.gallery3d.data.MediaSet)

Aggregations

MediaItem (com.android.gallery3d.data.MediaItem)37 MediaSet (com.android.gallery3d.data.MediaSet)9 LocalMediaItem (com.android.gallery3d.data.LocalMediaItem)8 Path (com.android.gallery3d.data.Path)8 Intent (android.content.Intent)6 Uri (android.net.Uri)3 Bundle (android.os.Bundle)3 TiledScreenNail (com.android.gallery3d.ui.TiledScreenNail)3 ArrayList (java.util.ArrayList)3 Activity (android.app.Activity)2 MatrixCursor (android.database.MatrixCursor)2 View (android.view.View)2 ThreeDimensionalActivity (com.android.gallery3d.app.dualcam3d.ThreeDimensionalActivity)2 ClusterAlbum (com.android.gallery3d.data.ClusterAlbum)2 DataManager (com.android.gallery3d.data.DataManager)2 MediaObject (com.android.gallery3d.data.MediaObject)2 FilterShowActivity (com.android.gallery3d.filtershow.FilterShowActivity)2 BitmapScreenNail (com.android.gallery3d.ui.BitmapScreenNail)2 ScreenNail (com.android.gallery3d.ui.ScreenNail)2 ResolveInfo (android.content.pm.ResolveInfo)1