summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wei <markwei@google.com>2013-01-16 20:27:17 -0800
committerMark Wei <markwei@google.com>2013-01-17 16:14:25 -0800
commit0bf849421d303e05c600cdcd7dab73cc84809a36 (patch)
treeb3b569a0f7d9877957d4fc0faed484d66feeadff
parent98ee665434ba99543c13a99b70a1ad5340a34c23 (diff)
downloadandroid_frameworks_opt_photoviewer-0bf849421d303e05c600cdcd7dab73cc84809a36.tar.gz
android_frameworks_opt_photoviewer-0bf849421d303e05c600cdcd7dab73cc84809a36.tar.bz2
android_frameworks_opt_photoviewer-0bf849421d303e05c600cdcd7dab73cc84809a36.zip
Modify image attachments previews to conform to UX specs
Thumbnail and full image start loading at the same time. Once thumbnail is shown, we display a determinate progress bar while downloading the full image. Remove progress bar from image tiles in ConversationView. Bug: 8021747 Change-Id: Ic1c7e7fcdc5683ad9e899c82b6bbdb5861d16a55
-rw-r--r--src/com/android/ex/photo/PhotoViewActivity.java5
-rw-r--r--src/com/android/ex/photo/PhotoViewCallbacks.java2
-rw-r--r--src/com/android/ex/photo/fragments/PhotoViewFragment.java49
3 files changed, 29 insertions, 27 deletions
diff --git a/src/com/android/ex/photo/PhotoViewActivity.java b/src/com/android/ex/photo/PhotoViewActivity.java
index 5e17674..7408952 100644
--- a/src/com/android/ex/photo/PhotoViewActivity.java
+++ b/src/com/android/ex/photo/PhotoViewActivity.java
@@ -552,6 +552,7 @@ public class PhotoViewActivity extends FragmentActivity implements
}
}
+ @Override
public void onNewPhotoLoaded() {
setViewActivated();
}
@@ -564,4 +565,8 @@ public class PhotoViewActivity extends FragmentActivity implements
mPhotoIndex = index;
}
+ @Override
+ public void onCursorChanged(PhotoViewFragment fragment, Cursor cursor) {
+ // do nothing
+ }
}
diff --git a/src/com/android/ex/photo/PhotoViewCallbacks.java b/src/com/android/ex/photo/PhotoViewCallbacks.java
index 62c497a..7e789c6 100644
--- a/src/com/android/ex/photo/PhotoViewCallbacks.java
+++ b/src/com/android/ex/photo/PhotoViewCallbacks.java
@@ -69,4 +69,6 @@ public interface PhotoViewCallbacks {
public void onFragmentVisible(PhotoViewFragment fragment);
public boolean isFragmentFullScreen(Fragment fragment);
+
+ public void onCursorChanged(PhotoViewFragment fragment, Cursor cursor);
}
diff --git a/src/com/android/ex/photo/fragments/PhotoViewFragment.java b/src/com/android/ex/photo/fragments/PhotoViewFragment.java
index ae0ef11..21c355a 100644
--- a/src/com/android/ex/photo/fragments/PhotoViewFragment.java
+++ b/src/com/android/ex/photo/fragments/PhotoViewFragment.java
@@ -23,7 +23,6 @@ import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.os.Bundle;
-import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.Loader;
@@ -215,21 +214,26 @@ public class PhotoViewFragment extends Fragment implements
@Override
public void onResume() {
+ super.onResume();
mCallback.addScreenListener(this);
mCallback.addCursorListener(this);
- getLoaderManager().initLoader(LOADER_ID_THUMBNAIL, null, this);
+ if (!isPhotoBound()) {
+ mProgressBarNeeded = true;
+ mPhotoPreviewAndProgress.setVisibility(View.VISIBLE);
- super.onResume();
+ getLoaderManager().initLoader(LOADER_ID_THUMBNAIL, null, this);
+ getLoaderManager().initLoader(LOADER_ID_PHOTO, null, this);
+ }
}
@Override
public void onPause() {
- super.onPause();
// Remove listeners
mCallback.removeCursorListener(this);
mCallback.removeScreenListener(this);
resetPhotoView();
+ super.onPause();
}
@Override
@@ -239,7 +243,6 @@ public class PhotoViewFragment extends Fragment implements
mPhotoView.clear();
mPhotoView = null;
}
-
super.onDestroyView();
}
@@ -274,14 +277,15 @@ public class PhotoViewFragment extends Fragment implements
return;
}
+ // both loaders are started together, they may finish loading in such a
+ // way that the thumbnail is displayed on top of the full image
final int id = loader.getId();
switch (id) {
case LOADER_ID_THUMBNAIL:
if (isPhotoBound()) {
- // There is need to do anything with the thumbnail image, as the full size
+ // There is need to do anything with the thumbnail
+ // image, as the full size
// image is being shown.
- mProgressBarNeeded = false;
- mPhotoPreviewAndProgress.setVisibility(View.GONE);
return;
}
@@ -295,25 +299,9 @@ public class PhotoViewFragment extends Fragment implements
mPhotoPreviewImage.setVisibility(View.VISIBLE);
mPhotoPreviewImage.setScaleType(ImageView.ScaleType.CENTER);
enableImageTransforms(false);
- mPhotoProgressBar.setIndeterminate(true);
- mProgressBarNeeded = true;
-
- Handler handler = new Handler();
- handler.post(new Runnable() {
- @Override
- public void run() {
- getLoaderManager().initLoader(LOADER_ID_PHOTO, null,
- PhotoViewFragment.this);
- }
- });
break;
case LOADER_ID_PHOTO:
- if (data != null) {
- bindPhoto(data);
- enableImageTransforms(true);
- mPhotoPreviewAndProgress.setVisibility(View.GONE);
- mProgressBarNeeded = false;
- }
+ bindPhoto(data);
break;
default:
break;
@@ -334,8 +322,13 @@ public class PhotoViewFragment extends Fragment implements
* Binds an image to the photo view.
*/
private void bindPhoto(Bitmap bitmap) {
- if (mPhotoView != null) {
- mPhotoView.bindPhoto(bitmap);
+ if (bitmap != null) {
+ if (mPhotoView != null) {
+ mPhotoView.bindPhoto(bitmap);
+ }
+ enableImageTransforms(true);
+ mPhotoPreviewAndProgress.setVisibility(View.GONE);
+ mProgressBarNeeded = false;
}
}
@@ -441,6 +434,8 @@ public class PhotoViewFragment extends Fragment implements
@Override
public void onCursorChanged(Cursor cursor) {
if (cursor.moveToPosition(mPosition) && !isPhotoBound()) {
+ mCallback.onCursorChanged(this, cursor);
+
final LoaderManager manager = getLoaderManager();
final Loader<Bitmap> fakeLoader = manager.getLoader(LOADER_ID_PHOTO);
if (fakeLoader == null) {