summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/data/ComboAlbumSet.java
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2013-01-16 14:10:30 -0800
committerJohn Reck <jreck@google.com>2013-01-16 18:05:07 -0800
commit9686d9d07e344fae2f2310ca544e5401b5e11d30 (patch)
tree7bc66a807f33e3aa016d0e9c977f85cfffbe62f1 /src/com/android/gallery3d/data/ComboAlbumSet.java
parent9003bd581c00a31db4c8291c99a30d5e74fe2dde (diff)
downloadandroid_packages_apps_Snap-9686d9d07e344fae2f2310ca544e5401b5e11d30.tar.gz
android_packages_apps_Snap-9686d9d07e344fae2f2310ca544e5401b5e11d30.tar.bz2
android_packages_apps_Snap-9686d9d07e344fae2f2310ca544e5401b5e11d30.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/ComboAlbumSet.java')
-rw-r--r--src/com/android/gallery3d/data/ComboAlbumSet.java33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/com/android/gallery3d/data/ComboAlbumSet.java b/src/com/android/gallery3d/data/ComboAlbumSet.java
index a2a041279..528ffcf41 100644
--- a/src/com/android/gallery3d/data/ComboAlbumSet.java
+++ b/src/com/android/gallery3d/data/ComboAlbumSet.java
@@ -27,11 +27,13 @@ public class ComboAlbumSet extends MediaSet implements ContentListener {
@SuppressWarnings("unused")
private static final String TAG = "ComboAlbumSet";
private final MediaSet[] mSets;
+ private final boolean[] mDirtySets;
private final String mName;
public ComboAlbumSet(Path path, GalleryApp application, MediaSet[] mediaSets) {
super(path, nextVersionNumber());
mSets = mediaSets;
+ mDirtySets = new boolean[mSets.length];
for (MediaSet set : mSets) {
set.addContentListener(this);
}
@@ -66,31 +68,24 @@ public class ComboAlbumSet extends MediaSet implements ContentListener {
}
@Override
- public boolean isLoading() {
- for (int i = 0, n = mSets.length; i < n; ++i) {
- if (mSets[i].isLoading()) return true;
+ protected boolean isDirtyLocked() {
+ boolean dirty = false;
+ for (int i = 0; i < mSets.length; i++) {
+ mDirtySets[i] = mSets[i].isDirtyLocked();
+ dirty |= mDirtySets[i]
+ || mSets[i].getDataVersion() > getDataVersion();
}
- return false;
+ return dirty;
}
@Override
- public long reload() {
- boolean changed = false;
+ protected void load() throws InterruptedException {
for (int i = 0, n = mSets.length; i < n; ++i) {
- long version = mSets[i].reload();
- if (version > mDataVersion) changed = true;
- }
- if (changed) mDataVersion = nextVersionNumber();
- return mDataVersion;
- }
-
- @Override
- public boolean loadIfDirty() {
- boolean changed = false;
- for (int i = 0; i < mSets.length; i++) {
- changed |= mSets[i].loadIfDirty();
+ if (mDirtySets[i]) {
+ mDirtySets[i] = false;
+ mSets[i].load();
+ }
}
- return changed;
}
@Override