diff options
author | Hung-ying Tyan <tyanh@google.com> | 2012-10-30 17:47:35 +0800 |
---|---|---|
committer | Hung-ying Tyan <tyanh@google.com> | 2012-10-30 19:44:15 +0800 |
commit | 05da3f520eacb9219964b6ed57ef37846d889fd7 (patch) | |
tree | b574f8ac1346a4fe96918c6b1977f4623cb61fb3 /src/com/android/gallery3d/app/AlbumDataLoader.java | |
parent | 38c5d92c4a3659f3ae51a3b0f61bfb9eb2ed0043 (diff) | |
download | android_packages_apps_Gallery2-05da3f520eacb9219964b6ed57ef37846d889fd7.tar.gz android_packages_apps_Gallery2-05da3f520eacb9219964b6ed57ef37846d889fd7.tar.bz2 android_packages_apps_Gallery2-05da3f520eacb9219964b6ed57ef37846d889fd7.zip |
Show sync error toast only when both loading and syncing are done.
Bug: 7427597
Change-Id: Ie1fe8510e2a2225424b3c2892b2c0a8b4021324c
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)); |