diff options
author | Angus Kong <shkong@google.com> | 2013-08-14 23:10:46 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-08-14 23:10:51 +0000 |
commit | 0689254ef810c502c65852a7c54bf902e975b38a (patch) | |
tree | 53fa222fd0639b75a96837f67dbd3c5b006cc503 | |
parent | 92ae10ec320405d07c85a9e80be40293c65d85e0 (diff) | |
parent | 47721fa8f2dc13cb565ae5629a417dc4ed298e81 (diff) | |
download | android_packages_apps_Snap-0689254ef810c502c65852a7c54bf902e975b38a.tar.gz android_packages_apps_Snap-0689254ef810c502c65852a7c54bf902e975b38a.tar.bz2 android_packages_apps_Snap-0689254ef810c502c65852a7c54bf902e975b38a.zip |
Merge "Make current view center in filmstrip." into gb-ub-photos-carlsbad
-rw-r--r-- | src/com/android/camera/ui/FilmStripView.java | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java index d99a4fcf5..d6bfe3718 100644 --- a/src/com/android/camera/ui/FilmStripView.java +++ b/src/com/android/camera/ui/FilmStripView.java @@ -78,6 +78,9 @@ public class FilmStripView extends ViewGroup { // mCenterX accordingly. private boolean mAnchorPending; + // This is true if and only if the user is scrolling, + private boolean mIsUserScrolling; + /** * Common interface for all images in the filmstrip. */ @@ -712,11 +715,6 @@ public class FilmStripView extends ViewGroup { if (mController.isScrolling()) { mController.stopScrolling(); } - if (getCurrentViewType() == ImageData.TYPE_STICKY_VIEW - && !mController.isScalling() - && mScale != FULLSCREEN_SCALE) { - mController.gotoFullScreen(); - } } if (curr.getID() == mDataAdapter.getTotalNumber() - 1 && mCenterX > curr.getCenterX()) { @@ -799,6 +797,23 @@ public class FilmStripView extends ViewGroup { }); } + private void snapInCenter() { + ViewInfo currentInfo = mViewInfo[mCurrentInfo]; + if (currentInfo == null || mController.isScrolling() || mIsUserScrolling) { + return; + } + int currentViewCenter = currentInfo.getCenterX(); + if (mCenterX != currentViewCenter) { + mController.scrollTo(currentViewCenter, + DURATION_GEOMETRY_ADJUST, false); + } + if (getCurrentViewType() == ImageData.TYPE_STICKY_VIEW + && !mController.isScalling() + && mScale != FULLSCREEN_SCALE) { + mController.gotoFullScreen(); + } + } + private void layoutChildren() { if (mViewInfo[mCurrentInfo] == null) { return; @@ -869,6 +884,7 @@ public class FilmStripView extends ViewGroup { stepIfNeeded(); adjustChildZOrder(); + snapInCenter(); invalidate(); updatePhotoSphereViewButton(); mLastItemId = getCurrentId(); @@ -1554,6 +1570,7 @@ public class FilmStripView extends ViewGroup { lockAtCurrentView(); } else if (inFilmStrip()) { unlockPosition(); + snapInCenter(); } } } @@ -1615,6 +1632,7 @@ public class FilmStripView extends ViewGroup { @Override public boolean onUp(float x, float y) { float halfH = getHeight() / 2; + mIsUserScrolling = false; for (int i = 0; i < BUFFER_SIZE; i++) { if (mViewInfo[i] == null) { continue; @@ -1642,6 +1660,7 @@ public class FilmStripView extends ViewGroup { .start(); } } + snapInCenter(); return false; } @@ -1650,6 +1669,7 @@ public class FilmStripView extends ViewGroup { if (mViewInfo[mCurrentInfo] == null) { return false; } + mIsUserScrolling = true; int deltaX = (int) (dx / mScale); if (inFilmStrip()) { if (Math.abs(dx) > Math.abs(dy)) { |