use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.
the class AlbumPage method onSingleTapUp.
private void onSingleTapUp(int slotIndex) {
if (!mIsActive)
return;
if (mSelectionManager.inSelectionMode()) {
MediaItem item = mAlbumDataAdapter.get(slotIndex);
// Item not ready yet, ignore the click
if (item == null)
return;
mSelectionManager.toggle(item.getPath());
mSlotView.invalidate();
} else {
// 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.MediaItem in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoPage method launchPhotoEditor.
private void launchPhotoEditor() {
MediaItem current = mModel.getMediaItem(0);
if (current == null || (current.getSupportedOperations() & MediaObject.SUPPORT_EDIT) == 0) {
return;
}
Intent intent = new Intent(ACTION_NEXTGEN_EDIT);
intent.setDataAndType(current.getContentUri(), current.getMimeType()).setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
if (mActivity.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() == 0) {
intent.setAction(Intent.ACTION_EDIT);
}
intent.putExtra(FilterShowActivity.LAUNCH_FULLSCREEN, mActivity.isFullscreen());
List<ResolveInfo> resolveInfoList = mActivity.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (resolveInfoList != null && resolveInfoList.size() > 0) {
if (resolveInfoList.size() == 1) {
// only one app can resolve intent, don't use createChooser.
mActivity.startActivityForResult(intent, REQUEST_EDIT);
} else {
mActivity.startActivityForResult(Intent.createChooser(intent, null), REQUEST_EDIT);
}
overrideTransitionToEditor();
}
}
use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoPage method launchTinyPlanet.
private void launchTinyPlanet() {
// Deep link into tiny planet
MediaItem current = mModel.getMediaItem(0);
Intent intent = new Intent(FilterShowActivity.TINY_PLANET_ACTION);
intent.setClass(mActivity, FilterShowActivity.class);
intent.setDataAndType(current.getContentUri(), current.getMimeType()).setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(FilterShowActivity.LAUNCH_FULLSCREEN, mActivity.isFullscreen());
mActivity.startActivityForResult(intent, REQUEST_EDIT);
overrideTransitionToEditor();
}
use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoPage method onSingleTapUp.
// //////////////////////////////////////////////////////////////////////////
// Callbacks from PhotoView
// //////////////////////////////////////////////////////////////////////////
@Override
public void onSingleTapUp(int x, int y) {
if (mAppBridge != null) {
if (mAppBridge.onSingleTapUp(x, y))
return;
}
MediaItem item = mModel.getMediaItem(0);
if (item == null || item == mScreenNailItem) {
// item is not ready or it is camera preview, ignore
return;
}
if (item.getMimeType().equals(MediaItem.MIME_TYPE_GIF)) {
viewAnimateGif((Activity) mActivity, item.getContentUri());
return;
}
int supported = item.getSupportedOperations();
boolean playVideo = ((supported & MediaItem.SUPPORT_PLAY) != 0);
boolean unlock = ((supported & MediaItem.SUPPORT_UNLOCK) != 0);
boolean goBack = ((supported & MediaItem.SUPPORT_BACK) != 0);
boolean launchCamera = ((supported & MediaItem.SUPPORT_CAMERA_SHORTCUT) != 0);
if (playVideo) {
// determine if the point is at center (1/6) of the photo view.
// (The position of the "play" icon is at center (1/6) of the photo)
int w = mPhotoView.getWidth();
int h = mPhotoView.getHeight();
playVideo = (Math.abs(x - w / 2) * 12 <= w) && (Math.abs(y - h / 2) * 12 <= h);
}
if (playVideo) {
if (mSecureAlbum == null) {
playVideo(mActivity, item.getPlayUri(), item.getName());
} else {
mActivity.getStateManager().finishState(this);
}
} else if (goBack) {
onBackPressed();
} else if (unlock) {
Intent intent = new Intent(mActivity, GalleryActivity.class);
intent.putExtra(GalleryActivity.KEY_DISMISS_KEYGUARD, true);
mActivity.startActivity(intent);
} else if (launchCamera) {
launchCamera();
} else {
toggleBars();
}
}
use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoDataAdapter method setCurrentPhoto.
@Override
public void setCurrentPhoto(Path path, int indexHint) {
if (mItemPath == path)
return;
mItemPath = path;
mCurrentIndex = indexHint;
updateSlidingWindow();
updateImageCache();
fireDataChange();
// We need to reload content if the path doesn't match.
MediaItem item = getMediaItem(0);
if (item != null && item.getPath() != path) {
if (mReloadTask != null)
mReloadTask.notifyDirty();
}
}
Aggregations