diff options
author | Owen Lin <owenlin@google.com> | 2011-08-30 10:38:59 +0800 |
---|---|---|
committer | Owen Lin <owenlin@google.com> | 2011-09-05 11:28:18 +0800 |
commit | ace280a70fd1ead67039b9667d3905c85703c094 (patch) | |
tree | add5ae4895e61f13a9b55c91b9890bb6ecc9a58e /src/com/android/gallery3d/app/PhotoPage.java | |
parent | 9c12d7512df688131384328fb6ffb89b36cc4393 (diff) | |
download | android_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/PhotoPage.java')
-rw-r--r-- | src/com/android/gallery3d/app/PhotoPage.java | 39 |
1 files changed, 24 insertions, 15 deletions
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 |