diff options
author | John Reck <jreck@google.com> | 2013-01-16 14:10:30 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2013-01-16 18:05:07 -0800 |
commit | f4f43e7dbc85ab8b7437e8f1d6ab0317470e70b6 (patch) | |
tree | 52bf0103140bbe996165b07c5313a39828ed895d /src/com/android/gallery3d/data/ClusterAlbumSet.java | |
parent | 48d4284a9ce804ba00b22e587a8b3d27ef9928c1 (diff) | |
download | android_packages_apps_Gallery2-f4f43e7dbc85ab8b7437e8f1d6ab0317470e70b6.tar.gz android_packages_apps_Gallery2-f4f43e7dbc85ab8b7437e8f1d6ab0317470e70b6.tar.bz2 android_packages_apps_Gallery2-f4f43e7dbc85ab8b7437e8f1d6ab0317470e70b6.zip |
New loading model
Rename reload() to loadIfDirty()
loadIfDirty is implemented by MediaSet and is final
loadIfDirty is now blocking instead of async
Subclasses must implement two protected methods, isDirtyLocked() and load()
The change from async reload() to sync loadIfDirty() should be fine since
all users of reload() were doing so from a background thread already, and the
longest load() is PicasaAlbumSet which is still a fairly brisk 40ms or so
Change-Id: If5cc596a1c13e52e5f4efff1a144bd086d37cfb7
Diffstat (limited to 'src/com/android/gallery3d/data/ClusterAlbumSet.java')
-rw-r--r-- | src/com/android/gallery3d/data/ClusterAlbumSet.java | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/com/android/gallery3d/data/ClusterAlbumSet.java b/src/com/android/gallery3d/data/ClusterAlbumSet.java index cb212ba36..a551de2ab 100644 --- a/src/com/android/gallery3d/data/ClusterAlbumSet.java +++ b/src/com/android/gallery3d/data/ClusterAlbumSet.java @@ -24,7 +24,7 @@ import com.android.gallery3d.app.GalleryApp; import java.util.ArrayList; import java.util.HashSet; -public class ClusterAlbumSet extends MediaSet implements ContentListener { +public class ClusterAlbumSet extends MediaSetWrapper implements ContentListener { @SuppressWarnings("unused") private static final String TAG = "ClusterAlbumSet"; private GalleryApp mApplication; @@ -35,7 +35,7 @@ public class ClusterAlbumSet extends MediaSet implements ContentListener { public ClusterAlbumSet(Path path, GalleryApp application, MediaSet baseSet, int kind) { - super(path, INVALID_DATA_VERSION); + super(baseSet, path, INVALID_DATA_VERSION); mApplication = application; mBaseSet = baseSet; mKind = kind; @@ -58,17 +58,20 @@ public class ClusterAlbumSet extends MediaSet implements ContentListener { } @Override - public long reload() { - if (mBaseSet.reload() > mDataVersion) { - if (mFirstReloadDone) { - updateClustersContents(); - } else { - updateClusters(); - mFirstReloadDone = true; - } - mDataVersion = nextVersionNumber(); + protected boolean isDirtyLocked() { + return super.isDirtyLocked() + || !mFirstReloadDone; + } + + @Override + public void load() throws InterruptedException { + super.load(); + if (mFirstReloadDone) { + updateClustersContents(); + } else { + updateClusters(); + mFirstReloadDone = true; } - return mDataVersion; } @Override |