use of com.android.gallery3d.data.MediaSet in project android_packages_apps_Gallery2 by LineageOS.
the class TimeLinePage method onSingleTapUp.
private void onSingleTapUp(int slotIndex, boolean isTitle) {
if (!mIsActive)
return;
if (mSelectionManager.inSelectionMode()) {
if (isTitle) {
MediaSet targetSet = mAlbumDataAdapter.getMediaSet(slotIndex);
if (targetSet == null)
return;
ArrayList<Path> paths = ((ClusterAlbum) targetSet).getMediaItems();
if (paths == null || paths.size() <= 0)
return;
mSelectionManager.toggleTimeLineSet(paths);
mSlotView.invalidate();
} else {
MediaItem item = mAlbumDataAdapter.get(slotIndex);
// Item not ready yet, ignore the click
if (item == null)
return;
if (mSelectionManager.getSelectedCount() > 0) {
if (!ActionModeHandler.isThreadComplete)
return;
}
mSelectionManager.toggle(item.getPath());
mSlotView.invalidate();
}
} else if (!isTitle) {
// Render transition in pressed state
mAlbumView.setPressedIndex(slotIndex);
mAlbumView.setPressedUp();
mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_PICK_PHOTO, slotIndex, 0), FadeTexture.DURATION);
}
}
use of com.android.gallery3d.data.MediaSet in project android_packages_apps_Gallery2 by LineageOS.
the class AlbumSetPage method onSingleTapUp.
public void onSingleTapUp(int slotIndex) {
if (!mIsActive)
return;
if (mSelectionManager.inSelectionMode()) {
MediaSet targetSet = mAlbumSetDataAdapter.getMediaSet(slotIndex);
// Content is dirty, we shall reload soon
if (targetSet == null)
return;
mSelectionManager.toggle(targetSet.getPath());
mSlotView.invalidate();
} else {
// Show pressed-up animation for the single-tap.
mAlbumSetView.setPressedIndex(slotIndex);
mAlbumSetView.setPressedUp();
mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_PICK_ALBUM, slotIndex, 0), FadeTexture.DURATION);
}
}
use of com.android.gallery3d.data.MediaSet in project android_packages_apps_Gallery2 by LineageOS.
the class SelectionManager method getSelected.
public ArrayList<Path> getSelected(boolean expandSet, int maxSelection) {
ArrayList<Path> selected = new ArrayList<Path>();
if (mIsAlbumSet) {
if (mInverseSelection) {
int total = getTotalCount();
for (int i = 0; i < total; i++) {
MediaSet set = mSourceMediaSet.getSubMediaSet(i);
Path id = set.getPath();
if (!mClickedSet.contains(id)) {
if (expandSet) {
if (!expandMediaSet(selected, set, maxSelection)) {
return null;
}
} else {
addPathIfSelectable(selected, id);
if (selected.size() > maxSelection) {
return null;
}
}
}
}
} else {
for (Path id : mClickedSet) {
if (expandSet) {
if (!expandMediaSet(selected, mDataManager.getMediaSet(id), maxSelection)) {
return null;
}
} else {
addPathIfSelectable(selected, id);
if (selected.size() > maxSelection) {
return null;
}
}
}
}
} else {
if (mInverseSelection) {
int total = getTotalCount();
int index = 0;
while (index < total) {
int count = Math.min(total - index, MediaSet.MEDIAITEM_BATCH_FETCH_COUNT);
ArrayList<MediaItem> list = mSourceMediaSet.getMediaItem(index, count);
for (MediaItem item : list) {
Path id = item.getPath();
if (!mClickedSet.contains(id)) {
addPathIfSelectable(selected, id);
if (selected.size() > maxSelection) {
return null;
}
}
}
index += count;
}
} else {
for (Path id : mClickedSet) {
addPathIfSelectable(selected, id);
if (selected.size() > maxSelection) {
return null;
}
}
}
}
return selected;
}
use of com.android.gallery3d.data.MediaSet in project android_packages_apps_Gallery2 by LineageOS.
the class AlbumSetSlidingWindow method updateAlbumSetEntry.
private void updateAlbumSetEntry(AlbumSetEntry entry, int slotIndex) {
MediaSet album = mSource.getMediaSet(slotIndex);
MediaItem cover = mSource.getCoverItem(slotIndex);
int totalCount = mSource.getTotalCount(slotIndex);
entry.album = album;
entry.setDataVersion = getDataVersion(album);
entry.cacheFlag = identifyCacheFlag(album);
entry.cacheStatus = identifyCacheStatus(album);
entry.setPath = (album == null) ? null : album.getPath();
String title = (album == null) ? "" : Utils.ensureNotNull(album.getName());
int sourceType = DataSourceType.identifySourceType(album);
if (isLabelChanged(entry, title, totalCount, sourceType)) {
entry.title = title;
entry.totalCount = totalCount;
entry.sourceType = sourceType;
if (entry.labelLoader != null) {
entry.labelLoader.recycle();
entry.labelLoader = null;
entry.labelTexture = null;
}
if (album != null) {
entry.labelLoader = new AlbumLabelLoader(slotIndex, title, totalCount, sourceType);
}
}
entry.coverItem = cover;
if (getDataVersion(cover) != entry.coverDataVersion) {
entry.coverDataVersion = getDataVersion(cover);
entry.rotation = (cover == null) ? 0 : cover.getRotation();
if (entry.coverLoader != null) {
entry.coverLoader.recycle();
entry.coverLoader = null;
entry.bitmapTexture = null;
entry.content = null;
}
if (cover != null) {
entry.coverLoader = new AlbumCoverLoader(slotIndex, cover);
}
}
}
use of com.android.gallery3d.data.MediaSet in project android_packages_apps_Gallery2 by LineageOS.
the class GalleryWidgetMigrator method migrateGalleryWidgetsInternal.
private static void migrateGalleryWidgetsInternal(Context context) {
GalleryApp galleryApp = (GalleryApp) context.getApplicationContext();
DataManager manager = galleryApp.getDataManager();
WidgetDatabaseHelper dbHelper = new WidgetDatabaseHelper(context);
// only need to migrate local-album entries of type TYPE_ALBUM
List<Entry> entries = dbHelper.getEntries(WidgetDatabaseHelper.TYPE_ALBUM);
if (entries == null)
return;
// Check each entry's relativePath. If exists, update bucket id using relative
// path combined with external storage path. Otherwise, iterate through old external
// storage paths to find the relative path that matches the old bucket id, and then update
// bucket id and relative path
HashMap<Integer, Entry> localEntries = new HashMap<Integer, Entry>(entries.size());
for (Entry entry : entries) {
Path path = Path.fromString(entry.albumPath);
MediaSet mediaSet = (MediaSet) manager.getMediaObject(path);
if (mediaSet instanceof LocalAlbum) {
if (entry.relativePath != null && entry.relativePath.length() > 0) {
// update entry using relative path + external storage path
updateEntryUsingRelativePath(entry, dbHelper);
} else {
int bucketId = Integer.parseInt(path.getSuffix());
localEntries.put(bucketId, entry);
}
}
}
if (!localEntries.isEmpty())
migrateLocalEntries(context, localEntries, dbHelper);
}
Aggregations