From 93a918280a5a186620eb7cbffe9dafdf58116632 Mon Sep 17 00:00:00 2001 From: Kedi Xu Date: Wed, 14 Sep 2016 11:30:29 +0800 Subject: SnapdragonGallery: Fix OOM when enter from camera delete last picture When enter from camera and delete the last picture, gallery will OOM. Change-Id: If468a8e6644a46ad2f06010ef3064ddf0ddf2e79 CRs-Fixed: 1063842 Signed-off-by: Kedi Xu --- src/com/android/gallery3d/app/PhotoDataAdapter.java | 12 ++---------- src/com/android/gallery3d/app/PhotoPage.java | 3 +-- src/com/android/gallery3d/data/ClusterAlbumSet.java | 2 -- 3 files changed, 3 insertions(+), 14 deletions(-) mode change 100644 => 100755 src/com/android/gallery3d/data/ClusterAlbumSet.java diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java index 36bde4dbd..baece7023 100755 --- a/src/com/android/gallery3d/app/PhotoDataAdapter.java +++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java @@ -162,7 +162,6 @@ public class PhotoDataAdapter implements PhotoPage.Model { private int mCameraIndex; private boolean mIsPanorama; private boolean mIsStaticCamera; - private boolean mIsFromTimelineScreen; private boolean mIsActive; private boolean mNeedFullImage; private int mFocusHintDirection = FOCUS_HINT_NEXT; @@ -188,7 +187,7 @@ public class PhotoDataAdapter implements PhotoPage.Model { // preview. If cameraIndex < 0, there is no camera preview. public PhotoDataAdapter(AbstractGalleryActivity activity, PhotoView view, MediaSet mediaSet, Path itemPath, int indexHint, int cameraIndex, - boolean isPanorama, boolean isStaticCamera, boolean isFromTimelineScreen) { + boolean isPanorama, boolean isStaticCamera) { mActivity = activity; mSource = Utils.checkNotNull(mediaSet); mPhotoView = Utils.checkNotNull(view); @@ -197,7 +196,6 @@ public class PhotoDataAdapter implements PhotoPage.Model { mCameraIndex = cameraIndex; mIsPanorama = isPanorama; mIsStaticCamera = isStaticCamera; - mIsFromTimelineScreen = isFromTimelineScreen; mThreadPool = activity.getThreadPool(); mNeedFullImage = true; @@ -1309,9 +1307,6 @@ public class PhotoDataAdapter implements PhotoPage.Model { } mDirty = false; - if (mIsFromTimelineScreen) { - mSource.setClusterKind(GalleryActivity.CLUSTER_ALBUMSET_NO_TITLE); - } version = mSource.reload(); //if data is not ready, continue to reload if (version == MediaObject.INVALID_DATA_VERSION) { @@ -1439,10 +1434,7 @@ public class PhotoDataAdapter implements PhotoPage.Model { // Don't change index if mSize == 0 if (mSize > 0) { - // Due to the set identification and new photo, photos - // in the last two positions disappear in the temp info.items. - // Don't change index in such a situation. - if (index >= mSize + 2) index = mSize - 1; + if (index >= mSize) index = mSize - 1; } info.indexHint = index; diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 3000d056b..e8dd13fac 100755 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -501,8 +501,7 @@ public abstract class PhotoPage extends ActivityState implements mActivity, mPhotoView, mMediaSet, itemPath, mCurrentIndex, mAppBridge == null ? -1 : 0, mAppBridge == null ? false : mAppBridge.isPanorama(), - mAppBridge == null ? false : mAppBridge.isStaticCamera(), - mIsFromTimelineScreen); + mAppBridge == null ? false : mAppBridge.isStaticCamera()); mModel = pda; mPhotoView.setModel(mModel); diff --git a/src/com/android/gallery3d/data/ClusterAlbumSet.java b/src/com/android/gallery3d/data/ClusterAlbumSet.java old mode 100644 new mode 100755 index 7695bd35c..0d7ce3685 --- a/src/com/android/gallery3d/data/ClusterAlbumSet.java +++ b/src/com/android/gallery3d/data/ClusterAlbumSet.java @@ -139,8 +139,6 @@ public class ClusterAlbumSet extends MediaSet implements ContentListener { album = (ClusterAlbum) dataManager.peekMediaObject(childPath); if (album == null) { album = new ClusterAlbum(childPath, dataManager, this, mKind); - } else { - album.setClusterKind(mKind); } } album.setMediaItems(clustering.getCluster(i)); -- cgit v1.2.3