Search in sources :

Example 1 with MediaItem

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

the class GalleryActivity method startViewAction.

private void startViewAction(Intent intent) {
    Boolean slideshow = intent.getBooleanExtra(EXTRA_SLIDESHOW, false);
    if (slideshow) {
        getActionBar().hide();
        DataManager manager = getDataManager();
        Path path = manager.findPathByUri(intent.getData(), intent.getType());
        if (path == null || manager.getMediaObject(path) instanceof MediaItem) {
            path = Path.fromString(manager.getTopSetPath(DataManager.INCLUDE_IMAGE));
        }
        Bundle data = new Bundle();
        data.putString(SlideshowPage.KEY_SET_PATH, path.toString());
        data.putBoolean(SlideshowPage.KEY_RANDOM_ORDER, true);
        data.putBoolean(SlideshowPage.KEY_REPEAT, true);
        if (intent.getBooleanExtra(EXTRA_DREAM, false)) {
            data.putBoolean(SlideshowPage.KEY_DREAM, true);
        }
        getStateManager().startState(SlideshowPage.class, data);
    } else {
        Bundle data = new Bundle();
        DataManager dm = getDataManager();
        Uri uri = intent.getData();
        String contentType = getContentType(intent);
        if (contentType == null) {
            Toast.makeText(this, R.string.no_such_item, Toast.LENGTH_LONG).show();
            finish();
            return;
        }
        if (uri == null) {
            int typeBits = GalleryUtils.determineTypeBits(this, intent);
            data.putInt(KEY_TYPE_BITS, typeBits);
            data.putString(AlbumSetPage.KEY_MEDIA_PATH, getDataManager().getTopSetPath(typeBits));
            getStateManager().startState(AlbumSetPage.class, data);
        } else if (contentType.startsWith(ContentResolver.CURSOR_DIR_BASE_TYPE)) {
            int mediaType = intent.getIntExtra(KEY_MEDIA_TYPES, 0);
            if (mediaType != 0) {
                uri = uri.buildUpon().appendQueryParameter(KEY_MEDIA_TYPES, String.valueOf(mediaType)).build();
            }
            Path setPath = dm.findPathByUri(uri, null);
            MediaSet mediaSet = null;
            if (setPath != null) {
                mediaSet = (MediaSet) dm.getMediaObject(setPath);
            }
            if (mediaSet != null) {
                if (mediaSet.isLeafAlbum()) {
                    data.putString(AlbumPage.KEY_MEDIA_PATH, setPath.toString());
                    data.putString(AlbumPage.KEY_PARENT_MEDIA_PATH, dm.getTopSetPath(DataManager.INCLUDE_ALL));
                    getStateManager().startState(AlbumPage.class, data);
                } else {
                    data.putString(AlbumSetPage.KEY_MEDIA_PATH, setPath.toString());
                    getStateManager().startState(AlbumSetPage.class, data);
                }
            } else {
                startTimelinePage();
            }
        } else {
            Path itemPath = dm.findPathByUri(uri, contentType);
            Path albumPath = dm.getDefaultSetOf(itemPath);
            data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, itemPath.toString());
            if (!intent.getBooleanExtra(KEY_FROM_SNAPCAM, false)) {
                data.putBoolean(PhotoPage.KEY_READONLY, true);
            } else {
                int hintIndex = 0;
                if (View.LAYOUT_DIRECTION_RTL == TextUtils.getLayoutDirectionFromLocale(Locale.getDefault())) {
                    hintIndex = intent.getIntExtra(KEY_TOTAL_NUMBER, 1) - 1;
                }
                data.putInt(PhotoPage.KEY_INDEX_HINT, hintIndex);
            }
            // TODO: Make the parameter "SingleItemOnly" public so other
            // activities can reference it.
            boolean singleItemOnly = (albumPath == null) || intent.getBooleanExtra("SingleItemOnly", false);
            if (!singleItemOnly) {
                data.putString(PhotoPage.KEY_MEDIA_SET_PATH, albumPath.toString());
            }
            data.putBoolean("SingleItemOnly", singleItemOnly);
            // set the cover View to black
            View cover = findViewById(R.id.gl_root_cover);
            cover.setBackgroundColor(Color.BLACK);
            getStateManager().startState(SinglePhotoPage.class, data);
        }
    }
}
Also used : Path(com.android.gallery3d.data.Path) Bundle(android.os.Bundle) DataManager(com.android.gallery3d.data.DataManager) Uri(android.net.Uri) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) BottomNavigationView(android.support.design.widget.BottomNavigationView) TextView(android.widget.TextView) ListView(android.widget.ListView) MediaItem(com.android.gallery3d.data.MediaItem) MediaSet(com.android.gallery3d.data.MediaSet)

Example 2 with MediaItem

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

the class AlbumPage method prepareAnimationBackToFilmstrip.

private void prepareAnimationBackToFilmstrip(int slotIndex) {
    if (mAlbumDataAdapter == null || !mAlbumDataAdapter.isActive(slotIndex))
        return;
    MediaItem item = mAlbumDataAdapter.get(slotIndex);
    if (item == null)
        return;
    TransitionStore transitions = mActivity.getTransitionStore();
    transitions.put(PhotoPage.KEY_INDEX_HINT, slotIndex);
    transitions.put(PhotoPage.KEY_OPEN_ANIMATION_RECT, mSlotView.getSlotRect(slotIndex, mRootPane));
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem)

Example 3 with MediaItem

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

the class AlbumPage method allVideoFiles.

private boolean allVideoFiles() {
    if (mMediaSet == null)
        return false;
    int count = mMediaSet.getMediaItemCount();
    ArrayList<MediaItem> list;
    MediaItem item;
    for (int i = 0; i < count; i++) {
        list = mMediaSet.getMediaItem(i, 1);
        if (list == null) {
            continue;
        }
        if (list.isEmpty()) {
            break;
        }
        item = list.get(0);
        if (item == null) {
            continue;
        }
        if (item.getMimeType().trim().startsWith("image/"))
            return false;
    }
    return true;
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem)

Example 4 with MediaItem

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

the class AlbumPage method onLongTap.

public void onLongTap(int slotIndex) {
    if (mGetContent)
        return;
    MediaItem item = mAlbumDataAdapter.get(slotIndex);
    if (item == null)
        return;
    mSelectionManager.setAutoLeaveSelectionMode(true);
    mSelectionManager.toggle(item.getPath());
    mSlotView.invalidate();
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem)

Example 5 with MediaItem

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

the class AlbumPage method pickPhoto.

private void pickPhoto(int slotIndex, boolean startInFilmstrip) {
    if (!mIsActive)
        return;
    if (!startInFilmstrip) {
        // Launch photos in lights out mode
        mActivity.getGLRoot().setLightsOutMode(true);
    }
    MediaItem item = mAlbumDataAdapter.get(slotIndex);
    // Checking it is RTL or not
    boolean isLayoutRtl = (View.LAYOUT_DIRECTION_RTL == TextUtils.getLayoutDirectionFromLocale(Locale.getDefault())) ? true : false;
    // When not RTL, return directly to ignore the click
    if (!isLayoutRtl && item == null) {
        return;
    }
    if (mGetContent) {
        if (isLayoutRtl && item == null) {
            // Item not ready yet, ignore the click
            return;
        }
        // if (DrmHelper.isDrmFile(DrmHelper.getFilePath(
        // mActivity.getAndroidContext(), item.getContentUri()))) {
        // Toast.makeText(mActivity, R.string.no_permission_for_drm,
        // Toast.LENGTH_SHORT).show();
        // return;
        // }
        onGetContent(item);
    } else if (mLaunchedFromPhotoPage) {
        if (isLayoutRtl && item == null) {
            // Item not ready yet, ignore the click
            return;
        }
        TransitionStore transitions = mActivity.getTransitionStore();
        transitions.put(PhotoPage.KEY_ALBUMPAGE_TRANSITION, PhotoPage.MSG_ALBUMPAGE_PICKED);
        transitions.put(PhotoPage.KEY_INDEX_HINT, slotIndex);
        onBackPressed();
    } else {
        // Get into the PhotoPage.
        // mAlbumView.savePositions(PositionRepository.getInstance(mActivity));
        Bundle data = new Bundle();
        data.putInt(PhotoPage.KEY_INDEX_HINT, slotIndex);
        data.putParcelable(PhotoPage.KEY_OPEN_ANIMATION_RECT, mSlotView.getSlotRect(slotIndex, mRootPane));
        data.putString(PhotoPage.KEY_MEDIA_SET_PATH, mMediaSetPath.toString());
        // Item not ready yet, don't pass the photo path to bundle
        if (!isLayoutRtl && item != null) {
            data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, item.getPath().toString());
        }
        data.putInt(PhotoPage.KEY_ALBUMPAGE_TRANSITION, PhotoPage.MSG_ALBUMPAGE_STARTED);
        data.putBoolean(PhotoPage.KEY_START_IN_FILMSTRIP, startInFilmstrip);
        data.putBoolean(PhotoPage.KEY_IN_CAMERA_ROLL, mMediaSet.isCameraRoll());
        data.putBoolean(PhotoPage.KEY_FROM_VIDEOS_SCREEN, mIsVideoScreen);
        if (startInFilmstrip) {
            mActivity.getStateManager().switchState(this, FilmstripPage.class, data);
        } else {
            mActivity.getStateManager().startStateForResult(SinglePhotoPage.class, REQUEST_PHOTO, data);
        }
    }
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem) Bundle(android.os.Bundle)

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