[Android] Audio player: hide and show the sliding up player on touch event
Adrien Maglo
git at videolan.org
Mon Jan 13 10:02:18 CET 2014
vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Mon Jan 13 10:01:58 2014 +0100| [c1ef38cd5a8459983deea6af7a525248e36cf705] | committer: Adrien Maglo
Audio player: hide and show the sliding up player on touch event
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=c1ef38cd5a8459983deea6af7a525248e36cf705
---
.../org/videolan/vlc/widget/SlidingPaneLayout.java | 31 ++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/widget/SlidingPaneLayout.java b/vlc-android/src/org/videolan/vlc/widget/SlidingPaneLayout.java
index e05f2c1..a682376 100644
--- a/vlc-android/src/org/videolan/vlc/widget/SlidingPaneLayout.java
+++ b/vlc-android/src/org/videolan/vlc/widget/SlidingPaneLayout.java
@@ -504,8 +504,39 @@ public class SlidingPaneLayout extends ViewGroup {
if (!mCanSlide) {
return super.onTouchEvent(ev);
}
+
mDragHelper.processTouchEvent(ev);
+ final int action = ev.getAction();
+
+ switch (action & MotionEventCompat.ACTION_MASK) {
+ case MotionEvent.ACTION_DOWN: {
+ final float x = ev.getX();
+ final float y = ev.getY();
+ mInitialMotionX = x;
+ mInitialMotionY = y;
+ break;
+ }
+
+ case MotionEvent.ACTION_UP: {
+ final float x = ev.getX();
+ final float y = ev.getY();
+ final float dx = x - mInitialMotionX;
+ final float dy = y - mInitialMotionY;
+ final int slop = mDragHelper.getTouchSlop();
+ if (dx * dx + dy * dy < slop * slop &&
+ mDragHelper.isViewUnder(mSlideableView, (int) x, (int) y)) {
+ // Close or open the pane on touch event.
+ if (getState() == STATE_OPENED)
+ closePane();
+ else if (getState() == STATE_CLOSED)
+ openPane();
+ break;
+ }
+ break;
+ }
+ }
+
return true;
}
More information about the Android
mailing list