Search in sources :

Example 6 with MediaItem

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

the class AlbumPage method onSingleTapUp.

private void onSingleTapUp(int slotIndex) {
    if (!mIsActive)
        return;
    if (mSelectionManager.inSelectionMode()) {
        MediaItem item = mAlbumDataAdapter.get(slotIndex);
        // Item not ready yet, ignore the click
        if (item == null)
            return;
        mSelectionManager.toggle(item.getPath());
        mSlotView.invalidate();
    } else {
        // Render transition in pressed state
        mAlbumView.setPressedIndex(slotIndex);
        mAlbumView.setPressedUp();
        mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_PICK_PHOTO, slotIndex, 0), FadeTexture.DURATION);
    }
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem)

Example 7 with MediaItem

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

the class PhotoPage method launchPhotoEditor.

private void launchPhotoEditor() {
    MediaItem current = mModel.getMediaItem(0);
    if (current == null || (current.getSupportedOperations() & MediaObject.SUPPORT_EDIT) == 0) {
        return;
    }
    Intent intent = new Intent(ACTION_NEXTGEN_EDIT);
    intent.setDataAndType(current.getContentUri(), current.getMimeType()).setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    if (mActivity.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() == 0) {
        intent.setAction(Intent.ACTION_EDIT);
    }
    intent.putExtra(FilterShowActivity.LAUNCH_FULLSCREEN, mActivity.isFullscreen());
    List<ResolveInfo> resolveInfoList = mActivity.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (resolveInfoList != null && resolveInfoList.size() > 0) {
        if (resolveInfoList.size() == 1) {
            // only one app can resolve intent, don't use createChooser.
            mActivity.startActivityForResult(intent, REQUEST_EDIT);
        } else {
            mActivity.startActivityForResult(Intent.createChooser(intent, null), REQUEST_EDIT);
        }
        overrideTransitionToEditor();
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) MediaItem(com.android.gallery3d.data.MediaItem) Intent(android.content.Intent)

Example 8 with MediaItem

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

the class PhotoPage method launchTinyPlanet.

private void launchTinyPlanet() {
    // Deep link into tiny planet
    MediaItem current = mModel.getMediaItem(0);
    Intent intent = new Intent(FilterShowActivity.TINY_PLANET_ACTION);
    intent.setClass(mActivity, FilterShowActivity.class);
    intent.setDataAndType(current.getContentUri(), current.getMimeType()).setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.putExtra(FilterShowActivity.LAUNCH_FULLSCREEN, mActivity.isFullscreen());
    mActivity.startActivityForResult(intent, REQUEST_EDIT);
    overrideTransitionToEditor();
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem) Intent(android.content.Intent)

Example 9 with MediaItem

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

the class PhotoPage method onSingleTapUp.

// //////////////////////////////////////////////////////////////////////////
// Callbacks from PhotoView
// //////////////////////////////////////////////////////////////////////////
@Override
public void onSingleTapUp(int x, int y) {
    if (mAppBridge != null) {
        if (mAppBridge.onSingleTapUp(x, y))
            return;
    }
    MediaItem item = mModel.getMediaItem(0);
    if (item == null || item == mScreenNailItem) {
        // item is not ready or it is camera preview, ignore
        return;
    }
    if (item.getMimeType().equals(MediaItem.MIME_TYPE_GIF)) {
        viewAnimateGif((Activity) mActivity, item.getContentUri());
        return;
    }
    int supported = item.getSupportedOperations();
    boolean playVideo = ((supported & MediaItem.SUPPORT_PLAY) != 0);
    boolean unlock = ((supported & MediaItem.SUPPORT_UNLOCK) != 0);
    boolean goBack = ((supported & MediaItem.SUPPORT_BACK) != 0);
    boolean launchCamera = ((supported & MediaItem.SUPPORT_CAMERA_SHORTCUT) != 0);
    if (playVideo) {
        // determine if the point is at center (1/6) of the photo view.
        // (The position of the "play" icon is at center (1/6) of the photo)
        int w = mPhotoView.getWidth();
        int h = mPhotoView.getHeight();
        playVideo = (Math.abs(x - w / 2) * 12 <= w) && (Math.abs(y - h / 2) * 12 <= h);
    }
    if (playVideo) {
        if (mSecureAlbum == null) {
            playVideo(mActivity, item.getPlayUri(), item.getName());
        } else {
            mActivity.getStateManager().finishState(this);
        }
    } else if (goBack) {
        onBackPressed();
    } else if (unlock) {
        Intent intent = new Intent(mActivity, GalleryActivity.class);
        intent.putExtra(GalleryActivity.KEY_DISMISS_KEYGUARD, true);
        mActivity.startActivity(intent);
    } else if (launchCamera) {
        launchCamera();
    } else {
        toggleBars();
    }
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem) Intent(android.content.Intent)

Example 10 with MediaItem

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

the class PhotoDataAdapter method setCurrentPhoto.

@Override
public void setCurrentPhoto(Path path, int indexHint) {
    if (mItemPath == path)
        return;
    mItemPath = path;
    mCurrentIndex = indexHint;
    updateSlidingWindow();
    updateImageCache();
    fireDataChange();
    // We need to reload content if the path doesn't match.
    MediaItem item = getMediaItem(0);
    if (item != null && item.getPath() != path) {
        if (mReloadTask != null)
            mReloadTask.notifyDirty();
    }
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem) LocalMediaItem(com.android.gallery3d.data.LocalMediaItem)

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