Search in sources :

Example 11 with MediaItem

use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.

the class PhotoDataAdapter method updateCurrentIndex.

private void updateCurrentIndex(int index) {
    if (mCurrentIndex == index)
        return;
    mCurrentIndex = index;
    updateSlidingWindow();
    MediaItem item = mData[index % DATA_CACHE_SIZE];
    mItemPath = item == null ? null : item.getPath();
    updateImageCache();
    updateImageRequests();
    updateTileProvider();
    if (mDataListener != null) {
        mDataListener.onPhotoChanged(index, mItemPath);
    }
    fireDataChange();
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem) LocalMediaItem(com.android.gallery3d.data.LocalMediaItem)

Example 12 with MediaItem

use of com.android.gallery3d.data.MediaItem 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 13 with MediaItem

use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.

the class GalleryProvider method getType.

// TODO: consider concurrent access
@Override
public String getType(Uri uri) {
    long token = Binder.clearCallingIdentity();
    try {
        Path path = Path.fromString(uri.getPath());
        MediaItem item = (MediaItem) mDataManager.getMediaObject(path);
        return item != null ? item.getMimeType() : null;
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
Also used : Path(com.android.gallery3d.data.Path) MediaItem(com.android.gallery3d.data.MediaItem)

Example 14 with MediaItem

use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.

the class PhotoView method buildFallbackEffect.

public PhotoFallbackEffect buildFallbackEffect(GLView root, GLCanvas canvas) {
    Rect location = new Rect();
    Utils.assertTrue(root.getBoundsOf(this, location));
    Rect fullRect = bounds();
    PhotoFallbackEffect effect = new PhotoFallbackEffect();
    for (int i = -SCREEN_NAIL_MAX; i <= SCREEN_NAIL_MAX; ++i) {
        MediaItem item = mModel.getMediaItem(i);
        if (item == null)
            continue;
        ScreenNail sc = mModel.getScreenNail(i);
        if (!(sc instanceof TiledScreenNail) || ((TiledScreenNail) sc).isShowingPlaceholder())
            continue;
        // Now, sc is BitmapScreenNail and is not showing placeholder
        Rect rect = new Rect(getPhotoRect(i));
        if (!Rect.intersects(fullRect, rect))
            continue;
        rect.offset(location.left, location.top);
        int width = sc.getWidth();
        int height = sc.getHeight();
        int rotation = mModel.getImageRotation(i);
        RawTexture texture;
        if ((rotation % 180) == 0) {
            texture = new RawTexture(width, height, true);
            canvas.beginRenderTarget(texture);
            canvas.translate(width / 2f, height / 2f);
        } else {
            texture = new RawTexture(height, width, true);
            canvas.beginRenderTarget(texture);
            canvas.translate(height / 2f, width / 2f);
        }
        canvas.rotate(rotation, 0, 0, 1);
        canvas.translate(-width / 2f, -height / 2f);
        sc.draw(canvas, 0, 0, width, height);
        canvas.endRenderTarget();
        effect.addEntry(item.getPath(), rect, texture);
    }
    return effect;
}
Also used : Rect(android.graphics.Rect) RawTexture(com.android.gallery3d.glrenderer.RawTexture) MediaItem(com.android.gallery3d.data.MediaItem)

Example 15 with MediaItem

use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.

the class SelectionManager method expandMediaSet.

private static boolean expandMediaSet(ArrayList<Path> items, MediaSet set, int maxSelection) {
    int subCount = set.getSubMediaSetCount();
    for (int i = 0; i < subCount; i++) {
        if (!expandMediaSet(items, set.getSubMediaSet(i), maxSelection)) {
            return false;
        }
    }
    int total = set.getMediaItemCount();
    int batch = 50;
    int index = 0;
    while (index < total) {
        int count = index + batch < total ? batch : total - index;
        ArrayList<MediaItem> list = set.getMediaItem(index, count);
        if (list != null && list.size() > (maxSelection - items.size())) {
            return false;
        }
        for (MediaItem item : list) {
            items.add(item.getPath());
        }
        index += batch;
    }
    return true;
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem)

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