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;
}
}
}
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();
}
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);
}
}
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);
}
}
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;
}
Aggregations