summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ui/FilmStripView.java
diff options
context:
space:
mode:
authorErin Dahlgren <edahlgren@google.com>2013-10-14 23:42:13 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-10-14 23:42:13 +0000
commit831da6132122d9d9a35183ef832994be659c3740 (patch)
tree8f83dd813d79b05d143d2065b490bc3fc1116774 /src/com/android/camera/ui/FilmStripView.java
parent2670f3e45f5818f7c1074b10ef336df30af74583 (diff)
parent3044d8c577432d6e9721fc8b26ac2afbbaf21266 (diff)
downloadandroid_packages_apps_Snap-831da6132122d9d9a35183ef832994be659c3740.tar.gz
android_packages_apps_Snap-831da6132122d9d9a35183ef832994be659c3740.tar.bz2
android_packages_apps_Snap-831da6132122d9d9a35183ef832994be659c3740.zip
Merge "Set camera controls visibility based on whether the camera preview is centered." into gb-ub-photos-carlsbad
Diffstat (limited to 'src/com/android/camera/ui/FilmStripView.java')
-rw-r--r--src/com/android/camera/ui/FilmStripView.java64
1 files changed, 60 insertions, 4 deletions
diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java
index 5de2d7cff..d17567d52 100644
--- a/src/com/android/camera/ui/FilmStripView.java
+++ b/src/com/android/camera/ui/FilmStripView.java
@@ -340,6 +340,27 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
public void onDataFullScreenChange(int dataID, boolean fullScreen);
/**
+ * Called by {@link reload}.
+ */
+ public void onReload();
+
+ /**
+ * Called by {@link checkCurrentDataCentered} when the
+ * data is centered in the film strip.
+ *
+ * @param dataID the ID of the local data
+ */
+ public void onCurrentDataCentered(int dataID);
+
+ /**
+ * Called by {@link checkCurrentDataCentered} when the
+ * data is off centered in the film strip.
+ *
+ * @param dataID the ID of the local data
+ */
+ public void onCurrentDataOffCentered(int dataID);
+
+ /**
* The callback when the item is centered/off-centered.
*
* @param dataID The ID of the image data.
@@ -712,7 +733,7 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
* @param id The id of the data to check.
* @return {@code True} if the data is currently at the center.
*/
- protected boolean isDataAtCenter(int id) {
+ private boolean isDataAtCenter(int id) {
if (mViewItem[mCurrentItem] == null) {
return false;
}
@@ -826,6 +847,7 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
if (nearest == BUFFER_SIZE) {
return -1;
}
+
int min = Math.abs(pointX - mViewItem[nearest].getCenterX());
for (int itemID = nearest + 1; itemID < BUFFER_SIZE && mViewItem[itemID] != null; itemID++) {
@@ -961,10 +983,28 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
if (stopScroll) {
mCenterX = curr.getCenterX();
}
+
return stopScroll;
}
/**
+ * Checks if the item is centered in the film strip, and calls
+ * {@link #onCurrentDataCentered} or {@link #onCurrentDataOffCentered}.
+ * TODO: refactor.
+ *
+ * @param dataID the ID of the image data.
+ */
+ private void checkCurrentDataCentered(int dataID) {
+ if (mListener != null) {
+ if (isDataAtCenter(dataID)) {
+ mListener.onCurrentDataCentered(dataID);
+ } else {
+ mListener.onCurrentDataOffCentered(dataID);
+ }
+ }
+ }
+
+ /**
* Reorders the child views to be consistent with their data ID. This
* method should be called after adding/removing views.
*/
@@ -1688,6 +1728,10 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
return (mScale == FULL_SCREEN_SCALE);
}
+ public boolean isCameraPreview() {
+ return (getCurrentViewType() == ImageData.VIEW_TYPE_STICKY);
+ }
+
public boolean inCameraFullscreen() {
return isDataAtCenter(0) && inFullScreen()
&& (getCurrentViewType() == ImageData.VIEW_TYPE_STICKY);
@@ -1758,7 +1802,10 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
}
newItem.copyGeometry(item);
mViewItem[itemID] = newItem;
- if (clampCenterX()) {
+
+ boolean stopScroll = clampCenterX();
+ checkCurrentDataCentered(getCurrentId());
+ if (stopScroll) {
mController.stopScrolling(true);
}
adjustChildZOrder();
@@ -1883,6 +1930,7 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
invalidate();
if (mListener != null) {
+ mListener.onReload();
mListener.onDataFocusChanged(mViewItem[mCurrentItem].getId(), true);
}
}
@@ -1917,7 +1965,10 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
@Override
public void onScrollUpdate(int currX, int currY) {
mCenterX = currX;
- if (clampCenterX()) {
+
+ boolean stopScroll = clampCenterX();
+ checkCurrentDataCentered(getCurrentId());
+ if (stopScroll) {
mController.stopScrolling(true);
}
invalidate();
@@ -2056,7 +2107,10 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
return;
}
mCenterX += deltaX;
- if (clampCenterX()) {
+
+ boolean stopScroll = clampCenterX();
+ checkCurrentDataCentered(getCurrentId());
+ if (stopScroll) {
mController.stopScrolling(true);
}
invalidate();
@@ -2201,6 +2255,8 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
mCanStopScroll = interruptible;
mScroller.startScroll(mCenterX, 0, position - mCenterX,
0, duration);
+
+ checkCurrentDataCentered(mViewItem[mCurrentItem].getId());
}
@Override