OSDN Git Service

Hide action bar upon filmstrip is off position.
authorAngus Kong <shkong@google.com>
Wed, 26 Feb 2014 07:45:52 +0000 (23:45 -0800)
committerAngus Kong <shkong@google.com>
Wed, 26 Feb 2014 17:44:15 +0000 (09:44 -0800)
bug:13184003
Change-Id: I6ad2bf2c4d0da45764907d819a5d4651a9887209

src/com/android/camera/CameraActivity.java
src/com/android/camera/filmstrip/FilmstripContentPanel.java
src/com/android/camera/widget/FilmstripLayout.java

index 69db899..815640e 100644 (file)
@@ -485,6 +485,11 @@ public class CameraActivity extends Activity
                 }
 
                 @Override
+                public void onSwipeOutBegin() {
+                    mActionBar.hide();
+                }
+
+                @Override
                 public void onFilmstripHidden() {
                     mFilmstripVisible = false;
                     CameraActivity.this.setFilmstripUiVisibility(false);
index 86c1109..c881c18 100644 (file)
@@ -35,6 +35,11 @@ public interface FilmstripContentPanel {
         public void onSwipeOut();
 
         /**
+         * Callback on a swiping out begins.
+         */
+        public void onSwipeOutBegin();
+
+        /**
          * Callback when the filmstrip becomes invisible or gone.
          */
         public void onFilmstripHidden();
index 5918fc0..1172aff 100644 (file)
@@ -311,6 +311,18 @@ public class FilmstripLayout extends FrameLayout implements FilmstripContentPane
         mFilmstripContentTranslationProgress = pixel / getMeasuredWidth();
     }
 
+    private void onSwipeOut() {
+        if (mListener != null) {
+            mListener.onSwipeOut();
+        }
+    }
+
+    private void onSwipeOutBegin() {
+        if (mListener != null) {
+            mListener.onSwipeOutBegin();
+        }
+    }
+
     /**
      * A gesture listener which passes all the gestures to the
      * {@code mFilmstripView} by default and only intercepts scroll gestures
@@ -330,6 +342,9 @@ public class FilmstripLayout extends FrameLayout implements FilmstripContentPane
                 return true;
             }
             mSwipeTrend = (((int) dx) >> 1) + (mSwipeTrend >> 1);
+            if (dx < 0 && mFilmstripContentLayout.getTranslationX() == 0) {
+                FilmstripLayout.this.onSwipeOutBegin();
+            }
             float translate = mFilmstripContentLayout.getTranslationX() - dx;
             if (translate < 0f) {
                 translate = 0f;
@@ -339,6 +354,12 @@ public class FilmstripLayout extends FrameLayout implements FilmstripContentPane
                 }
             }
             translateContentLayoutByPixel(translate);
+            if (translate == 0 && dx > 0) {
+                // This will only happen once since when this condition holds
+                // the onScroll() callback will be forwarded to the filmstrip
+                // view.
+                mFilmstripAnimatorListener.onAnimationEnd(mFilmstripAnimator);
+            }
             mBackgroundDrawable.invalidateSelf();
             return true;
         }
@@ -398,14 +419,13 @@ public class FilmstripLayout extends FrameLayout implements FilmstripContentPane
             }
             if (mSwipeTrend < 0) {
                 hideFilmstrip();
-                if (mListener != null) {
-                    mListener.onSwipeOut();
-                }
+                onSwipeOut();
             } else if (mSwipeTrend > 0) {
                 showFilmstrip();
             } else {
                 if (mFilmstripContentLayout.getTranslationX() >= getMeasuredWidth() / 2) {
                     hideFilmstrip();
+                    onSwipeOut();
                 } else {
                     showFilmstrip();
                 }