summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2012-05-21 17:24:45 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-05-21 17:24:45 -0700
commitb8ab1f5676cd93e11f4afd4ced7032ab92bf3f31 (patch)
treea77d339654deb54d4d933026e583b8a14ba6a3cb /src
parent52973767f43e7f7e3637cbd31e1c52c3285a2522 (diff)
parentfb14073b494ee6ead2538641d04ad8177b433001 (diff)
downloadandroid_packages_apps_Snap-b8ab1f5676cd93e11f4afd4ced7032ab92bf3f31.tar.gz
android_packages_apps_Snap-b8ab1f5676cd93e11f4afd4ced7032ab92bf3f31.tar.bz2
android_packages_apps_Snap-b8ab1f5676cd93e11f4afd4ced7032ab92bf3f31.zip
Merge "Fix capture animation if we are far away from the camera preview." into jb-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/ui/PhotoView.java35
-rw-r--r--src/com/android/gallery3d/ui/PositionController.java24
2 files changed, 42 insertions, 17 deletions
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index e7ec3a948..fd08e0eb3 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -973,21 +973,15 @@ public class PhotoView extends GLView {
@Override
protected void render(GLCanvas canvas) {
- float filmRatio = mPositionController.getFilmRatio();
-
- // Draw next photos. In page mode, we draw only one next photo.
- int lastPhoto = (filmRatio == 0f) ? 1 : SCREEN_NAIL_MAX;
- for (int i = lastPhoto; i > 0; i--) {
- Rect r = mPositionController.getPosition(i);
- mPictures.get(i).draw(canvas, r);
- }
-
- // Draw current photo
- mPictures.get(0).draw(canvas, mPositionController.getPosition(0));
-
- // Draw previous photos. In page mode, we draw only one previous photo.
- lastPhoto = (filmRatio == 0f) ? -1: -SCREEN_NAIL_MAX;
- for (int i = -1; i >= lastPhoto; i--) {
+ // In page mode, we draw only one previous/next photo. But if we are
+ // doing capture animation, we want to draw all photos.
+ boolean inPageMode = (mPositionController.getFilmRatio() == 0f);
+ boolean inCaptureAnimation = ((mHolding & HOLD_CAPTURE_ANIMATION) != 0);
+ boolean drawOneNeighborOnly = inPageMode && !inCaptureAnimation;
+ int neighbors = drawOneNeighborOnly ? 1 : SCREEN_NAIL_MAX;
+
+ // Draw photos from back to front
+ for (int i = neighbors; i >= -neighbors; i--) {
Rect r = mPositionController.getPosition(i);
mPictures.get(i).draw(canvas, r);
}
@@ -1191,6 +1185,17 @@ public class PhotoView extends GLView {
mPositionController.startCaptureAnimationSlide(-1);
} else if (offset == -1) {
if (mPrevBound >= 0) return false;
+ if (mFilmMode) setFilmMode(false);
+
+ // If we are too far away from the first image (so that we don't
+ // have all the ScreenNails in-between), we go directly without
+ // animation.
+ if (mModel.getCurrentIndex() > SCREEN_NAIL_MAX) {
+ switchToFirstImage();
+ mPositionController.skipAnimation();
+ return true;
+ }
+
switchToFirstImage();
mPositionController.startCaptureAnimationSlide(1);
} else {
diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java
index 226826da7..bb2b83ecb 100644
--- a/src/com/android/gallery3d/ui/PositionController.java
+++ b/src/com/android/gallery3d/ui/PositionController.java
@@ -34,7 +34,7 @@ class PositionController {
public static final int IMAGE_AT_TOP_EDGE = 4;
public static final int IMAGE_AT_BOTTOM_EDGE = 8;
- public static final int CAPTURE_ANIMATION_TIME = 600;
+ public static final int CAPTURE_ANIMATION_TIME = 700;
// Special values for animation time.
private static final long NO_ANIMATION = -1;
@@ -960,7 +960,27 @@ class PositionController {
}
}
- // 8. offset the Platform position
+ // 8. calculate the new absolute X coordinates for those box before
+ // first or after last.
+ for (int i = first - 1; i >= -BOX_MAX; i--) {
+ Box a = mBoxes.get(i + 1);
+ Box b = mBoxes.get(i);
+ int wa = widthOf(a);
+ int wb = widthOf(b);
+ Gap g = mGaps.get(i);
+ b.mAbsoluteX = a.mAbsoluteX - wa / 2 - (wb - wb / 2) - g.mCurrentGap;
+ }
+
+ for (int i = last + 1; i <= BOX_MAX; i++) {
+ Box a = mBoxes.get(i - 1);
+ Box b = mBoxes.get(i);
+ int wa = widthOf(a);
+ int wb = widthOf(b);
+ Gap g = mGaps.get(i - 1);
+ b.mAbsoluteX = a.mAbsoluteX + (wa - wa / 2) + wb / 2 + g.mCurrentGap;
+ }
+
+ // 9. offset the Platform position
int dx = mBoxes.get(0).mAbsoluteX - mPlatform.mCurrentX;
mPlatform.mCurrentX += dx;
mPlatform.mFromX += dx;