use of com.android.gallery3d.data.Path 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);
}
}
}
use of com.android.gallery3d.data.Path in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoPage method onBottomControlClicked.
@Override
public void onBottomControlClicked(int control) {
switch(control) {
case R.id.photopage_bottom_control_edit:
launchPhotoEditor();
return;
case R.id.photopage_bottom_control_share:
if (mModel != null && mModel.getMediaItem(0) != null) {
Uri uri = mActivity.getDataManager().getContentUri(mModel.getMediaItem(0).getPath());
mActivity.isTopMenuShow = true;
mShareIntent.setType(MenuExecutor.getMimeType(mModel.getMediaItem(0).getMediaType()));
mShareIntent.putExtra(Intent.EXTRA_STREAM, uri);
String shareTitle = mActivity.getResources().getString(R.string.share_dialogue_title);
mActivity.startActivity(Intent.createChooser(mShareIntent, shareTitle));
}
return;
case R.id.photopage_bottom_control_delete:
String confirmMsg = null;
confirmMsg = mActivity.getResources().getQuantityString(R.plurals.delete_selection, 1);
if (mModel != null && mModel.getMediaItem(0) != null) {
Path path = mModel.getMediaItem(0).getPath();
mSelectionManager.deSelectAll();
mSelectionManager.toggle(path);
MenuItem item = null;
mMenuExecutor.onMenuClicked(item, confirmMsg, mConfirmDialogListener);
}
return;
default:
return;
}
}
use of com.android.gallery3d.data.Path in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoPage method setCurrentPhotoByIntent.
private void setCurrentPhotoByIntent(Intent intent) {
if (intent == null)
return;
Path path = mApplication.getDataManager().findPathByUri(intent.getData(), intent.getType());
if (path != null) {
Path albumPath = mApplication.getDataManager().getDefaultSetOf(path);
if (albumPath == null) {
return;
}
boolean isClusterType = FilterUtils.isClusterPath(mOriginalSetPathString);
if (!albumPath.equalsIgnoreCase(mOriginalSetPathString) && !isClusterType) {
// If the edited image is stored in a different album, we need
// to start a new activity state to show the new image
Bundle data = new Bundle(getData());
data.putString(KEY_MEDIA_SET_PATH, albumPath.toString());
data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, path.toString());
mActivity.getStateManager().startState(SinglePhotoPage.class, data);
return;
}
if (null != mModel) {
mModel.setCurrentPhoto(path, mCurrentIndex);
parseGDepth();
}
}
}
use of com.android.gallery3d.data.Path in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoDataAdapter method fireDataChange.
private void fireDataChange() {
// First check if data actually changed.
boolean changed = false;
for (int i = -SCREEN_NAIL_MAX; i <= SCREEN_NAIL_MAX; ++i) {
long newVersion = getVersion(mCurrentIndex + i);
if (mChanges[i + SCREEN_NAIL_MAX] != newVersion) {
mChanges[i + SCREEN_NAIL_MAX] = newVersion;
changed = true;
}
}
if (!changed)
return;
// Now calculate the fromIndex array. fromIndex represents the item
// movement. It records the index where the picture come from. The
// special value Integer.MAX_VALUE means it's a new picture.
final int N = IMAGE_CACHE_SIZE;
int[] fromIndex = new int[N];
// Remember the old path array.
Path[] oldPaths = new Path[N];
System.arraycopy(mPaths, 0, oldPaths, 0, N);
// Update the mPaths array.
for (int i = 0; i < N; ++i) {
mPaths[i] = getPath(mCurrentIndex + i - SCREEN_NAIL_MAX);
}
// Calculate the fromIndex array.
for (int i = 0; i < N; i++) {
Path p = mPaths[i];
if (p == null) {
fromIndex[i] = Integer.MAX_VALUE;
continue;
}
// Try to find the same path in the old array
int j;
for (j = 0; j < N; j++) {
if (oldPaths[j] == p) {
break;
}
}
fromIndex[i] = (j < N) ? j - SCREEN_NAIL_MAX : Integer.MAX_VALUE;
}
mPhotoView.notifyDataChange(fromIndex, -mCurrentIndex, mSize - 1 - mCurrentIndex);
}
use of com.android.gallery3d.data.Path 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));
}
}
Aggregations