From 13e61e48a4eb7e09bdcb84fac0b15c33b5970599 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Thu, 5 Apr 2012 12:02:01 +0800 Subject: [PATCH] Fix NPE in Gallery. bug: 6249248 Change-Id: I41851c6524163195f6296a15893d962e706b3449 --- src/com/android/gallery3d/app/AlbumPage.java | 21 ++++++++++++++------- src/com/android/gallery3d/app/AlbumSetPage.java | 21 ++++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index e0b738444..3d8c86d4b 100644 --- a/src/com/android/gallery3d/app/AlbumPage.java +++ b/src/com/android/gallery3d/app/AlbumPage.java @@ -45,6 +45,7 @@ import com.android.gallery3d.ui.AlbumView; import com.android.gallery3d.ui.DetailsHelper; import com.android.gallery3d.ui.DetailsHelper.CloseListener; import com.android.gallery3d.ui.GLCanvas; +import com.android.gallery3d.ui.GLRoot; import com.android.gallery3d.ui.GLView; import com.android.gallery3d.ui.GridDrawer; import com.android.gallery3d.ui.HighlightDrawer; @@ -561,13 +562,19 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster ((Activity) mActivity).runOnUiThread(new Runnable() { @Override public void run() { - if (resultCode == MediaSet.SYNC_RESULT_SUCCESS) { - mInitialSynced = true; - } - clearLoadingBit(BIT_LOADING_SYNC); - if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive) { - Toast.makeText((Context) mActivity, R.string.sync_album_error, - Toast.LENGTH_LONG).show(); + GLRoot root = mActivity.getGLRoot(); + root.lockRenderThread(); + try { + if (resultCode == MediaSet.SYNC_RESULT_SUCCESS) { + mInitialSynced = true; + } + clearLoadingBit(BIT_LOADING_SYNC); + if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive) { + Toast.makeText((Context) mActivity, R.string.sync_album_error, + Toast.LENGTH_LONG).show(); + } + } finally { + root.unlockRenderThread(); } } }); diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java index 7b8750131..6b4bb00f9 100644 --- a/src/com/android/gallery3d/app/AlbumSetPage.java +++ b/src/com/android/gallery3d/app/AlbumSetPage.java @@ -44,6 +44,7 @@ import com.android.gallery3d.ui.AlbumSetView; import com.android.gallery3d.ui.DetailsHelper; import com.android.gallery3d.ui.DetailsHelper.CloseListener; import com.android.gallery3d.ui.GLCanvas; +import com.android.gallery3d.ui.GLRoot; import com.android.gallery3d.ui.GLView; import com.android.gallery3d.ui.GridDrawer; import com.android.gallery3d.ui.HighlightDrawer; @@ -574,13 +575,19 @@ public class AlbumSetPage extends ActivityState implements ((Activity) mActivity).runOnUiThread(new Runnable() { @Override public void run() { - if (resultCode == MediaSet.SYNC_RESULT_SUCCESS) { - mInitialSynced = true; - } - clearLoadingBit(BIT_LOADING_SYNC); - if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive) { - Toast.makeText((Context) mActivity, R.string.sync_album_set_error, - Toast.LENGTH_LONG).show(); + GLRoot root = mActivity.getGLRoot(); + root.lockRenderThread(); + try { + if (resultCode == MediaSet.SYNC_RESULT_SUCCESS) { + mInitialSynced = true; + } + clearLoadingBit(BIT_LOADING_SYNC); + if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive) { + Toast.makeText((Context) mActivity, R.string.sync_album_set_error, + Toast.LENGTH_LONG).show(); + } + } finally { + root.unlockRenderThread(); } } }); -- 2.11.0