summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRay Chen <raychen@google.com>2012-05-17 12:29:12 +0800
committerHung-ying Tyan <tyanh@google.com>2012-05-23 12:41:50 +0800
commit0b920dba5d7452132f51c322e4a8282a1f73aac0 (patch)
tree2c85b2064cbf869e59efe0e19481e09fb04255b8 /src
parent048ca675a9e659fb0d3b150880d71cd42770023d (diff)
downloadandroid_packages_apps_Snap-0b920dba5d7452132f51c322e4a8282a1f73aac0.tar.gz
android_packages_apps_Snap-0b920dba5d7452132f51c322e4a8282a1f73aac0.tar.bz2
android_packages_apps_Snap-0b920dba5d7452132f51c322e4a8282a1f73aac0.zip
Fix 6259517 "0 images / videos available" toast is displayed in gallery on launch though it has images / videos
And removed sync error toast. Bug: 6259517 Change-Id: Ib7b25176a6db290220661a2e98e4e031043201d9
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/app/AlbumPage.java4
-rw-r--r--src/com/android/gallery3d/app/AlbumSetDataLoader.java2
-rw-r--r--src/com/android/gallery3d/app/AlbumSetPage.java7
-rw-r--r--src/com/android/gallery3d/data/ComboAlbumSet.java8
-rw-r--r--src/com/android/gallery3d/data/LocalAlbumSet.java8
-rw-r--r--src/com/android/gallery3d/data/MediaSet.java8
-rw-r--r--src/com/android/gallery3d/data/MtpDeviceSet.java8
7 files changed, 39 insertions, 6 deletions
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index 090ba0891..e7736918b 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -652,7 +652,9 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
mInitialSynced = true;
}
clearLoadingBit(BIT_LOADING_SYNC);
- if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive) {
+ if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive
+ && (mAlbumDataAdapter.size() == 0)) {
+ // show error toast only if the album is empty
Toast.makeText((Context) mActivity, R.string.sync_album_error,
Toast.LENGTH_LONG).show();
}
diff --git a/src/com/android/gallery3d/app/AlbumSetDataLoader.java b/src/com/android/gallery3d/app/AlbumSetDataLoader.java
index 819adccb7..39d4a8bdc 100644
--- a/src/com/android/gallery3d/app/AlbumSetDataLoader.java
+++ b/src/com/android/gallery3d/app/AlbumSetDataLoader.java
@@ -329,7 +329,7 @@ public class AlbumSetDataLoader {
while (mActive) {
synchronized (this) {
if (mActive && !mDirty && updateComplete) {
- updateLoading(false);
+ if (!mSource.isLoading()) updateLoading(false);
Utils.waitWithoutInterrupt(this);
continue;
}
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index 8376b2792..aa72eb82c 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -300,9 +300,9 @@ public class AlbumSetPage extends ActivityState implements
// Only show toast when there's no album and we are going to finish
// the page. Toast is redundant if we are going to stay on this page.
if ((mAlbumSetDataAdapter.size() == 0)) {
- Toast.makeText((Context) mActivity,
- R.string.empty_album, Toast.LENGTH_LONG).show();
if (mActivity.getStateManager().getStateCount() > 1) {
+ Toast.makeText((Context) mActivity,
+ R.string.empty_album, Toast.LENGTH_LONG).show();
mActivity.getStateManager().finishState(this);
}
}
@@ -597,8 +597,7 @@ public class AlbumSetPage extends ActivityState implements
}
clearLoadingBit(BIT_LOADING_SYNC);
if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive) {
- Toast.makeText((Context) mActivity, R.string.sync_album_set_error,
- Toast.LENGTH_LONG).show();
+ Log.w(TAG, "failed to load album set");
}
} finally {
root.unlockRenderThread();
diff --git a/src/com/android/gallery3d/data/ComboAlbumSet.java b/src/com/android/gallery3d/data/ComboAlbumSet.java
index 916b1639d..6d9a2a3d4 100644
--- a/src/com/android/gallery3d/data/ComboAlbumSet.java
+++ b/src/com/android/gallery3d/data/ComboAlbumSet.java
@@ -65,6 +65,14 @@ 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;
+ }
+ return false;
+ }
+
+ @Override
public long reload() {
boolean changed = false;
for (int i = 0, n = mSets.length; i < n; ++i) {
diff --git a/src/com/android/gallery3d/data/LocalAlbumSet.java b/src/com/android/gallery3d/data/LocalAlbumSet.java
index dbb518985..07741efcb 100644
--- a/src/com/android/gallery3d/data/LocalAlbumSet.java
+++ b/src/com/android/gallery3d/data/LocalAlbumSet.java
@@ -100,6 +100,7 @@ public class LocalAlbumSet extends MediaSet
private final ChangeNotifier mNotifierVideo;
private final String mName;
private final Handler mHandler;
+ private boolean mIsLoading;
private Future<ArrayList<MediaSet>> mLoadTask;
private ArrayList<MediaSet> mLoadBuffer;
@@ -261,6 +262,11 @@ public class LocalAlbumSet extends MediaSet
}
@Override
+ public synchronized boolean isLoading() {
+ return mIsLoading;
+ }
+
+ @Override
// synchronized on this function for
// 1. Prevent calling reload() concurrently.
// 2. Prevent calling onFutureDone() and reload() concurrently
@@ -268,6 +274,7 @@ public class LocalAlbumSet extends MediaSet
// "|" is used instead of "||" because we want to clear both flags.
if (mNotifierImage.isDirty() | mNotifierVideo.isDirty()) {
if (mLoadTask != null) mLoadTask.cancel();
+ mIsLoading = true;
mLoadTask = mApplication.getThreadPool().submit(new AlbumsLoader(), this);
}
if (mLoadBuffer != null) {
@@ -285,6 +292,7 @@ public class LocalAlbumSet extends MediaSet
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
diff --git a/src/com/android/gallery3d/data/MediaSet.java b/src/com/android/gallery3d/data/MediaSet.java
index ff9b8c386..67525b1f3 100644
--- a/src/com/android/gallery3d/data/MediaSet.java
+++ b/src/com/android/gallery3d/data/MediaSet.java
@@ -94,6 +94,14 @@ public abstract class MediaSet extends MediaObject {
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++) {
diff --git a/src/com/android/gallery3d/data/MtpDeviceSet.java b/src/com/android/gallery3d/data/MtpDeviceSet.java
index 6dcb0d2e6..1f26511fc 100644
--- a/src/com/android/gallery3d/data/MtpDeviceSet.java
+++ b/src/com/android/gallery3d/data/MtpDeviceSet.java
@@ -47,6 +47,7 @@ public class MtpDeviceSet extends MediaSet
private Future<ArrayList<MediaSet>> mLoadTask;
private ArrayList<MediaSet> mDeviceSet = new ArrayList<MediaSet>();
private ArrayList<MediaSet> mLoadBuffer;
+ private boolean mIsLoading;
public MtpDeviceSet(Path path, GalleryApp application, MtpContext mtpContext) {
super(path, nextVersionNumber());
@@ -113,9 +114,15 @@ public class MtpDeviceSet extends MediaSet
}
@Override
+ public synchronized boolean isLoading() {
+ return mIsLoading;
+ }
+
+ @Override
public synchronized long reload() {
if (mNotifier.isDirty()) {
if (mLoadTask != null) mLoadTask.cancel();
+ mIsLoading = true;
mLoadTask = mApplication.getThreadPool().submit(new DevicesLoader(), this);
}
if (mLoadBuffer != null) {
@@ -133,6 +140,7 @@ public class MtpDeviceSet extends MediaSet
public synchronized void onFutureDone(Future<ArrayList<MediaSet>> future) {
if (future != mLoadTask) return;
mLoadBuffer = future.get();
+ mIsLoading = false;
if (mLoadBuffer == null) mLoadBuffer = new ArrayList<MediaSet>();
mHandler.post(new Runnable() {