diff options
author | kaiyiz <kaiyiz@codeaurora.org> | 2014-02-26 15:00:27 +0800 |
---|---|---|
committer | emancebo <emancebo@cyngn.com> | 2014-09-04 10:40:18 -0700 |
commit | e09343aaf29847aec279ec16d1bed85eb46a5c7e (patch) | |
tree | 4197cdf937e5ee27e91d714805c7be685c5c1a60 /src | |
parent | 9b59b8e3937b7fd91a9f0367cf69d93c57de2d65 (diff) | |
download | android_packages_apps_Gallery2-e09343aaf29847aec279ec16d1bed85eb46a5c7e.tar.gz android_packages_apps_Gallery2-e09343aaf29847aec279ec16d1bed85eb46a5c7e.tar.bz2 android_packages_apps_Gallery2-e09343aaf29847aec279ec16d1bed85eb46a5c7e.zip |
Gallery2: Fix crash sometimes when delete video in Gallery.
It's the IndexOutOfBoundsException which causes the app crash.
According to log, it's the size of list is 0, but still want to
get the first item in list.
Add extra judgement before get item from ArrayList, if the size
is 0, skip it as the item is null.
CRs-Fixed: 622574
Change-Id: Ide839b2a73954b9da052a6fece46c864dfa42a21
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/android/gallery3d/app/AlbumPage.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index e855814d7..dab447337 100755 --- a/src/com/android/gallery3d/app/AlbumPage.java +++ b/src/com/android/gallery3d/app/AlbumPage.java @@ -575,9 +575,14 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster if (mMediaSet == null) return false; int count = mMediaSet.getMediaItemCount(); + ArrayList<MediaItem> mediaItems; MediaItem item; for (int i = 0; i < count; i++) { - item = mMediaSet.getMediaItem(i, 1).get(0); + mediaItems = mMediaSet.getMediaItem(i, 1); + if (mediaItems.size() <= 0) { + continue; + } + item = mediaItems.get(0); if (item == null) { continue; } |