summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBobby Georgescu <georgescu@google.com>2012-09-24 11:26:10 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-24 14:29:54 -0700
commit77551a6b619e63c59d518b42b472556ebf750484 (patch)
tree2fb68a91a98e11554f222db290a32a0a45151331
parent561df21b1651cf6b266f241bb1a3945c05c229bf (diff)
downloadandroid_packages_apps_Snap-77551a6b619e63c59d518b42b472556ebf750484.tar.gz
android_packages_apps_Snap-77551a6b619e63c59d518b42b472556ebf750484.tar.bz2
android_packages_apps_Snap-77551a6b619e63c59d518b42b472556ebf750484.zip
Fix occasional crash when restoring photo page state
Bug: 7216012 If the saved state being used to restore the photo page includes an out-of-bounds index, ignore it and reset the index to 0. Change-Id: I1b8aa82cbc553297189abb57bd274d7eb53f61e0
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index c5c77e11b..b1736203c 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -353,10 +353,13 @@ public class PhotoPage extends ActivityState implements
Log.w(TAG, "failed to restore " + mSetPathString);
}
if (itemPath == null) {
- if (mMediaSet.getMediaItemCount() > 0) {
+ int mediaItemCount = mMediaSet.getMediaItemCount();
+ if (mediaItemCount > 0) {
+ if (mCurrentIndex >= mediaItemCount) mCurrentIndex = 0;
itemPath = mMediaSet.getMediaItem(mCurrentIndex, 1)
.get(0).getPath();
} else {
+ // Bail out, PhotoPage can't load on an empty album
return;
}
}