From 157df6f8e45a243878c6be39c22ef88fd82cc59d Mon Sep 17 00:00:00 2001 From: Likai Ding Date: Sat, 30 Jan 2016 15:57:24 +0800 Subject: Gallery2: fix a NullPointerException If gallery is launched for picking wallpaper, after entering AlbumPage and then press back key, the app crashes. In this case, toolbar is not set up. Add a condition check before calling method on it. Change-Id: I0522a3518ff43c8963214ae783ac9b4e73245b41 CRs-Fixed: 968930 --- src/com/android/gallery3d/app/AlbumPage.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index 2f628a978..5fc16aa50 100644 --- a/src/com/android/gallery3d/app/AlbumPage.java +++ b/src/com/android/gallery3d/app/AlbumPage.java @@ -288,10 +288,13 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster if (mInCameraApp) { GalleryUtils.startGalleryActivity(mActivity); } else if (mActivity.getStateManager().getStateCount() > 1) { - mActivity.getToolbar().setNavigationContentDescription(mActivity.getResources(). - getString(R.string.drawer_desc)); - mActivity.getToolbar().setNavigationIcon(R.drawable.drawer); - ((GalleryActivity)mActivity).toggleNavDrawer(true); + Toolbar toolbar = mActivity.getToolbar(); + if (toolbar != null) { + toolbar.setNavigationContentDescription( + mActivity.getResources().getString(R.string.drawer_desc)); + toolbar.setNavigationIcon(R.drawable.drawer); + ((GalleryActivity) mActivity).toggleNavDrawer(true); + } super.onBackPressed(); } else if (mParentMediaSetString != null) { Bundle data = new Bundle(getData()); -- cgit v1.2.3