summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui
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/ui
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/ui')
-rw-r--r--src/com/android/gallery3d/ui/AlbumSlidingWindow.java7
-rw-r--r--src/com/android/gallery3d/ui/FilmStripView.java59
-rw-r--r--src/com/android/gallery3d/ui/GLView.java7
3 files changed, 23 insertions, 50 deletions
diff --git a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
index 9e44bd1d2..9b410e9a8 100644
--- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
@@ -24,7 +24,7 @@ import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.Path;
import com.android.gallery3d.util.Future;
import com.android.gallery3d.util.FutureListener;
-import com.android.gallery3d.util.ThreadPool;
+import com.android.gallery3d.util.JobLimiter;
import com.android.gallery3d.util.ThreadPool.Job;
import com.android.gallery3d.util.ThreadPool.JobContext;
@@ -39,6 +39,7 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener {
private static final int MSG_LOAD_BITMAP_DONE = 0;
private static final int MSG_UPDATE_SLOT = 1;
private static final int MIN_THUMB_SIZE = 100;
+ private static final int JOB_LIMIT = 2;
public static interface Listener {
public void onSizeChanged(int size);
@@ -64,7 +65,7 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener {
private SelectionDrawer mSelectionDrawer;
private SynchronizedHandler mHandler;
- private ThreadPool mThreadPool;
+ private JobLimiter mThreadPool;
private int mSlotWidth, mSlotHeight;
private int mActiveRequestCount = 0;
@@ -103,7 +104,7 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener {
}
};
- mThreadPool = activity.getThreadPool();
+ mThreadPool = new JobLimiter(activity.getThreadPool(), JOB_LIMIT);
}
public void setSelectionDrawer(SelectionDrawer drawer) {
diff --git a/src/com/android/gallery3d/ui/FilmStripView.java b/src/com/android/gallery3d/ui/FilmStripView.java
index 8d28f2c7b..c53e1aedf 100644
--- a/src/com/android/gallery3d/ui/FilmStripView.java
+++ b/src/com/android/gallery3d/ui/FilmStripView.java
@@ -18,7 +18,6 @@ package com.android.gallery3d.ui;
import com.android.gallery3d.R;
import com.android.gallery3d.anim.AlphaAnimation;
-import com.android.gallery3d.anim.CanvasAnimation;
import com.android.gallery3d.app.AlbumDataAdapter;
import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.data.MediaSet;
@@ -46,8 +45,6 @@ public class FilmStripView extends GLView implements SlotView.Listener,
private StripDrawer mStripDrawer;
private Listener mListener;
private UserInteractionListener mUIListener;
- private boolean mFilmStripVisible;
- private CanvasAnimation mFilmStripAnimation;
private NinePatchTexture mBackgroundTexture;
// The layout of FileStripView is
@@ -90,7 +87,6 @@ public class FilmStripView extends GLView implements SlotView.Listener,
mAlbumView.setModel(mAlbumDataAdapter);
mBackgroundTexture = new NinePatchTexture(activity.getAndroidContext(),
R.drawable.navstrip_translucent);
- mFilmStripVisible = true;
}
public void setListener(Listener listener) {
@@ -101,25 +97,18 @@ public class FilmStripView extends GLView implements SlotView.Listener,
mUIListener = listener;
}
- private void setFilmStripVisible(boolean visible) {
- if (mFilmStripVisible == visible) return;
- mFilmStripVisible = visible;
- if (!visible) {
- mFilmStripAnimation = new AlphaAnimation(1, 0);
- mFilmStripAnimation.setDuration(HIDE_ANIMATION_DURATION);
- mFilmStripAnimation.start();
- } else {
- mFilmStripAnimation = null;
- }
- invalidate();
- }
-
public void show() {
- setFilmStripVisible(true);
+ if (getVisibility() == GLView.VISIBLE) return;
+ startAnimation(null);
+ setVisibility(GLView.VISIBLE);
}
public void hide() {
- setFilmStripVisible(false);
+ if (getVisibility() == GLView.INVISIBLE) return;
+ AlphaAnimation animation = new AlphaAnimation(1, 0);
+ animation.setDuration(HIDE_ANIMATION_DURATION);
+ startAnimation(animation);
+ setVisibility(GLView.INVISIBLE);
}
@Override
@@ -159,10 +148,6 @@ public class FilmStripView extends GLView implements SlotView.Listener,
@Override
protected boolean dispatchTouchEvent(MotionEvent event) {
- if (!mFilmStripVisible && mFilmStripAnimation == null) {
- return false;
- }
-
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE:
@@ -179,63 +164,49 @@ public class FilmStripView extends GLView implements SlotView.Listener,
@Override
protected void render(GLCanvas canvas) {
- CanvasAnimation anim = mFilmStripAnimation;
- if (anim == null && !mFilmStripVisible) return;
-
- boolean needRestore = false;
- if (anim != null) {
- needRestore = true;
- canvas.save(anim.getCanvasSaveFlags());
- long now = canvas.currentAnimationTimeMillis();
- boolean more = anim.calculate(now);
- anim.apply(canvas);
- if (more) {
- invalidate();
- } else {
- mFilmStripAnimation = null;
- }
- }
-
mBackgroundTexture.draw(canvas, 0, 0, getWidth(), getHeight());
super.render(canvas);
-
- if (needRestore) {
- canvas.restore();
- }
}
// Called by AlbumView
+ @Override
public void onSingleTapUp(int slotIndex) {
mAlbumView.setFocusIndex(slotIndex);
mListener.onSlotSelected(slotIndex);
}
// Called by AlbumView
+ @Override
public void onLongTap(int slotIndex) {
onSingleTapUp(slotIndex);
}
// Called by AlbumView
+ @Override
public void onUserInteractionBegin() {
mUIListener.onUserInteractionBegin();
}
// Called by AlbumView
+ @Override
public void onUserInteractionEnd() {
mUIListener.onUserInteractionEnd();
}
// Called by AlbumView
+ @Override
public void onUserInteraction() {
mUIListener.onUserInteraction();
}
// Called by AlbumView
+ @Override
public void onScrollPositionChanged(int position, int total) {
mScrollBarView.setContentPosition(position, total);
}
// Called by ScrollBarView
+ @Override
public void onScrollBarPositionChanged(int position) {
mAlbumView.setScrollPosition(position);
}
diff --git a/src/com/android/gallery3d/ui/GLView.java b/src/com/android/gallery3d/ui/GLView.java
index c59327831..7491a6ffb 100644
--- a/src/com/android/gallery3d/ui/GLView.java
+++ b/src/com/android/gallery3d/ui/GLView.java
@@ -76,10 +76,11 @@ public class GLView {
public void startAnimation(CanvasAnimation animation) {
GLRoot root = getGLRoot();
if (root == null) throw new IllegalStateException();
-
mAnimation = animation;
- mAnimation.start();
- root.registerLaunchedAnimation(mAnimation);
+ if (mAnimation != null) {
+ mAnimation.start();
+ root.registerLaunchedAnimation(mAnimation);
+ }
invalidate();
}