Flinging back should stop at the first photo first.
bug:10634016
Change-Id: I44e715268b913902a444c977c136d1e0381b3833
diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java
index d20d85e..329540f 100644
--- a/src/com/android/camera/ui/FilmStripView.java
+++ b/src/com/android/camera/ui/FilmStripView.java
@@ -68,6 +68,7 @@
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 @@
setWillNotDraw(false);
mActivity = cameraActivity;
mScale = 1.0f;
+ mStopAtFirstPhoto = true;
mController = new MyController(cameraActivity);
mViewAnimInterpolator = new DecelerateInterpolator();
mZoomView = new ZoomView(cameraActivity);
@@ -885,18 +887,28 @@
return;
}
- if (curr.getId() == 0 && mCenterX < curr.getCenterX()) {
- mCenterX = curr.getCenterX();
- if (mController.isScrolling()) {
- mController.stopScrolling();
+ 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;
}
- }
- if (curr.getId() == mDataAdapter.getTotalNumber() - 1
+ } 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 @@
}
private void layoutViewItems() {
- if (mViewItem[mCurrentItem] == null) {
+ if (mViewItem[mCurrentItem] == null ||
+ mDrawArea.width() == 0 ||
+ mDrawArea.height() == 0) {
return;
}
if (mAnchorPending) {
@@ -1864,6 +1878,9 @@
return;
}
mCenterX += deltaX;
+ if (deltaX > 0) {
+ mStopAtFirstPhoto = true;
+ }
invalidate();
}
@@ -1956,6 +1973,8 @@
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 &&