Search in sources :

Example 16 with Path

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

the class PhotoPage method on3DButtonClicked.

@Override
public void on3DButtonClicked() {
    if (mCurrentPhoto != null) {
        Path p = mCurrentPhoto.getPath();
        Uri uri = mActivity.getDataManager().getContentUri(p);
        Intent intent = new Intent();
        intent.setClass(mActivity, ThreeDimensionalActivity.class);
        intent.setData(uri);
        mActivity.startActivity(intent);
    }
}
Also used : Path(com.android.gallery3d.data.Path) Intent(android.content.Intent) Uri(android.net.Uri)

Example 17 with Path

use of com.android.gallery3d.data.Path 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();
}
Also used : Path(com.android.gallery3d.data.Path) MediaItem(com.android.gallery3d.data.MediaItem) LocalMediaItem(com.android.gallery3d.data.LocalMediaItem) HashSet(java.util.HashSet) TiledScreenNail(com.android.gallery3d.ui.TiledScreenNail)

Example 18 with Path

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

use of com.android.gallery3d.data.Path 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)

Example 20 with Path

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

the class GalleryProvider method query.

// TODO: consider concurrent access
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    long token = Binder.clearCallingIdentity();
    try {
        Path path = Path.fromString(uri.getPath());
        MediaObject object = mDataManager.getMediaObject(path);
        if (object == null) {
            Log.w(TAG, "cannot find: " + uri);
            return null;
        }
        if (PicasaSource.isPicasaImage(object)) {
            return queryPicasaItem(object, projection, selection, selectionArgs, sortOrder);
        } else {
            return null;
        }
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
Also used : Path(com.android.gallery3d.data.Path) MediaObject(com.android.gallery3d.data.MediaObject)

Aggregations

Path (com.android.gallery3d.data.Path)25 MediaSet (com.android.gallery3d.data.MediaSet)9 DataManager (com.android.gallery3d.data.DataManager)8 MediaItem (com.android.gallery3d.data.MediaItem)8 Intent (android.content.Intent)6 Uri (android.net.Uri)6 ArrayList (java.util.ArrayList)4 Bundle (android.os.Bundle)3 MediaObject (com.android.gallery3d.data.MediaObject)3 Activity (android.app.Activity)2 View (android.view.View)2 GalleryApp (com.android.gallery3d.app.GalleryApp)2 ClusterAlbum (com.android.gallery3d.data.ClusterAlbum)2 LocalAlbum (com.android.gallery3d.data.LocalAlbum)2 MenuExecutor (com.android.gallery3d.ui.MenuExecutor)2 Message (android.os.Message)1 BottomNavigationView (android.support.design.widget.BottomNavigationView)1 MenuItem (android.view.MenuItem)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1