use of com.android.gallery3d.data.MediaSet in project android_packages_apps_Gallery2 by LineageOS.
the class ActionModeHandler method computeCanShare.
private boolean computeCanShare(ArrayList<MediaObject> selected, int max) {
int numSelected = selected.size();
boolean ret = computeCanShare(numSelected, max);
if (!ret)
return false;
numSelected = 0;
for (MediaObject mediaObject : selected) {
if (mediaObject instanceof MediaSet) {
numSelected = numSelected + ((MediaSet) mediaObject).getTotalMediaItemCount();
} else {
numSelected = numSelected + 1;
}
ret = computeCanShare(numSelected, max);
if (!ret)
return false;
}
return true;
}
use of com.android.gallery3d.data.MediaSet in project android_packages_apps_Gallery2 by LineageOS.
the class WidgetConfigure method setChoosenAlbum.
private void setChoosenAlbum(Intent data) {
String albumPath = data.getStringExtra(AlbumPicker.KEY_ALBUM_PATH);
WidgetDatabaseHelper helper = new WidgetDatabaseHelper(this);
try {
String relativePath = null;
GalleryApp galleryApp = (GalleryApp) getApplicationContext();
DataManager manager = galleryApp.getDataManager();
Path path = Path.fromString(albumPath);
MediaSet mediaSet = (MediaSet) manager.getMediaObject(path);
if (mediaSet instanceof LocalAlbum) {
int bucketId = Integer.parseInt(path.getSuffix());
// If the chosen album is a local album, find relative path
// Otherwise, leave the relative path field empty
relativePath = LocalAlbum.getRelativePath(bucketId);
Log.i(TAG, "Setting widget, album path: " + albumPath + ", relative path: " + relativePath);
}
helper.setWidget(mAppWidgetId, WidgetDatabaseHelper.TYPE_ALBUM, albumPath, relativePath);
updateWidgetAndFinish(helper.getEntry(mAppWidgetId));
} finally {
helper.close();
}
}
use of com.android.gallery3d.data.MediaSet in project android_packages_apps_Gallery2 by LineageOS.
the class MediaSetLoader method uriForItem.
@Override
public Uri uriForItem(Cursor item) {
int index = item.getInt(AlbumSetLoader.INDEX_ID);
MediaSet ms = mMediaSet.getSubMediaSet(index);
return ms == null ? null : ms.getContentUri();
}
use of com.android.gallery3d.data.MediaSet in project android_packages_apps_Gallery2 by LineageOS.
the class MediaSetLoader method urisForSubItems.
@Override
public ArrayList<Uri> urisForSubItems(Cursor item) {
int index = item.getInt(AlbumSetLoader.INDEX_ID);
MediaSet ms = mMediaSet.getSubMediaSet(index);
if (ms == null)
return null;
final ArrayList<Uri> result = new ArrayList<Uri>();
ms.enumerateMediaItems(new MediaSet.ItemConsumer() {
@Override
public void consume(int index, MediaItem item) {
if (item != null) {
result.add(item.getContentUri());
}
}
});
return result;
}
use of com.android.gallery3d.data.MediaSet in project android_packages_apps_Gallery2 by LineageOS.
the class MediaSetLoader method loadInBackground.
@Override
public Cursor loadInBackground() {
// TODO: This probably doesn't work
mMediaSet.reload();
final MatrixCursor cursor = new MatrixCursor(AlbumSetLoader.PROJECTION);
final Object[] row = new Object[AlbumSetLoader.PROJECTION.length];
int count = mMediaSet.getSubMediaSetCount();
ArrayList<MediaItem> coverItems = new ArrayList<MediaItem>(count);
for (int i = 0; i < count; i++) {
MediaSet m = mMediaSet.getSubMediaSet(i);
m.reload();
row[AlbumSetLoader.INDEX_ID] = i;
row[AlbumSetLoader.INDEX_TITLE] = m.getName();
row[AlbumSetLoader.INDEX_COUNT] = m.getMediaItemCount();
row[AlbumSetLoader.INDEX_SUPPORTED_OPERATIONS] = m.getSupportedOperations();
MediaItem coverItem = m.getCoverMediaItem();
if (coverItem != null) {
row[AlbumSetLoader.INDEX_TIMESTAMP] = coverItem.getDateInMs();
}
coverItems.add(coverItem);
cursor.addRow(row);
}
synchronized (mMediaSet) {
mCoverItems = coverItems;
}
return cursor;
}
Aggregations