Search in sources :

Example 1 with MediaSet

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

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

the class AlbumSetPage method onLongTap.

public void onLongTap(int slotIndex) {
    if (mGetContent || mGetAlbum)
        return;
    MediaSet set = mAlbumSetDataAdapter.getMediaSet(slotIndex);
    if (set == null)
        return;
    mSelectionManager.setAutoLeaveSelectionMode(true);
    mSelectionManager.toggle(set.getPath());
    mSlotView.invalidate();
}
Also used : MediaSet(com.android.gallery3d.data.MediaSet)

Example 3 with MediaSet

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

the class AlbumSetPage method pickAlbum.

private void pickAlbum(int slotIndex) {
    if (mActivity.getStateManager().getStateCount() >= 1) {
        android.widget.Toolbar toolbar = mActivity.getToolbar();
        if (toolbar != null) {
            ((GalleryActivity) mActivity).toggleNavBar(false);
        }
    }
    if (!mIsActive)
        return;
    MediaSet targetSet = mAlbumSetDataAdapter.getMediaSet(slotIndex);
    // Content is dirty, we shall reload soon
    if (targetSet == null)
        return;
    if (targetSet.getTotalMediaItemCount() == 0) {
        showEmptyAlbumToast(Toast.LENGTH_SHORT);
        return;
    }
    hideEmptyAlbumToast();
    String mediaPath = targetSet.getPath().toString();
    Bundle data = new Bundle(getData());
    int[] center = new int[2];
    getSlotCenter(slotIndex, center);
    data.putIntArray(AlbumPage.KEY_SET_CENTER, center);
    if (mGetAlbum && targetSet.isLeafAlbum()) {
        Activity activity = mActivity;
        Intent result = new Intent().putExtra(AlbumPicker.KEY_ALBUM_PATH, targetSet.getPath().toString());
        activity.setResult(Activity.RESULT_OK, result);
        activity.finish();
    } else if (targetSet.getSubMediaSetCount() > 0) {
        data.putString(AlbumSetPage.KEY_MEDIA_PATH, mediaPath);
        mActivity.getStateManager().startStateForResult(AlbumSetPage.class, REQUEST_DO_ANIMATION, data);
    } else {
        if (!mGetContent && albumShouldOpenInFilmstrip(targetSet)) {
            data.putParcelable(PhotoPage.KEY_OPEN_ANIMATION_RECT, mSlotView.getSlotRect(slotIndex, mRootPane));
            data.putInt(PhotoPage.KEY_INDEX_HINT, 0);
            data.putString(PhotoPage.KEY_MEDIA_SET_PATH, mediaPath);
            data.putBoolean(PhotoPage.KEY_START_IN_FILMSTRIP, false);
            data.putBoolean(PhotoPage.KEY_IN_CAMERA_ROLL, targetSet.isCameraRoll());
            mActivity.getStateManager().startStateForResult(SinglePhotoPage.class, AlbumPage.REQUEST_PHOTO, data);
            return;
        }
        data.putString(AlbumPage.KEY_MEDIA_PATH, mediaPath);
        // We only show cluster menu in the first AlbumPage in stack
        boolean inAlbum = mActivity.getStateManager().hasStateClass(AlbumPage.class);
        data.putBoolean(AlbumPage.KEY_SHOW_CLUSTER_MENU, !inAlbum);
        mActivity.getStateManager().startStateForResult(AlbumPage.class, REQUEST_DO_ANIMATION, data);
    }
}
Also used : Bundle(android.os.Bundle) MediaSet(com.android.gallery3d.data.MediaSet) Activity(android.app.Activity) Intent(android.content.Intent)

Example 4 with MediaSet

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

the class SlideshowPage method initializeData.

private void initializeData(Bundle data) {
    boolean random = data.getBoolean(KEY_RANDOM_ORDER, false);
    // We only want to show slideshow for images only, not videos.
    String mediaPath = data.getString(KEY_SET_PATH);
    mediaPath = FilterUtils.newFilterPath(mediaPath, FilterUtils.FILTER_IMAGE_ONLY);
    MediaSet mediaSet = mActivity.getDataManager().getMediaSet(mediaPath);
    if (random) {
        boolean repeat = data.getBoolean(KEY_REPEAT);
        mModel = new SlideshowDataAdapter(mActivity, new ShuffleSource(mediaSet, repeat), 0, null);
        setStateResult(Activity.RESULT_OK, mResultIntent.putExtra(KEY_PHOTO_INDEX, 0));
    } else {
        int index = data.getInt(KEY_PHOTO_INDEX);
        String itemPath = data.getString(KEY_ITEM_PATH);
        Path path = itemPath != null ? Path.fromString(itemPath) : null;
        boolean repeat = data.getBoolean(KEY_REPEAT);
        mModel = new SlideshowDataAdapter(mActivity, new SequentialSource(mediaSet, repeat), index, path);
        setStateResult(Activity.RESULT_OK, mResultIntent.putExtra(KEY_PHOTO_INDEX, index));
    }
}
Also used : Path(com.android.gallery3d.data.Path) MediaSet(com.android.gallery3d.data.MediaSet)

Example 5 with MediaSet

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

the class ManageCachePage method onSingleTapUp.

public void onSingleTapUp(int slotIndex) {
    MediaSet targetSet = mAlbumSetDataAdapter.getMediaSet(slotIndex);
    // Content is dirty, we shall reload soon
    if (targetSet == null)
        return;
    // operation (like a local album).
    if ((targetSet.getSupportedOperations() & MediaSet.SUPPORT_CACHE) == 0) {
        showToastForLocalAlbum();
        return;
    }
    Path path = targetSet.getPath();
    boolean isFullyCached = (targetSet.getCacheFlag() == MediaObject.CACHE_FLAG_FULL);
    boolean isSelected = mSelectionManager.isItemSelected(path);
    if (!isFullyCached) {
        // in this session.
        if (isSelected) {
            --mAlbumCountToMakeAvailableOffline;
        } else {
            ++mAlbumCountToMakeAvailableOffline;
        }
    }
    long sizeOfTarget = targetSet.getCacheSize();
    mCacheStorageInfo.increaseTargetCacheSize((isFullyCached ^ isSelected) ? -sizeOfTarget : sizeOfTarget);
    refreshCacheStorageInfo();
    mSelectionManager.toggle(path);
    mSlotView.invalidate();
}
Also used : Path(com.android.gallery3d.data.Path) MediaSet(com.android.gallery3d.data.MediaSet)

Aggregations

MediaSet (com.android.gallery3d.data.MediaSet)20 MediaItem (com.android.gallery3d.data.MediaItem)9 Path (com.android.gallery3d.data.Path)9 Uri (android.net.Uri)3 DataManager (com.android.gallery3d.data.DataManager)3 ArrayList (java.util.ArrayList)3 Activity (android.app.Activity)2 Intent (android.content.Intent)2 Bundle (android.os.Bundle)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 MediaObject (com.android.gallery3d.data.MediaObject)2 MatrixCursor (android.database.MatrixCursor)1 Message (android.os.Message)1 BottomNavigationView (android.support.design.widget.BottomNavigationView)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1