Search in sources :

Example 6 with Path

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

the class FilterUtils method getAppliedFilters.

private static void getAppliedFilters(Path path, int[] result, boolean underCluster) {
    String[] segments = path.split();
    // Recurse into sub media sets.
    for (int i = 0; i < segments.length; i++) {
        if (segments[i].startsWith("{")) {
            String[] sets = Path.splitSequence(segments[i]);
            for (int j = 0; j < sets.length; j++) {
                Path sub = Path.fromString(sets[j]);
                getAppliedFilters(sub, result, underCluster);
            }
        }
    }
    // update current selection
    if (segments[0].equals("cluster")) {
        // if this is a clustered album, set underCluster to true.
        if (segments.length == 4) {
            underCluster = true;
        }
        int ctype = toClusterType(segments[2]);
        result[CLUSTER_TYPE] |= ctype;
        result[CLUSTER_CURRENT_TYPE] = ctype;
        if (underCluster) {
            result[CLUSTER_TYPE_F] |= ctype;
        }
    }
}
Also used : Path(com.android.gallery3d.data.Path)

Example 7 with Path

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

Example 8 with Path

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

the class GalleryProvider method openFile.

@Override
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
    long token = Binder.clearCallingIdentity();
    try {
        if (mode.contains("w")) {
            throw new FileNotFoundException("cannot open file for write");
        }
        Path path = Path.fromString(uri.getPath());
        MediaObject object = mDataManager.getMediaObject(path);
        if (object == null) {
            throw new FileNotFoundException(uri.toString());
        }
        if (PicasaSource.isPicasaImage(object)) {
            return PicasaSource.openFile(getContext(), object, mode);
        } else {
            throw new FileNotFoundException("unspported type: " + object);
        }
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
Also used : Path(com.android.gallery3d.data.Path) FileNotFoundException(java.io.FileNotFoundException) MediaObject(com.android.gallery3d.data.MediaObject)

Example 9 with Path

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

the class GalleryProvider method getType.

// TODO: consider concurrent access
@Override
public String getType(Uri uri) {
    long token = Binder.clearCallingIdentity();
    try {
        Path path = Path.fromString(uri.getPath());
        MediaItem item = (MediaItem) mDataManager.getMediaObject(path);
        return item != null ? item.getMimeType() : null;
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
Also used : Path(com.android.gallery3d.data.Path) MediaItem(com.android.gallery3d.data.MediaItem)

Example 10 with Path

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

the class ActionModeHandler method computeSharingIntent.

private Intent computeSharingIntent(JobContext jc, int maxItems) {
    ArrayList<Path> expandedPaths = mSelectionManager.getSelected(true, maxItems);
    if (expandedPaths == null || expandedPaths.size() == 0) {
        setNfcBeamPushUris(null);
        return new Intent();
    }
    final ArrayList<Uri> uris = new ArrayList<Uri>();
    DataManager manager = mActivity.getDataManager();
    int type = 0;
    final Intent intent = new Intent();
    for (Path path : expandedPaths) {
        if (jc.isCancelled())
            return null;
        int support = manager.getSupportedOperations(path);
        type |= manager.getMediaType(path);
        if ((support & MediaObject.SUPPORT_SHARE) != 0) {
            Uri uri = manager.getContentUri(path);
            if (uri != null) {
                uris.add(uri);
            }
        }
    }
    final int size = uris.size();
    if (size > 0) {
        final String mimeType = MenuExecutor.getMimeType(type);
        if (size > 1) {
            intent.setAction(Intent.ACTION_SEND_MULTIPLE).setType(mimeType);
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        } else {
            intent.setAction(Intent.ACTION_SEND).setType(mimeType);
            intent.putExtra(Intent.EXTRA_STREAM, uris.get(0));
        }
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        setNfcBeamPushUris(uris.toArray(new Uri[uris.size()]));
    } else {
        setNfcBeamPushUris(null);
    }
    return intent;
}
Also used : Path(com.android.gallery3d.data.Path) ArrayList(java.util.ArrayList) Intent(android.content.Intent) DataManager(com.android.gallery3d.data.DataManager) Uri(android.net.Uri)

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