diff options
author | Owen Lin <owenlin@google.com> | 2012-08-29 01:46:38 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-08-29 01:46:39 -0700 |
commit | 894300ca4d2da44e9c4fb5d8ec7d7a5d8662da51 (patch) | |
tree | 728761cd8f5738ea0962d394d6c13efe1c6fe6f8 /src/com | |
parent | 650a9df4376e7c4f0b64d439b5d38dd81b7fcdcd (diff) | |
parent | 9b7fe0007a8e07f1155dacec7b299042b825da7c (diff) | |
download | android_packages_apps_Snap-894300ca4d2da44e9c4fb5d8ec7d7a5d8662da51.tar.gz android_packages_apps_Snap-894300ca4d2da44e9c4fb5d8ec7d7a5d8662da51.tar.bz2 android_packages_apps_Snap-894300ca4d2da44e9c4fb5d8ec7d7a5d8662da51.zip |
Merge "Fix NPE in viewing single image." into gb-ub-photos-arches
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/gallery3d/app/GalleryActionBar.java | 20 | ||||
-rw-r--r-- | src/com/android/gallery3d/app/PhotoPage.java | 32 |
2 files changed, 25 insertions, 27 deletions
diff --git a/src/com/android/gallery3d/app/GalleryActionBar.java b/src/com/android/gallery3d/app/GalleryActionBar.java index 0f7579e60..0aac60e77 100644 --- a/src/com/android/gallery3d/app/GalleryActionBar.java +++ b/src/com/android/gallery3d/app/GalleryActionBar.java @@ -298,27 +298,27 @@ public class GalleryActionBar implements OnNavigationListener { private Menu mActionBarMenu; private MenuItem mShareMenuItem; + private Intent mShareIntent; public void createActionBarMenu(int menuRes, Menu menu) { mActivity.getSupportMenuInflater().inflate(menuRes, menu); mActionBarMenu = menu; mShareMenuItem = menu.findItem(R.id.action_share); + if (mShareMenuItem != null) { + ((ShareActionProvider) mShareMenuItem.getActionProvider()) + .setShareIntent(mShareIntent); + } } public Menu getMenu() { return mActionBarMenu; } - public boolean hasShareMenuItem() { - return mShareMenuItem != null; - } - public void setShareIntent(Intent shareIntent) { - ((ShareActionProvider) mShareMenuItem.getActionProvider()) - .setShareIntent(shareIntent); - } - - public MenuItem findMenuItem(int itemId) { - return mActionBarMenu.findItem(itemId); + mShareIntent = shareIntent; + if (mShareMenuItem != null) { + ((ShareActionProvider) mShareMenuItem.getActionProvider()) + .setShareIntent(shareIntent); + } } } diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index b50f0b762..71f886129 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -53,13 +53,13 @@ import com.android.gallery3d.data.SnailItem; import com.android.gallery3d.data.SnailSource; import com.android.gallery3d.picasasource.PicasaSource; import com.android.gallery3d.ui.AnimationTime; +import com.android.gallery3d.ui.BitmapScreenNail; import com.android.gallery3d.ui.DetailsHelper; import com.android.gallery3d.ui.DetailsHelper.CloseListener; import com.android.gallery3d.ui.DetailsHelper.DetailsSource; import com.android.gallery3d.ui.GLCanvas; import com.android.gallery3d.ui.GLRoot; import com.android.gallery3d.ui.GLRoot.OnGLIdleListener; -import com.android.gallery3d.ui.BitmapScreenNail; import com.android.gallery3d.ui.GLView; import com.android.gallery3d.ui.ImportCompleteListener; import com.android.gallery3d.ui.MenuExecutor; @@ -108,7 +108,6 @@ public class PhotoPage extends ActivityState implements private PhotoPage.Model mModel; private DetailsHelper mDetailsHelper; private boolean mShowDetails; - private Path mPendingSharePath; // mMediaSet could be null if there is no KEY_MEDIA_SET_PATH supplied. // E.g., viewing a photo in gmail attachment @@ -377,7 +376,7 @@ public class PhotoPage extends ActivityState implements @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) private void setNfcBeamPushUris(Uri[] uris) { if (mNfcAdapter != null && ApiHelper.HAS_SET_BEAM_PUSH_URIS) { - mNfcAdapter.setBeamPushUris(uris, (Activity)mActivity); + mNfcAdapter.setBeamPushUris(uris, mActivity); } } @@ -393,16 +392,10 @@ public class PhotoPage extends ActivityState implements } private void updateShareURI(Path path) { - if (mActionBar.hasShareMenuItem()) { - DataManager manager = mActivity.getDataManager(); - Uri uri = manager.getContentUri(path); - mActionBar.setShareIntent(createShareIntent(path)); - setNfcBeamPushUris(new Uri[]{uri}); - mPendingSharePath = null; - } else { - // This happens when ActionBar is not created yet. - mPendingSharePath = path; - } + DataManager manager = mActivity.getDataManager(); + Uri uri = manager.getContentUri(path); + mActionBar.setShareIntent(createShareIntent(path)); + setNfcBeamPushUris(new Uri[]{uri}); } private void updateCurrentPhoto(MediaItem photo) { @@ -432,16 +425,22 @@ public class PhotoPage extends ActivityState implements } private void updateMenuOperations() { - MenuItem item = mActionBar.findMenuItem(R.id.action_slideshow); + Menu menu = mActionBar.getMenu(); + + // it could be null if onCreateActionBar has not been called yet + if (menu == null) return; + + MenuItem item = menu.findItem(R.id.action_slideshow); item.setVisible((mSecureAlbum == null) && canDoSlideShow()); if (mCurrentPhoto == null) return; + int supportedOperations = mCurrentPhoto.getSupportedOperations(); if (mSecureAlbum != null) { - supportedOperations = supportedOperations & MediaObject.SUPPORT_DELETE; + supportedOperations &= MediaObject.SUPPORT_DELETE; } else if (!GalleryUtils.isEditorAvailable(mActivity, "image/*")) { supportedOperations &= ~MediaObject.SUPPORT_EDIT; } - MenuExecutor.updateMenuOperation(mActionBar.getMenu(), supportedOperations); + MenuExecutor.updateMenuOperation(menu, supportedOperations); } private boolean canDoSlideShow() { @@ -600,7 +599,6 @@ public class PhotoPage extends ActivityState implements @Override protected boolean onCreateActionBar(Menu menu) { mActionBar.createActionBarMenu(R.menu.photo, menu); - if (mPendingSharePath != null) updateShareURI(mPendingSharePath); updateMenuOperations(); updateTitle(); return true; |