summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngus Kong <shkong@google.com>2013-08-14 15:24:00 -0700
committerAngus Kong <shkong@google.com>2013-08-14 16:08:43 -0700
commit47721fa8f2dc13cb565ae5629a417dc4ed298e81 (patch)
tree335584a3e83d17f7c4c2fbbb7986832dc51892cd
parent18a29449cf72bb693eb63e30ba2b7e70853c454b (diff)
downloadandroid_packages_apps_Snap-47721fa8f2dc13cb565ae5629a417dc4ed298e81.tar.gz
android_packages_apps_Snap-47721fa8f2dc13cb565ae5629a417dc4ed298e81.tar.bz2
android_packages_apps_Snap-47721fa8f2dc13cb565ae5629a417dc4ed298e81.zip
Make current view center in filmstrip.
bug:10096746 Change-Id: I458a3f1b1a2c78239e1cfaa91d6d5e1cec19507e
-rw-r--r--src/com/android/camera/ui/FilmStripView.java30
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)) {