diff options
author | Bart Sears <bsears@google.com> | 2012-10-30 12:39:23 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-10-30 12:39:23 -0700 |
commit | 556347cb20e871f25560ff37d7c51f66733888f7 (patch) | |
tree | 97d3a92558c7fbe252d98bf4c09654cb0611d21a /src/com/android/gallery3d/app/AlbumDataLoader.java | |
parent | 883295bc3643c5d3e0520fa317bec9919cc4ff7c (diff) | |
parent | db0db2d3809d377577c601689c140276ac8cf323 (diff) | |
download | android_packages_apps_Snap-556347cb20e871f25560ff37d7c51f66733888f7.tar.gz android_packages_apps_Snap-556347cb20e871f25560ff37d7c51f66733888f7.tar.bz2 android_packages_apps_Snap-556347cb20e871f25560ff37d7c51f66733888f7.zip |
Merge "Show sync error toast only when both loading and syncing are done." into gb-ub-photos-arches
Diffstat (limited to 'src/com/android/gallery3d/app/AlbumDataLoader.java')
-rw-r--r-- | src/com/android/gallery3d/app/AlbumDataLoader.java | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/com/android/gallery3d/app/AlbumDataLoader.java b/src/com/android/gallery3d/app/AlbumDataLoader.java index 8093bb983..0ee1b03af 100644 --- a/src/com/android/gallery3d/app/AlbumDataLoader.java +++ b/src/com/android/gallery3d/app/AlbumDataLoader.java @@ -72,6 +72,8 @@ public class AlbumDataLoader { private LoadingListener mLoadingListener; private ReloadTask mReloadTask; + // the data version on which last loading failed + private long mFailedVersion = MediaObject.INVALID_DATA_VERSION; public AlbumDataLoader(AbstractGalleryActivity context, MediaSet mediaSet) { mSource = mediaSet; @@ -93,7 +95,11 @@ public class AlbumDataLoader { if (mLoadingListener != null) mLoadingListener.onLoadingStarted(); return; case MSG_LOAD_FINISH: - if (mLoadingListener != null) mLoadingListener.onLoadingFinished(); + if (mLoadingListener != null) { + boolean loadingFailed = + (mFailedVersion != MediaObject.INVALID_DATA_VERSION); + mLoadingListener.onLoadingFinished(loadingFailed); + } return; } } @@ -245,6 +251,10 @@ public class AlbumDataLoader { @Override public UpdateInfo call() throws Exception { + if (mFailedVersion == mVersion) { + // previous loading failed, return null to pause loading + return null; + } UpdateInfo info = new UpdateInfo(); long version = mVersion; info.version = mSourceVersion; @@ -283,7 +293,14 @@ public class AlbumDataLoader { ArrayList<MediaItem> items = info.items; - if (items == null) return null; + mFailedVersion = MediaObject.INVALID_DATA_VERSION; + if ((items == null) || items.isEmpty()) { + if (info.reloadCount > 0) { + mFailedVersion = info.version; + Log.d(TAG, "loading failed: " + mFailedVersion); + } + return null; + } int start = Math.max(info.reloadStart, mContentStart); int end = Math.min(info.reloadStart + items.size(), mContentEnd); @@ -340,11 +357,17 @@ public class AlbumDataLoader { synchronized (this) { if (mActive && !mDirty && updateComplete) { updateLoading(false); + if (mFailedVersion != MediaObject.INVALID_DATA_VERSION) { + Log.d(TAG, "reload pause"); + } Utils.waitWithoutInterrupt(this); + if (mActive && (mFailedVersion != MediaObject.INVALID_DATA_VERSION)) { + Log.d(TAG, "reload resume"); + } continue; } + mDirty = false; } - mDirty = false; updateLoading(true); long version = mSource.reload(); UpdateInfo info = executeAndWait(new GetUpdateInfo(version)); |