summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngus Kong <shkong@google.com>2013-09-10 23:53:24 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-10 23:53:24 +0000
commit20703f72e087a01e6a589c2875819cf817581a51 (patch)
tree95f72d948f73e32d86c93a7a9195a3ecefc7e1dd
parente1d5ba4fc5470043e8645984e3018b712f5dfcff (diff)
parent5fbe134c3cf1f7c2c82ccef223cab7eb43cd92f1 (diff)
downloadandroid_packages_apps_Snap-20703f72e087a01e6a589c2875819cf817581a51.tar.gz
android_packages_apps_Snap-20703f72e087a01e6a589c2875819cf817581a51.tar.bz2
android_packages_apps_Snap-20703f72e087a01e6a589c2875819cf817581a51.zip
Merge "Flinging back should stop at the first photo first." into gb-ub-photos-carlsbad
-rw-r--r--src/com/android/camera/ui/FilmStripView.java41
1 files changed, 30 insertions, 11 deletions
diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java
index 33437f250..4cf8e9461 100644
--- a/src/com/android/camera/ui/FilmStripView.java
+++ b/src/com/android/camera/ui/FilmStripView.java
@@ -68,6 +68,7 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
private MyController mController;
private int mCenterX = -1;
private ViewItem[] mViewItem = new ViewItem[BUFFER_SIZE];
+ private boolean mStopAtFirstPhoto;
private Listener mListener;
private ZoomView mZoomView = null;
@@ -621,6 +622,7 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
setWillNotDraw(false);
mActivity = cameraActivity;
mScale = 1.0f;
+ mStopAtFirstPhoto = true;
mController = new MyController(cameraActivity);
mViewAnimInterpolator = new DecelerateInterpolator();
mZoomView = new ZoomView(cameraActivity);
@@ -885,18 +887,28 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
return;
}
- if (curr.getId() == 0 && mCenterX < curr.getCenterX()) {
- mCenterX = curr.getCenterX();
- if (mController.isScrolling()) {
- mController.stopScrolling();
- }
- }
- if (curr.getId() == mDataAdapter.getTotalNumber() - 1
+ boolean stopScroll = false;
+ if (mDataAdapter.getTotalNumber() > 1 &&
+ mDataAdapter.getImageData(0).getViewType() ==
+ ImageData.TYPE_STICKY_VIEW &&
+ mStopAtFirstPhoto) {
+ // Stop at the first photo which is the second ViewItem.
+ if (curr.getId() == 1 && mCenterX < curr.getCenterX()) {
+ mStopAtFirstPhoto = false;
+ stopScroll = true;
+ }
+ } else if (curr.getId() == 0 && mCenterX < curr.getCenterX()) {
+ // Stop at the first ViewItem.
+ stopScroll = true;
+ } if (curr.getId() == mDataAdapter.getTotalNumber() - 1
&& mCenterX > curr.getCenterX()) {
+ // Stop at the end.
+ stopScroll = true;
+ }
+
+ if (stopScroll && mController.isScrolling()) {
mCenterX = curr.getCenterX();
- if (!mController.isScrolling()) {
- mController.stopScrolling();
- }
+ mController.stopScrolling();
}
}
@@ -1094,7 +1106,9 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
}
private void layoutViewItems() {
- if (mViewItem[mCurrentItem] == null) {
+ if (mViewItem[mCurrentItem] == null ||
+ mDrawArea.width() == 0 ||
+ mDrawArea.height() == 0) {
return;
}
if (mAnchorPending) {
@@ -1864,6 +1878,9 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
return;
}
mCenterX += deltaX;
+ if (deltaX > 0) {
+ mStopAtFirstPhoto = true;
+ }
invalidate();
}
@@ -1956,6 +1973,8 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
public void goToFilmStrip() {
scaleTo(FILM_STRIP_SCALE, GEOMETRY_ADJUST_TIME_MS);
+ mStopAtFirstPhoto = true;
+
final ViewItem nextItem = mViewItem[mCurrentItem + 1];
if (mViewItem[mCurrentItem].getId() == 0 &&
getCurrentViewType() == ImageData.TYPE_STICKY_VIEW &&