diff options
author | Chao Zhang <chaoz@codeaurora.org> | 2016-02-04 10:59:01 +0800 |
---|---|---|
committer | Chao Zhang <chaoz@codeaurora.org> | 2016-02-04 11:04:41 +0800 |
commit | dcc252357983e570c4d75cca9c5a60aef5d8b904 (patch) | |
tree | 8ee7f3a06019b47e7bbd9e6cae4de2d6130377b2 /src/com/android/gallery3d/ui | |
parent | 083ecf6d23dcc29acf950a6a6b15d454aae0e47a (diff) | |
download | android_packages_apps_Gallery2-dcc252357983e570c4d75cca9c5a60aef5d8b904.tar.gz android_packages_apps_Gallery2-dcc252357983e570c4d75cca9c5a60aef5d8b904.tar.bz2 android_packages_apps_Gallery2-dcc252357983e570c4d75cca9c5a60aef5d8b904.zip |
Gallery2: fix crash when tap screen after all photos were deleted.
after delete all photos, mMediaSlotMap not be cleaned,
so getRectSlotByPosition() return a wrong index.
clean mMediaSlotMap in createSlots(),
make sure getRectSlotByPosition() return a correct value.
Change-Id: I9744fc0dc11aeb6ccec2abb825409b93c12675f6
CRs-Fixed: 971388
Diffstat (limited to 'src/com/android/gallery3d/ui')
-rw-r--r-- | src/com/android/gallery3d/ui/TimeLineSlotView.java | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/com/android/gallery3d/ui/TimeLineSlotView.java b/src/com/android/gallery3d/ui/TimeLineSlotView.java index 64ee5a2d1..108cb3486 100644 --- a/src/com/android/gallery3d/ui/TimeLineSlotView.java +++ b/src/com/android/gallery3d/ui/TimeLineSlotView.java @@ -725,48 +725,48 @@ public class TimeLineSlotView extends GLView { ArrayList<MediaItem> mediaItemlist = new ArrayList<MediaItem>(); if (mRenderer != null) { mediaItemlist = mRenderer.getAllMediaItems(); - } + } + if (mHeightList == null) { + mHeightList = new ArrayList<Integer>(); + } + if (mMediaSlotMap == null) { + mMediaSlotMap = new HashMap<Integer, RectSlot>(); + } + mHeightList.clear(); + mMediaSlotMap.clear(); if (mediaItemlist != null && mediaItemlist.size() > 0) { - if (mHeightList == null) { - mHeightList = new ArrayList<Integer>(); - } - if (mMediaSlotMap == null) { - mMediaSlotMap = new HashMap<Integer, RectSlot>(); - } - mHeightList.clear(); - mMediaSlotMap.clear(); boolean isPrevTitle = false; int j = 0; int col = 0; - int totalHieght = 0; + int totalHeight = 0; for (int i = 0; i < mediaItemlist.size(); ++i) { MediaItem info = mediaItemlist.get(i); if (info.getMediaType() == MediaObject.MEDIA_TYPE_TIMELINE_TITLE) { - totalHieght += (mSpec.titleHeight+mSlotGap); + totalHeight += (mSpec.titleHeight + mSlotGap); isPrevTitle = true; - col =0; + col = 0; } else { if (isPrevTitle) { - j =0; + j = 0; isPrevTitle = false; } else { ++j; } - if(j%mUnitCount == 0) { - totalHieght += (mSlotHeight+mSlotGap); - col =0; + if (j % mUnitCount == 0) { + totalHeight += (mSlotHeight + mSlotGap); + col = 0; } else { - col = j%mUnitCount; + col = j % mUnitCount; } } - mHeightList.add(totalHieght); + mHeightList.add(totalHeight); if (View.LAYOUT_DIRECTION_RTL == TextUtils .getLayoutDirectionFromLocale(Locale.getDefault())) { - col = mUnitCount - col -1; + col = mUnitCount - col - 1; } - RectSlot rectslot = new RectSlot(info.getMediaType(), i, col, totalHieght); + RectSlot rectslot = new RectSlot(info.getMediaType(), i, col, totalHeight); mMediaSlotMap.put(rectslot.slotIndex, rectslot); } mContentLength = mHeightList.get(mHeightList.size() -1); |