diff options
Diffstat (limited to 'src/com/android')
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; } |
