mDirty = false;
}
updateLoading(true);
- long version = mSource.loadIfDirty();
+ long version = mSource.reload();
UpdateInfo info = executeAndWait(new GetUpdateInfo(version));
updateComplete = info == null;
if (updateComplete) continue;
while (mActive) {
synchronized (this) {
if (mActive && !mDirty && updateComplete) {
- updateLoading(false);
+ if (!mSource.isLoading()) updateLoading(false);
Utils.waitWithoutInterrupt(this);
continue;
}
mDirty = false;
updateLoading(true);
- long version = mSource.loadIfDirty();
+ long version = mSource.reload();
UpdateInfo info = executeAndWait(new GetUpdateInfo(version));
updateComplete = info == null;
if (updateComplete) continue;
mDirty = false;
UpdateInfo info = executeAndWait(new GetUpdateInfo());
updateLoading(true);
- long version = mSource.loadIfDirty();
+ long version = mSource.reload();
if (info.version != version) {
info.reloadContent = true;
info.size = mSource.getMediaItemCount();
@Override
public long reload() {
- long version = mMediaSet.loadIfDirty();
+ long version = mMediaSet.reload();
if (version != mSourceVersion) {
mSourceVersion = version;
int count = mMediaSet.getTotalMediaItemCount();
@Override
public long reload() {
- long version = mMediaSet.loadIfDirty();
+ long version = mMediaSet.reload();
if (version != mDataVersion) {
mDataVersion = version;
mData.clear();
import java.util.ArrayList;
-public class ClusterAlbum extends MediaSetWrapper implements ContentListener {
+public class ClusterAlbum extends MediaSet implements ContentListener {
@SuppressWarnings("unused")
private static final String TAG = "ClusterAlbum";
private ArrayList<Path> mPaths = new ArrayList<Path>();
public ClusterAlbum(Path path, DataManager dataManager,
MediaSet clusterAlbumSet) {
- super(clusterAlbumSet, path, nextVersionNumber());
+ super(path, nextVersionNumber());
mDataManager = dataManager;
mClusterAlbumSet = clusterAlbumSet;
mClusterAlbumSet.addContentListener(this);
}
@Override
+ public long reload() {
+ if (mClusterAlbumSet.reload() > mDataVersion) {
+ mDataVersion = nextVersionNumber();
+ }
+ return mDataVersion;
+ }
+
+ @Override
public void onContentDirty() {
notifyContentChanged();
}
import java.util.ArrayList;
import java.util.HashSet;
-public class ClusterAlbumSet extends MediaSetWrapper implements ContentListener {
+public class ClusterAlbumSet extends MediaSet implements ContentListener {
@SuppressWarnings("unused")
private static final String TAG = "ClusterAlbumSet";
private GalleryApp mApplication;
public ClusterAlbumSet(Path path, GalleryApp application,
MediaSet baseSet, int kind) {
- super(baseSet, path, INVALID_DATA_VERSION);
+ super(path, INVALID_DATA_VERSION);
mApplication = application;
mBaseSet = baseSet;
mKind = kind;
}
@Override
- protected boolean isDirtyLocked() {
- return super.isDirtyLocked()
- || !mFirstReloadDone;
- }
-
- @Override
- public void load() throws InterruptedException {
- super.load();
- if (mFirstReloadDone) {
- updateClustersContents();
- } else {
- updateClusters();
- mFirstReloadDone = true;
+ public long reload() {
+ if (mBaseSet.reload() > mDataVersion) {
+ if (mFirstReloadDone) {
+ updateClustersContents();
+ } else {
+ updateClusters();
+ mFirstReloadDone = true;
+ }
+ mDataVersion = nextVersionNumber();
}
+ return mDataVersion;
}
@Override
@SuppressWarnings("unused")
private static final String TAG = "ComboAlbum";
private final MediaSet[] mSets;
- private final boolean[] mDirtySets;
private String mName;
public ComboAlbum(Path path, MediaSet[] mediaSets, String name) {
super(path, nextVersionNumber());
mSets = mediaSets;
- mDirtySets = new boolean[mSets.length];
for (MediaSet set : mSets) {
set.addContentListener(this);
}
}
@Override
- 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 dirty;
- }
-
- @Override
- protected void load() throws InterruptedException {
+ public long reload() {
+ boolean changed = false;
for (int i = 0, n = mSets.length; i < n; ++i) {
- if (mDirtySets[i]) {
- mDirtySets[i] = false;
- mSets[i].load();
- }
+ long version = mSets[i].reload();
+ if (version > mDataVersion) changed = true;
}
+ if (changed) mDataVersion = nextVersionNumber();
+ return mDataVersion;
}
@Override
@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);
}
}
@Override
- 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();
+ public boolean isLoading() {
+ for (int i = 0, n = mSets.length; i < n; ++i) {
+ if (mSets[i].isLoading()) return true;
}
- return dirty;
+ return false;
}
@Override
- protected void load() throws InterruptedException {
+ public long reload() {
+ boolean changed = false;
for (int i = 0, n = mSets.length; i < n; ++i) {
- if (mDirtySets[i]) {
- mDirtySets[i] = false;
- mSets[i].load();
- }
+ long version = mSets[i].reload();
+ if (version > mDataVersion) changed = true;
}
+ if (changed) mDataVersion = nextVersionNumber();
+ return mDataVersion;
}
@Override
// void clearDeletion();
// int getNumberOfDeletions();
//
-public class FilterDeleteSet extends MediaSetWrapper implements ContentListener {
+public class FilterDeleteSet extends MediaSet implements ContentListener {
@SuppressWarnings("unused")
private static final String TAG = "FilterDeleteSet";
private ArrayList<Deletion> mCurrent = new ArrayList<Deletion>();
public FilterDeleteSet(Path path, MediaSet baseSet) {
- super(baseSet, path, INVALID_DATA_VERSION);
+ super(path, INVALID_DATA_VERSION);
mBaseSet = baseSet;
mBaseSet.addContentListener(this);
}
return base;
}
- @Override
- protected boolean isDirtyLocked() {
- synchronized (mRequests) {
- return super.isDirtyLocked() || !mRequests.isEmpty();
- }
- }
-
// We apply the pending requests in the mRequests to construct mCurrent in reload().
@Override
- protected void load() throws InterruptedException {
- super.load();
+ public long reload() {
+ boolean newData = mBaseSet.reload() > mDataVersion;
synchronized (mRequests) {
+ if (!newData && mRequests.isEmpty()) {
+ return mDataVersion;
+ }
for (int i = 0; i < mRequests.size(); i++) {
Request r = mRequests.get(i);
switch (r.type) {
}
mCurrent = result;
}
+
+ mDataVersion = nextVersionNumber();
+ return mDataVersion;
}
private void sendRequest(int type, Path path, int indexHint) {
import java.util.ArrayList;
-public class FilterEmptyPromptSet extends MediaSetWrapper implements ContentListener {
+public class FilterEmptyPromptSet extends MediaSet implements ContentListener {
@SuppressWarnings("unused")
private static final String TAG = "FilterEmptyPromptSet";
private MediaSet mBaseSet;
public FilterEmptyPromptSet(Path path, MediaSet baseSet, MediaItem emptyItem) {
- super(baseSet, path, INVALID_DATA_VERSION);
+ super(path, INVALID_DATA_VERSION);
mEmptyItem = new ArrayList<MediaItem>(1);
mEmptyItem.add(emptyItem);
mBaseSet = baseSet;
}
@Override
+ public long reload() {
+ return mBaseSet.reload();
+ }
+
+ @Override
public String getName() {
return mBaseSet.getName();
}
private final DataManager mDataManager;
private final MediaSet mBaseSet;
- private boolean mBaseSetIsDirty;
private final int mMediaType;
private final ArrayList<Path> mPaths = new ArrayList<Path>();
private final ArrayList<MediaSet> mAlbums = new ArrayList<MediaSet>();
}
@Override
- protected boolean isDirtyLocked() {
- mBaseSetIsDirty = mBaseSet.isDirtyLocked();
- return mBaseSetIsDirty || mBaseSet.getDataVersion() > getDataVersion();
- }
-
- @Override
- public void load() throws InterruptedException {
- if (mBaseSetIsDirty) {
- mBaseSet.load();
+ public long reload() {
+ if (mBaseSet.reload() > mDataVersion) {
+ updateData();
+ mDataVersion = nextVersionNumber();
}
- updateData();
+ return mDataVersion;
}
@Override
notifyContentChanged();
}
- private void updateData() throws InterruptedException {
+ private void updateData() {
// Albums
mAlbums.clear();
String basePath = "/filter/mediatype/" + mMediaType;
MediaSet set = mBaseSet.getSubMediaSet(i);
String filteredPath = basePath + "/{" + set.getPath().toString() + "}";
MediaSet filteredSet = mDataManager.getMediaSet(filteredPath);
- filteredSet.loadIfDirty();
+ filteredSet.reload();
if (filteredSet.getMediaItemCount() > 0
|| filteredSet.getSubMediaSetCount() > 0) {
mAlbums.add(filteredSet);
}
@Override
- protected boolean isDirtyLocked() {
- return mNotifier.isDirty();
- }
- @Override
- public void load() {
- mCachedCount = INVALID_COUNT;
+ public long reload() {
+ if (mNotifier.isDirty()) {
+ mDataVersion = nextVersionNumber();
+ mCachedCount = INVALID_COUNT;
+ }
+ return mDataVersion;
}
@Override
package com.android.gallery3d.data;
import android.net.Uri;
+import android.os.Handler;
import android.provider.MediaStore.Images;
import android.provider.MediaStore.Video;
import com.android.gallery3d.R;
import com.android.gallery3d.app.GalleryApp;
import com.android.gallery3d.data.BucketHelper.BucketEntry;
+import com.android.gallery3d.util.Future;
+import com.android.gallery3d.util.FutureListener;
import com.android.gallery3d.util.MediaSetUtils;
+import com.android.gallery3d.util.ThreadPool;
+import com.android.gallery3d.util.ThreadPool.JobContext;
import java.util.ArrayList;
import java.util.Comparator;
// LocalAlbumSet lists all image or video albums in the local storage.
// The path should be "/local/image", "local/video" or "/local/all"
-public class LocalAlbumSet extends MediaSet {
+public class LocalAlbumSet extends MediaSet
+ implements FutureListener<ArrayList<MediaSet>> {
@SuppressWarnings("unused")
private static final String TAG = "LocalAlbumSet";
private ArrayList<MediaSet> mAlbums = new ArrayList<MediaSet>();
private final ChangeNotifier mNotifier;
private final String mName;
+ private final Handler mHandler;
+ private boolean mIsLoading;
+
+ private Future<ArrayList<MediaSet>> mLoadTask;
+ private ArrayList<MediaSet> mLoadBuffer;
public LocalAlbumSet(Path path, GalleryApp application) {
super(path, nextVersionNumber());
mApplication = application;
+ mHandler = new Handler(application.getMainLooper());
mType = getTypeFromPath(path);
mNotifier = new ChangeNotifier(this, mWatchUris, application);
mName = application.getResources().getString(
return -1;
}
+ private class AlbumsLoader implements ThreadPool.Job<ArrayList<MediaSet>> {
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ArrayList<MediaSet> run(JobContext jc) {
+ // Note: it will be faster if we only select media_type and bucket_id.
+ // need to test the performance if that is worth
+ BucketEntry[] entries = BucketHelper.loadBucketEntries(
+ jc, mApplication.getContentResolver(), mType);
+
+ if (jc.isCancelled()) return null;
+
+ int offset = 0;
+ // Move camera and download bucket to the front, while keeping the
+ // order of others.
+ int index = findBucket(entries, MediaSetUtils.CAMERA_BUCKET_ID);
+ if (index != -1) {
+ circularShiftRight(entries, offset++, index);
+ }
+ index = findBucket(entries, MediaSetUtils.DOWNLOAD_BUCKET_ID);
+ if (index != -1) {
+ circularShiftRight(entries, offset++, index);
+ }
+
+ ArrayList<MediaSet> albums = new ArrayList<MediaSet>();
+ DataManager dataManager = mApplication.getDataManager();
+ for (BucketEntry entry : entries) {
+ MediaSet album = getLocalAlbum(dataManager,
+ mType, mPath, entry.bucketId, entry.bucketName);
+ albums.add(album);
+ }
+ return albums;
+ }
+ }
+
private MediaSet getLocalAlbum(
DataManager manager, int type, Path parent, int id, String name) {
synchronized (DataManager.LOCK) {
}
@Override
- protected boolean isDirtyLocked() {
- return mNotifier.isDirty();
+ public synchronized boolean isLoading() {
+ return mIsLoading;
}
@Override
- protected void load() throws InterruptedException {
- // Note: it will be faster if we only select media_type and bucket_id.
- // need to test the performance if that is worth
- BucketEntry[] entries = BucketHelper.loadBucketEntries(
- createJobContextCompat(), mApplication.getContentResolver(), mType);
-
- // BucketHelper.loadBucketEntries returns null if it was canceled
- if (entries == null || Thread.interrupted()) {
- throw new InterruptedException();
- }
-
- int offset = 0;
- // Move camera and download bucket to the front, while keeping the
- // order of others.
- int index = findBucket(entries, MediaSetUtils.CAMERA_BUCKET_ID);
- if (index != -1) {
- circularShiftRight(entries, offset++, index);
+ // synchronized on this function for
+ // 1. Prevent calling reload() concurrently.
+ // 2. Prevent calling onFutureDone() and reload() concurrently
+ public synchronized long reload() {
+ if (mNotifier.isDirty()) {
+ if (mLoadTask != null) mLoadTask.cancel();
+ mIsLoading = true;
+ mLoadTask = mApplication.getThreadPool().submit(new AlbumsLoader(), this);
}
- index = findBucket(entries, MediaSetUtils.DOWNLOAD_BUCKET_ID);
- if (index != -1) {
- circularShiftRight(entries, offset++, index);
- }
-
- mAlbums.clear();
- DataManager dataManager = mApplication.getDataManager();
- for (BucketEntry entry : entries) {
- MediaSet album = getLocalAlbum(dataManager,
- mType, mPath, entry.bucketId, entry.bucketName);
- mAlbums.add(album);
+ if (mLoadBuffer != null) {
+ mAlbums = mLoadBuffer;
+ mLoadBuffer = null;
+ for (MediaSet album : mAlbums) {
+ album.reload();
+ }
+ mDataVersion = nextVersionNumber();
}
+ return mDataVersion;
+ }
- for (MediaSet album : mAlbums) {
- album.loadIfDirty();
- }
+ @Override
+ public synchronized void onFutureDone(Future<ArrayList<MediaSet>> future) {
+ if (mLoadTask != future) return; // ignore, wait for the latest task
+ mLoadBuffer = future.get();
+ mIsLoading = false;
+ if (mLoadBuffer == null) mLoadBuffer = new ArrayList<MediaSet>();
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ notifyContentChanged();
+ }
+ });
}
// For debug only. Fake there is a ContentObserver.onChange() event.
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.Comparator;
+import java.util.NoSuchElementException;
import java.util.SortedMap;
import java.util.TreeMap;
private final Comparator<MediaItem> mComparator;
private final MediaSet[] mSources;
- private final boolean[] mDirtySources;
private FetchCache[] mFetcher;
private int mSupportedOperation;
super(path, INVALID_DATA_VERSION);
mComparator = comparator;
mSources = sources;
- mDirtySources = new boolean[mSources.length];
mBucketId = bucketId;
for (MediaSet set : mSources) {
set.addContentListener(this);
}
+ reload();
}
@Override
}
private void updateData() {
+ ArrayList<MediaSet> matches = new ArrayList<MediaSet>();
int supported = mSources.length == 0 ? 0 : MediaItem.SUPPORT_ALL;
mFetcher = new FetchCache[mSources.length];
for (int i = 0, n = mSources.length; i < n; ++i) {
}
@Override
- protected boolean isDirtyLocked() {
- boolean dirty = false;
+ public long reload() {
+ boolean changed = false;
for (int i = 0, n = mSources.length; i < n; ++i) {
- mDirtySources[i] = mSources[i].isDirtyLocked();
- dirty |= mDirtySources[i]
- || mSources[i].getDataVersion() > getDataVersion();
+ if (mSources[i].reload() > mDataVersion) changed = true;
}
- return dirty;
- }
-
- @Override
- public void load() throws InterruptedException {
- for (int i = 0, n = mSources.length; i < n; ++i) {
- if (mDirtySources[i]) {
- mSources[i].load();
- mDirtySources[i] = false;
- }
+ if (changed) {
+ mDataVersion = nextVersionNumber();
+ updateData();
+ invalidateCache();
}
- updateData();
- invalidateCache();
+ return mDataVersion;
}
@Override
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.util.Future;
-import com.android.gallery3d.util.ThreadPool.CancelListener;
-import com.android.gallery3d.util.ThreadPool.JobContext;
import java.util.ArrayList;
import java.util.WeakHashMap;
void onSyncDone(MediaSet mediaSet, int resultCode);
}
- private Object mLoadLock = new Object();
- private boolean mIsLoading;
-
public MediaSet(Path path, long version) {
super(path, version);
}
return false;
}
+ /**
+ * Method {@link #reload()} may process the loading task in background, this method tells
+ * its client whether the loading is still in process or not.
+ */
+ public boolean isLoading() {
+ return false;
+ }
+
public int getTotalMediaItemCount() {
int total = getMediaItemCount();
for (int i = 0, n = getSubMediaSetCount(); i < n; i++) {
}
}
- // TODO: Remove this once createJobContextCompat is no longer needed
- // Note that canceling a load is not strictly supported as it can leave
- // MediaSets with bad internal state. Fortunately they are never canceled
- // anywhere, so the isCancelled() exists purely for completeness sake
- private static class LoadJobContextCompat implements JobContext {
-
- @Override
- public boolean isCancelled() {
- return Thread.interrupted();
- }
-
- @Override
- public void setCancelListener(CancelListener listener) {
- }
-
- @Override
- public boolean setMode(int mode) {
- return false;
- }
- }
-
- @Deprecated
- protected final JobContext createJobContextCompat() {
- return new LoadJobContextCompat();
- }
-
- /**
- * Synchronously load if the MediaSet is dirty. Note that this must be called
- * on the same thread as getMediaItem(int, int) and getSubMediaSet(int)
- * @return DataVersion
- */
- public final long loadIfDirty() {
- try {
- boolean doLoad = false;
- synchronized (mLoadLock) {
- if (mIsLoading) {
- mLoadLock.wait();
- }
- doLoad = isDirtyLocked();
- if (doLoad) {
- mIsLoading = true;
- }
- }
- if (doLoad) {
- load();
- synchronized (mLoadLock) {
- mDataVersion = nextVersionNumber();
- mIsLoading = false;
- mLoadLock.notifyAll();
- }
- }
- } catch (InterruptedException ex) {
- }
- return getDataVersion();
- }
-
- /**
- * Called inside of synchronized(mLoadLock). It is guaranteed this will only
- * be called once before a call to load() if this returns true. It is
- * acceptable to clear any internal dirty flags in this function as a result.
- * @return true if the set wants a load() call, false otherwise
- */
- protected abstract boolean isDirtyLocked();
-
- /**
- * Synchronously load the MediaSet. Only called if {@link #isDirtyLocked()}
- * returned true
- * @throws InterruptedException if the load was interrupted
- */
- protected abstract void load() throws InterruptedException;
+ // Reload the content. Return the current data version. reload() should be called
+ // in the same thread as getMediaItem(int, int) and getSubMediaSet(int).
+ public abstract long reload();
@Override
public MediaDetails getDetails() {
}
private class MultiSetSyncFuture implements Future<Integer>, SyncListener {
+ @SuppressWarnings("hiding")
private static final String TAG = "Gallery.MultiSetSync";
private final SyncListener mListener;
+++ /dev/null
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.data;
-
-public abstract class MediaSetWrapper extends MediaSet {
-
- private MediaSet mWrappedSet;
- private boolean mWrappedIsDirty;
-
- public MediaSetWrapper(MediaSet wrappedSet, Path path, long version) {
- super(path, version);
- mWrappedSet = wrappedSet;
- }
-
- @Override
- protected boolean isDirtyLocked() {
- mWrappedIsDirty = mWrappedSet.isDirtyLocked();
- return mWrappedIsDirty;
- }
-
- @Override
- protected void load() throws InterruptedException {
- if (mWrappedIsDirty) {
- mWrappedSet.load();
- }
- }
-
- @Override
- public long getDataVersion() {
- return mWrappedSet.getDataVersion();
- }
-
-}
}
@Override
- protected boolean isDirtyLocked() {
- return mNotifier.isDirty();
- }
-
- @Override
- public void load() {
- updateExistingItems();
+ public long reload() {
+ if (mNotifier.isDirty()) {
+ mDataVersion = nextVersionNumber();
+ updateExistingItems();
+ }
+ return mDataVersion;
}
private ArrayList<Integer> queryExistingIds(Uri uri, int minId, int maxId) {
}
@Override
- protected boolean isDirtyLocked() {
- return false;
+ public long reload() {
+ return mDataVersion;
}
-
- @Override
- protected void load() throws InterruptedException {
- }
-
}
}
@Override
- protected void load() throws InterruptedException {
- ((SnailItem) getItem()).updateVersion();
- }
-
- @Override
- protected boolean isDirtyLocked() {
- return mDirty.compareAndSet(true, false);
+ public long reload() {
+ if (mDirty.compareAndSet(true, false)) {
+ ((SnailItem) getItem()).updateVersion();
+ mDataVersion = nextVersionNumber();
+ }
+ return mDataVersion;
}
public void notifyChange() {
@Override
public void reload() {
- long version = mSource.loadIfDirty();
+ long version = mSource.reload();
if (mSourceVersion != version) {
mSourceVersion = version;
mCacheStart = 0;
@Override
public Cursor loadInBackground() {
- mMediaSet.loadIfDirty();
+ // TODO: This probably doesn't work
+ mMediaSet.reload();
final MatrixCursor cursor = new MatrixCursor(PhotoSetLoader.PROJECTION);
final Object[] row = new Object[PhotoSetLoader.PROJECTION.length];
final SparseArray<MediaItem> mediaItems = new SparseArray<MediaItem>();
@Override
public Cursor loadInBackground() {
- mMediaSet.loadIfDirty();
+ // TODO: This probably doesn't work
+ mMediaSet.reload();
final MatrixCursor cursor = new MatrixCursor(AlbumSetLoader.PROJECTION);
final Object[] row = new Object[AlbumSetLoader.PROJECTION.length];
int count = mMediaSet.getSubMediaSetCount();
ArrayList<MediaItem> coverItems = new ArrayList<MediaItem>(count);
for (int i = 0; i < count; i++) {
MediaSet m = mMediaSet.getSubMediaSet(i);
- m.loadIfDirty();
+ m.reload();
row[AlbumSetLoader.INDEX_ID] = i;
row[AlbumSetLoader.INDEX_TITLE] = m.getName();
row[AlbumSetLoader.INDEX_COUNT] = m.getMediaItemCount();
}
@Override
- protected boolean isDirtyLocked() {
- return false;
- }
-
- @Override
- protected void load() {
+ public long reload() {
+ return mDataVersion;
}
}
Path path = Path.fromString(
mIsImage ? "/local/image" : "/local/video");
mAlbumSet = new LocalAlbumSet(path, mApp);
- mAlbumSet.loadIfDirty();
+ mAlbumSet.reload();
verifyResult();
}
sub.delete();
mAlbumSet.fakeChange();
latch.isOnContentDirtyBeCalled(DEFAULT_TIMEOUT);
- mAlbumSet.loadIfDirty();
+ mAlbumSet.reload();
assertEquals(1, mAlbumSet.getSubMediaSetCount());
}
}
assertEquals(1, sub.getMediaItemCount());
assertTrue((sub.getSupportedOperations() & MediaSet.SUPPORT_DELETE) != 0);
sub.delete();
- sub.loadIfDirty();
+ sub.reload();
assertEquals(0, sub.getMediaItemCount());
}
}
}
@Override
- protected boolean isDirtyLocked() {
- return false;
+ public long reload() {
+ return 0;
}
-
- @Override
- protected void load() throws InterruptedException {
- }
-
}
class TestLocalImage {
public void run() {
MediaSet set = mDataManager.getMediaSet("/local/image");
- set.loadIfDirty();
+ set.reload();
Log.v(TAG, "LocalAlbumSet (Image)");
dumpMediaSet(set, "");
}
class TestLocalVideo {
public void run() {
MediaSet set = mDataManager.getMediaSet("/local/video");
- set.loadIfDirty();
+ set.reload();
Log.v(TAG, "LocalAlbumSet (Video)");
dumpMediaSet(set, "");
}
class TestPicasa implements Runnable {
public void run() {
MediaSet set = mDataManager.getMediaSet("/picasa");
- set.loadIfDirty();
+ set.reload();
Log.v(TAG, "PicasaAlbumSet");
dumpMediaSet(set, "");
}