summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhuw <zhuw@codeaurora.org>2016-08-02 15:47:08 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2016-08-02 19:42:50 -0700
commit7ed375d6829e18a0d342d31c3217d6263b9a5c33 (patch)
treee4ce0441a1e63f7074c21c4dca83f0b544864197
parent4edad0fbfadf5bf47726a33aa1a9a62dedd49a3a (diff)
downloadandroid_packages_apps_Gallery2-7ed375d6829e18a0d342d31c3217d6263b9a5c33.tar.gz
android_packages_apps_Gallery2-7ed375d6829e18a0d342d31c3217d6263b9a5c33.tar.bz2
android_packages_apps_Gallery2-7ed375d6829e18a0d342d31c3217d6263b9a5c33.zip
Gallery:Fix page skipping error after the editing
1. Add isLoading function at ClusterAlbumSet and ClusterAlbum. 2. Add isLoading function at FilterDeleteSet. 3. Modify ReloadTask in PhotoDataAdapter to control the loop by using the isLoading function. Change-Id: If3578294163120a0b52db0696deb7d5a764e0c1c CRs-Fixed: 1042817
-rwxr-xr-xsrc/com/android/gallery3d/app/PhotoDataAdapter.java14
-rw-r--r--src/com/android/gallery3d/data/ClusterAlbum.java5
-rw-r--r--src/com/android/gallery3d/data/ClusterAlbumSet.java10
-rw-r--r--src/com/android/gallery3d/data/FilterDeleteSet.java14
4 files changed, 40 insertions, 3 deletions
diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java
index c6ad14ded..872706fee 100755
--- a/src/com/android/gallery3d/app/PhotoDataAdapter.java
+++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java
@@ -1308,6 +1308,7 @@ public class PhotoDataAdapter implements PhotoPage.Model {
}
}
mDirty = false;
+
version = mSource.reload();
if (mIsFromTimelineScreen) {
mSource.setClusterKind(GalleryActivity.CLUSTER_ALBUMSET_NO_TITLE);
@@ -1316,6 +1317,12 @@ public class PhotoDataAdapter implements PhotoPage.Model {
if (version == MediaObject.INVALID_DATA_VERSION) {
continue;
}
+ if (mSource.isLoading()) {
+ mDirty = true;
+ continue;
+ } else {
+ mSourceVersion = version;
+ }
UpdateInfo info = executeAndWait(new GetUpdateInfo());
updateLoading(true);
@@ -1331,9 +1338,9 @@ public class PhotoDataAdapter implements PhotoPage.Model {
if (info.version != version) {
info.reloadContent = true;
- info.size = mSource.getMediaItemCount();
}
if (!info.reloadContent) continue;
+ info.size = mSource.getMediaItemCount();
// Check it is from camera or not
boolean isCameraFlag = false;
@@ -1436,7 +1443,10 @@ public class PhotoDataAdapter implements PhotoPage.Model {
// Don't change index if mSize == 0
if (mSize > 0) {
- if (index >= mSize) index = mSize - 1;
+ // 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;
}
info.indexHint = index;
diff --git a/src/com/android/gallery3d/data/ClusterAlbum.java b/src/com/android/gallery3d/data/ClusterAlbum.java
index b7d1c3f36..4e2cc18ea 100644
--- a/src/com/android/gallery3d/data/ClusterAlbum.java
+++ b/src/com/android/gallery3d/data/ClusterAlbum.java
@@ -179,6 +179,11 @@ public class ClusterAlbum extends MediaSet implements ContentListener {
}
@Override
+ public boolean isLoading() {
+ return mClusterAlbumSet.isLoading();
+ }
+
+ @Override
public long reload() {
long version = mClusterAlbumSet.reload();
if (version == INVALID_DATA_VERSION) {
diff --git a/src/com/android/gallery3d/data/ClusterAlbumSet.java b/src/com/android/gallery3d/data/ClusterAlbumSet.java
index 0986a8d69..7695bd35c 100644
--- a/src/com/android/gallery3d/data/ClusterAlbumSet.java
+++ b/src/com/android/gallery3d/data/ClusterAlbumSet.java
@@ -32,6 +32,7 @@ public class ClusterAlbumSet extends MediaSet implements ContentListener {
private MediaSet mBaseSet;
private int mKind;
private ArrayList<ClusterAlbum> mAlbums = new ArrayList<ClusterAlbum>();
+ private boolean mIsLoading;
private int mTotalMediaItemCount;
/** mTotalSelectableMediaItemCount is the count of items
@@ -64,11 +65,18 @@ public class ClusterAlbumSet extends MediaSet implements ContentListener {
}
@Override
+ public synchronized boolean isLoading() {
+ return mIsLoading;
+ }
+
+ @Override
public long reload() {
synchronized (this) {
long version = mBaseSet.reload();
- if (version > mDataVersion && !mBaseSet.isLoading()) {
+ mIsLoading = mBaseSet.isLoading();
+ if (version > mDataVersion && !mIsLoading) {
updateClusters();
+ mIsLoading = false;
mDataVersion = nextVersionNumber();
}
if (mKind == ClusterSource.CLUSTER_ALBUMSET_TIME) {
diff --git a/src/com/android/gallery3d/data/FilterDeleteSet.java b/src/com/android/gallery3d/data/FilterDeleteSet.java
index fcf0dec74..5c34fda70 100644
--- a/src/com/android/gallery3d/data/FilterDeleteSet.java
+++ b/src/com/android/gallery3d/data/FilterDeleteSet.java
@@ -35,6 +35,8 @@ public class FilterDeleteSet extends MediaSet implements ContentListener {
private static final int REQUEST_REMOVE = 2;
private static final int REQUEST_CLEAR = 3;
+ private boolean mIsLoading;
+
private static class Request {
int type; // one of the REQUEST_* constants
Path path;
@@ -141,12 +143,21 @@ public class FilterDeleteSet extends MediaSet implements ContentListener {
return base;
}
+ @Override
+ public boolean isLoading() {
+ return mIsLoading;
+ }
+
// We apply the pending requests in the mRequests to construct mCurrent in reload().
@Override
public long reload() {
+ mIsLoading = true;
boolean newData = mBaseSet.reload() > mDataVersion;
synchronized (mRequests) {
if (!newData && mRequests.isEmpty()) {
+ if (!mBaseSet.isLoading()) {
+ mIsLoading = false;
+ }
return mDataVersion;
}
for (int i = 0; i < mRequests.size(); i++) {
@@ -220,6 +231,9 @@ public class FilterDeleteSet extends MediaSet implements ContentListener {
}
mDataVersion = nextVersionNumber();
+ if (!mBaseSet.isLoading()) {
+ mIsLoading = false;
+ }
return mDataVersion;
}