summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/app
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2011-08-30 10:38:59 +0800
committerOwen Lin <owenlin@google.com>2011-09-05 11:28:18 +0800
commitace280a70fd1ead67039b9667d3905c85703c094 (patch)
treeadd5ae4895e61f13a9b55c91b9890bb6ecc9a58e /src/com/android/gallery3d/app
parent9c12d7512df688131384328fb6ffb89b36cc4393 (diff)
downloadandroid_packages_apps_Snap-ace280a70fd1ead67039b9667d3905c85703c094.tar.gz
android_packages_apps_Snap-ace280a70fd1ead67039b9667d3905c85703c094.tar.bz2
android_packages_apps_Snap-ace280a70fd1ead67039b9667d3905c85703c094.zip
Improve the performance of Reviewing a photo.
fix: 5144370 There is two componenet in the photo page. One is the large photo and the other is the thumbnail strip. They idenpendently load their own data and images. This change fixes several issues here: 1. Prevent sending to many jobs to ThreadPool and block others. In a worse case, if the thumbnail strip send image requests first, it may block the ThreadPool very long. 2. Improve the performance of extracting thumbnails from local files. Now we try to extract the thumbnails from EXIF data first. Change-Id: I45100d4daa025efb479f47c4f105de2b4731b498
Diffstat (limited to 'src/com/android/gallery3d/app')
-rw-r--r--src/com/android/gallery3d/app/PhotoDataAdapter.java8
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java39
2 files changed, 32 insertions, 15 deletions
diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java
index c05c89a0d..78afe7ee7 100644
--- a/src/com/android/gallery3d/app/PhotoDataAdapter.java
+++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java
@@ -142,6 +142,7 @@ public class PhotoDataAdapter implements PhotoPage.Model {
private boolean mIsActive;
public interface DataListener extends LoadingListener {
+ public void onPhotoAvailable(long version, boolean fullImage);
public void onPhotoChanged(int index, Path item);
}
@@ -224,6 +225,9 @@ public class PhotoDataAdapter implements PhotoPage.Model {
if (entry.screenNail == null) {
entry.failToLoad = true;
} else {
+ if (mDataListener != null) {
+ mDataListener.onPhotoAvailable(version, false);
+ }
for (int i = -1; i <=1; ++i) {
if (version == getVersion(mCurrentIndex + i)) {
if (i == 0) updateTileProvider(entry);
@@ -244,6 +248,9 @@ public class PhotoDataAdapter implements PhotoPage.Model {
entry.fullImageTask = null;
entry.fullImage = future.get();
if (entry.fullImage != null) {
+ if (mDataListener != null) {
+ mDataListener.onPhotoAvailable(version, true);
+ }
if (version == getVersion(mCurrentIndex)) {
updateTileProvider(entry);
mPhotoView.notifyImageInvalidated(0);
@@ -644,6 +651,7 @@ public class PhotoDataAdapter implements PhotoPage.Model {
@Override
public UpdateInfo call() throws Exception {
+ // TODO: Try to load some data in first update
UpdateInfo info = new UpdateInfo();
info.version = mSourceVersion;
info.reloadContent = needContentReload();
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 44f299ef5..3a0bcd23f 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -94,7 +94,7 @@ public class PhotoPage extends ActivityState
private Intent mResultIntent = new Intent();
private int mCurrentIndex = 0;
private Handler mHandler;
- private boolean mShowBars;
+ private boolean mShowBars = true;
private ActionBar mActionBar;
private MyMenuVisibilityListener mMenuVisibilityListener;
private boolean mIsMenuVisible;
@@ -148,6 +148,22 @@ public class PhotoPage extends ActivityState
}
};
+ private void initFilmStripView() {
+ Config.PhotoPage config = Config.PhotoPage.get((Context) mActivity);
+ mFilmStripView = new FilmStripView(mActivity, mMediaSet,
+ config.filmstripTopMargin, config.filmstripMidMargin, config.filmstripBottomMargin,
+ config.filmstripContentSize, config.filmstripThumbSize, config.filmstripBarSize,
+ config.filmstripGripSize, config.filmstripGripWidth);
+ mRootPane.addComponent(mFilmStripView);
+ mFilmStripView.setListener(this);
+ mFilmStripView.setUserInteractionListener(this);
+ mFilmStripView.setFocusIndex(mCurrentIndex);
+ mFilmStripView.setStartIndex(mCurrentIndex);
+ mRootPane.requestLayout();
+ if (mIsActive) mFilmStripView.resume();
+ if (!mShowBars) mFilmStripView.setVisibility(GLView.INVISIBLE);
+ }
+
@Override
public void onCreate(Bundle data, Bundle restoreState) {
mActionBar = ((Activity) mActivity).getActionBar();
@@ -175,25 +191,14 @@ public class PhotoPage extends ActivityState
mModel = pda;
mPhotoView.setModel(mModel);
- Config.PhotoPage config = Config.PhotoPage.get((Context) mActivity);
-
- mFilmStripView = new FilmStripView(mActivity, mMediaSet,
- config.filmstripTopMargin, config.filmstripMidMargin, config.filmstripBottomMargin,
- config.filmstripContentSize, config.filmstripThumbSize, config.filmstripBarSize,
- config.filmstripGripSize, config.filmstripGripWidth);
- mRootPane.addComponent(mFilmStripView);
- mFilmStripView.setListener(this);
- mFilmStripView.setUserInteractionListener(this);
- mFilmStripView.setFocusIndex(mCurrentIndex);
- mFilmStripView.setStartIndex(mCurrentIndex);
-
mResultIntent.putExtra(KEY_INDEX_HINT, mCurrentIndex);
setStateResult(Activity.RESULT_OK, mResultIntent);
pda.setDataListener(new PhotoDataAdapter.DataListener() {
+ @Override
public void onPhotoChanged(int index, Path item) {
- mFilmStripView.setFocusIndex(index);
+ if (mFilmStripView != null) mFilmStripView.setFocusIndex(index);
mCurrentIndex = index;
mResultIntent.putExtra(KEY_INDEX_HINT, index);
if (item != null) {
@@ -217,11 +222,15 @@ public class PhotoPage extends ActivityState
}
}
-
@Override
public void onLoadingStarted() {
GalleryUtils.setSpinnerVisibility((Activity) mActivity, true);
}
+
+ @Override
+ public void onPhotoAvailable(long version, boolean fullImage) {
+ if (mFilmStripView == null) initFilmStripView();
+ }
});
} else {
// Get default media set by the URI