summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/app/AlbumPage.java
diff options
context:
space:
mode:
authorHung-ying Tyan <tyanh@google.com>2012-10-30 17:47:35 +0800
committerHung-ying Tyan <tyanh@google.com>2012-10-30 19:44:15 +0800
commitdb0db2d3809d377577c601689c140276ac8cf323 (patch)
treef5e0f5bd745fac7900fe905cd720cd9b7e63ef4b /src/com/android/gallery3d/app/AlbumPage.java
parent373fe6a155425c6488ab610157184633637314b4 (diff)
downloadandroid_packages_apps_Snap-db0db2d3809d377577c601689c140276ac8cf323.tar.gz
android_packages_apps_Snap-db0db2d3809d377577c601689c140276ac8cf323.tar.bz2
android_packages_apps_Snap-db0db2d3809d377577c601689c140276ac8cf323.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/AlbumPage.java')
-rw-r--r--src/com/android/gallery3d/app/AlbumPage.java29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index 4c945a45b..ee7a107fd 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -108,6 +108,8 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
private int mLoadingBits = 0;
private boolean mInitialSynced = false;
+ private int mSyncResult;
+ private boolean mLoadingFailed;
private RelativePosition mOpenCenter = new RelativePosition();
private Handler mHandler;
@@ -419,6 +421,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
// Set the reload bit here to prevent it exit this page in clearLoadingBit().
setLoadingBit(BIT_LOADING_RELOAD);
+ mLoadingFailed = false;
mAlbumDataAdapter.resume();
mAlbumView.resume();
@@ -693,17 +696,13 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
public void run() {
GLRoot root = mActivity.getGLRoot();
root.lockRenderThread();
+ mSyncResult = resultCode;
try {
if (resultCode == MediaSet.SYNC_RESULT_SUCCESS) {
mInitialSynced = true;
}
clearLoadingBit(BIT_LOADING_SYNC);
- if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive
- && (mAlbumDataAdapter.size() == 0)) {
- // show error toast only if the album is empty
- Toast.makeText(mActivity, R.string.sync_album_error,
- Toast.LENGTH_LONG).show();
- }
+ showSyncErrorIfNecessary(mLoadingFailed);
} finally {
root.unlockRenderThread();
}
@@ -711,6 +710,19 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
});
}
+ // Show sync error toast when all the following conditions are met:
+ // (1) both loading and sync are done,
+ // (2) sync result is error,
+ // (3) the page is still active, and
+ // (4) no photo is shown or loading fails.
+ private void showSyncErrorIfNecessary(boolean loadingFailed) {
+ if ((mLoadingBits == 0) && (mSyncResult == MediaSet.SYNC_RESULT_ERROR) && mIsActive
+ && (loadingFailed || (mAlbumDataAdapter.size() == 0))) {
+ Toast.makeText(mActivity, R.string.sync_album_error,
+ Toast.LENGTH_LONG).show();
+ }
+ }
+
private void setLoadingBit(int loadTaskBit) {
mLoadingBits |= loadTaskBit;
}
@@ -731,11 +743,14 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
@Override
public void onLoadingStarted() {
setLoadingBit(BIT_LOADING_RELOAD);
+ mLoadingFailed = false;
}
@Override
- public void onLoadingFinished() {
+ public void onLoadingFinished(boolean loadingFailed) {
clearLoadingBit(BIT_LOADING_RELOAD);
+ mLoadingFailed = loadingFailed;
+ showSyncErrorIfNecessary(loadingFailed);
}
}