summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael W <baddaemon87@gmail.com>2017-07-12 14:16:42 +0200
committerBruno Martins <bgcngm@gmail.com>2018-11-20 10:16:51 +0000
commit0730a5a9ca2d52c1899ed750c97acfeddc453289 (patch)
treefb2b670d6549f25a55f9eedfd7371b6b8c699d05
parent04afbd04004412087a8f6aec12fc8c0e14b4566c (diff)
downloadandroid_packages_apps_Gallery2-0730a5a9ca2d52c1899ed750c97acfeddc453289.tar.gz
android_packages_apps_Gallery2-0730a5a9ca2d52c1899ed750c97acfeddc453289.tar.bz2
android_packages_apps_Gallery2-0730a5a9ca2d52c1899ed750c97acfeddc453289.zip
Gallery2: Fix potential crash
Author: Michael W <baddaemon87@gmail.com> Date: Wed Jul 12 14:16:42 2017 +0200 Gallery2: Fix potential crash * A race between deleting and displaying videos seems to report a higher count of videos available than actually accessible. BUGBASH-489 Change-Id: Iac24002feb8701cc4182c3834f663be017b625d5 Author: KhabarlakKonstantin <habarlack@gmail.com> Date: Tue Oct 3 11:22:40 2017 +0300 Fix crash after deleting a video on Albums tab getMediaItem can return empty list if no more media items available, break folder processing then Number of items returned by getMediaItem can be inconsistent with getMediaItemCount Change-Id: I7f2abce5d3832a1b2c1fe068b629a3474ed742e2 Change-Id: Ibcaeff698da118f484a6f38528b4a2111a009fdd
-rw-r--r--src/com/android/gallery3d/app/AlbumPage.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index 7f947d8f3..c3ef4c326 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -652,9 +652,17 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
if (mMediaSet == null)
return false;
int count = mMediaSet.getMediaItemCount();
+ ArrayList<MediaItem> list;
MediaItem item;
for (int i = 0; i < count; i++) {
- item = mMediaSet.getMediaItem(i, 1).get(0);
+ list = mMediaSet.getMediaItem(i, 1);
+ if (list == null) {
+ continue;
+ }
+ if (list.isEmpty()) {
+ break;
+ }
+ item = list.get(0);
if (item == null) {
continue;
}