summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2011-09-14 18:00:42 +0800
committerChih-Chung Chang <chihchung@google.com>2011-09-14 18:00:42 +0800
commit7cf4777f2d6691b5490b7e8df76d154ea5fd8bf7 (patch)
tree94c9863c7c418bb64f655a10307ac25738eff7ba
parent3a54b9ae67eb7b38f19ea0bdeeef26efc0a1afa1 (diff)
downloadandroid_packages_apps_Gallery2-7cf4777f2d6691b5490b7e8df76d154ea5fd8bf7.tar.gz
android_packages_apps_Gallery2-7cf4777f2d6691b5490b7e8df76d154ea5fd8bf7.tar.bz2
android_packages_apps_Gallery2-7cf4777f2d6691b5490b7e8df76d154ea5fd8bf7.zip
Fix 5196286: Crash if the last clustered album is deleted.
Change-Id: I5e451d3cebd61c31465cba56aebe66cc3a999e2d
-rw-r--r--src/com/android/gallery3d/app/AlbumSetDataAdapter.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/app/AlbumSetDataAdapter.java b/src/com/android/gallery3d/app/AlbumSetDataAdapter.java
index 9086ddbf4..85f3bf532 100644
--- a/src/com/android/gallery3d/app/AlbumSetDataAdapter.java
+++ b/src/com/android/gallery3d/app/AlbumSetDataAdapter.java
@@ -355,6 +355,14 @@ public class AlbumSetDataAdapter implements AlbumSetView.Model {
if (info.version != version) {
info.version = version;
info.size = mSource.getSubMediaSetCount();
+
+ // If the size becomes smaller after reload(), we may
+ // receive from GetUpdateInfo an index which is too
+ // big. Because the main thread is not aware of the size
+ // change until we call UpdateContent.
+ if (info.index >= info.size) {
+ info.index = INDEX_NONE;
+ }
}
if (info.index != INDEX_NONE) {
info.item = mSource.getSubMediaSet(info.index);