Search in sources :

Example 1 with SnailItem

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

the class PhotoPage method onItemSelected.

@Override
protected boolean onItemSelected(MenuItem item) {
    if (mModel == null)
        return true;
    refreshHidingMessage();
    MediaItem current = mModel.getMediaItem(0);
    // menu when transitioning from filmstrip to camera
    if (current instanceof SnailItem)
        return true;
    // after PhotoPage being refactored.
    if (current == null) {
        // item is not ready, ignore
        return true;
    }
    int currentIndex = mModel.getCurrentIndex();
    // If RTL, the current index need be revised.
    if (View.LAYOUT_DIRECTION_RTL == TextUtils.getLayoutDirectionFromLocale(Locale.getDefault())) {
        currentIndex = mMediaSet.getMediaItemCount() - currentIndex - 1;
    }
    Path path = current.getPath();
    DataManager manager = mActivity.getDataManager();
    int action = item.getItemId();
    String confirmMsg = null;
    switch(action) {
        case android.R.id.home:
            {
                onUpPressed();
                return true;
            }
        case R.id.action_slideshow:
            {
                Bundle data = new Bundle();
                data.putString(SlideshowPage.KEY_SET_PATH, mMediaSet.getPath().toString());
                data.putString(SlideshowPage.KEY_ITEM_PATH, path.toString());
                data.putInt(SlideshowPage.KEY_PHOTO_INDEX, currentIndex);
                data.putBoolean(SlideshowPage.KEY_REPEAT, true);
                mActivity.getStateManager().startStateForResult(SlideshowPage.class, REQUEST_SLIDESHOW, data);
                return true;
            }
        /*case R.id.action_crop: {
                Activity activity = mActivity;
                Intent intent = new Intent(CropActivity.CROP_ACTION);
                intent.setClass(activity, CropActivity.class);
                intent.setDataAndType(manager.getContentUri(path), current.getMimeType())
                    .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                activity.startActivityForResult(intent, PicasaSource.isPicasaImage(current)
                        ? REQUEST_CROP_PICASA
                        : REQUEST_CROP);
                return true;
            }*/
        case R.id.action_trim:
            {
                Intent intent = new Intent(mActivity, TrimVideo.class);
                intent.setData(manager.getContentUri(path));
                // We need the file path to wrap this into a RandomAccessFile.
                String str = current.getMimeType();
                if ("video/mp4".equals(str) || "video/mpeg4".equals(str) || "video/3gpp".equals(str) || "video/3gpp2".equals(str)) {
                    intent.putExtra(KEY_MEDIA_ITEM_PATH, current.getFilePath());
                    mActivity.startActivityForResult(intent, REQUEST_TRIM);
                } else {
                    Toast.makeText(mActivity, mActivity.getString(R.string.can_not_trim), Toast.LENGTH_SHORT).show();
                }
                return true;
            }
        case R.id.action_mute:
            {
                MuteVideo muteVideo = new MuteVideo(current.getFilePath(), manager.getContentUri(path), mActivity);
                muteVideo.muteInBackground();
                return true;
            }
        case R.id.action_edit:
            {
                launchPhotoEditor();
                return true;
            }
        /*case R.id.action_simple_edit: {
                launchSimpleEditor();
                return true;
            }*/
        case R.id.action_details:
            {
                if (mShowDetails) {
                    hideDetails();
                } else {
                    showDetails();
                }
                return true;
            }
        case R.id.print:
            {
                try {
                    mActivity.printSelectedImage(manager.getContentUri(path));
                } catch (SecurityException e) {
                    e.printStackTrace();
                    mActivity.finish();
                }
                return true;
            }
        case R.id.action_delete:
            confirmMsg = mActivity.getResources().getQuantityString(R.plurals.delete_selection, 1);
        case R.id.action_setas:
        // case R.id.action_rotate_cw:
        case R.id.action_show_on_map:
            mSelectionManager.deSelectAll();
            mSelectionManager.toggle(path);
            mMenuExecutor.onMenuClicked(item, confirmMsg, mConfirmDialogListener);
            return true;
        // return true;
        default:
            return false;
    }
}
Also used : Path(com.android.gallery3d.data.Path) SnailItem(com.android.gallery3d.data.SnailItem) MediaItem(com.android.gallery3d.data.MediaItem) Bundle(android.os.Bundle) DataManager(com.android.gallery3d.data.DataManager) Intent(android.content.Intent)

Aggregations

Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 DataManager (com.android.gallery3d.data.DataManager)1 MediaItem (com.android.gallery3d.data.MediaItem)1 Path (com.android.gallery3d.data.Path)1 SnailItem (com.android.gallery3d.data.SnailItem)1