From 4f0fcfc9d6cd00104689861f4c96421c6ed54d76 Mon Sep 17 00:00:00 2001 From: pedrovgs Date: Sat, 26 Apr 2014 13:39:32 +0200 Subject: [PATCH 1/3] Fix phantom scroll effect. If the view is closed the touch event should be ignored. --- .../com/github/pedrovgs/DraggableView.java | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/draggablepanel/src/main/java/com/github/pedrovgs/DraggableView.java b/draggablepanel/src/main/java/com/github/pedrovgs/DraggableView.java index c7dee5a..fc8c279 100644 --- a/draggablepanel/src/main/java/com/github/pedrovgs/DraggableView.java +++ b/draggablepanel/src/main/java/com/github/pedrovgs/DraggableView.java @@ -41,10 +41,10 @@ public class DraggableView extends RelativeLayout { private static final int ZERO = 0; private static final int DEFAULT_SCALE_FACTOR = 2; private static final float DEFAULT_TOP_VIEW_HEIGHT = -1; - private static final int DEFAULT_TOP_FRAGMENT_MARGIN = 30; + private static final int DEFAULT_TOP_VIEW_MARGIN = 30; private static final float SLIDE_TOP = 0f; private static final float SLIDE_BOTTOM = 1f; - private static final boolean DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFECT = true; + private static final boolean DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFFECT = true; private static final int ONE_HUNDRED = 100; private static final float SENSITIVITY = 1f; @@ -56,8 +56,8 @@ public class DraggableView extends RelativeLayout { private float xScaleFactor = DEFAULT_SCALE_FACTOR; private float yScaleFactor = DEFAULT_SCALE_FACTOR; - private float topFragmentMarginRight = DEFAULT_TOP_FRAGMENT_MARGIN; - private float topFragmentMarginBottom = DEFAULT_TOP_FRAGMENT_MARGIN; + private float topViewMarginRight = DEFAULT_TOP_VIEW_MARGIN; + private float topViewMarginBottom = DEFAULT_TOP_VIEW_MARGIN; private float topViewHeight = DEFAULT_TOP_VIEW_HEIGHT; private boolean enableHorizontalAlphaEffect; private int dragViewId; @@ -108,7 +108,7 @@ public void setYTopViewScaleFactor(float yScaleFactor) { * @param topFragmentMarginRight in pixels. */ public void setTopViewMarginRight(float topFragmentMarginRight) { - this.topFragmentMarginRight = topFragmentMarginRight; + this.topViewMarginRight = topFragmentMarginRight; } /** @@ -117,7 +117,7 @@ public void setTopViewMarginRight(float topFragmentMarginRight) { * @param topFragmentMarginBottom */ public void setTopViewMarginBottom(float topFragmentMarginBottom) { - this.topFragmentMarginBottom = topFragmentMarginBottom; + this.topViewMarginBottom = topFragmentMarginBottom; } /** @@ -201,7 +201,7 @@ public void closeToLeft() { } /** - * Checks if the top Fragment is minimized. + * Checks if the top view is minimized. * * @return true if the view is minimized. */ @@ -210,7 +210,7 @@ public boolean isMinimized() { } /** - * Checks if the top Fragment is maximized. + * Checks if the top view is maximized. * * @return true if the view is maximized. */ @@ -219,7 +219,7 @@ public boolean isMaximized() { } /** - * Checks if the top Fragment closed at the right place. + * Checks if the top view closed at the right place. * * @return true if the view is closed at right. */ @@ -228,7 +228,7 @@ public boolean isClosedAtRight() { } /** - * Checks if the top Fragment is closed at the left place. + * Checks if the top view is closed at the left place. * * @return true if the view is closed at left. */ @@ -236,6 +236,15 @@ public boolean isClosedAtLeft() { return dragView.getRight() <= 0; } + /** + * Checks if the top view is closed at the right or left place. + * + * @return true if the view is closed. + */ + public boolean isClosed() { + return isClosedAtLeft() || isClosedAtRight(); + } + /** * Override method to intercept only touch events over the drag view and to cancel the drag when the action * associated to the MotionEvent is equals to ACTION_CANCEL or ACTION_UP. @@ -264,7 +273,9 @@ public boolean onInterceptTouchEvent(MotionEvent ev) { @Override public boolean onTouchEvent(MotionEvent ev) { viewDragHelper.processTouchEvent(ev); - + if (isClosed()) { + return false; + } boolean isDragViewHit = isViewHit(dragView, (int) ev.getX(), (int) ev.getY()); boolean isSecondViewHit = isViewHit(secondView, (int) ev.getX(), (int) ev.getY()); if (isMaximized()) { @@ -505,9 +516,9 @@ private void initializeAttributes(AttributeSet attrs) { this.topViewHeight = attributes.getDimension(R.styleable.draggable_view_top_view_height, DEFAULT_TOP_VIEW_HEIGHT); this.xScaleFactor = attributes.getFloat(R.styleable.draggable_view_top_view_x_scale_factor, DEFAULT_SCALE_FACTOR); this.yScaleFactor = attributes.getFloat(R.styleable.draggable_view_top_view_y_scale_factor, DEFAULT_SCALE_FACTOR); - this.topFragmentMarginRight = attributes.getDimension(R.styleable.draggable_view_top_view_margin_right, DEFAULT_TOP_FRAGMENT_MARGIN); - this.topFragmentMarginBottom = attributes.getDimension(R.styleable.draggable_view_top_view_margin_bottom, DEFAULT_TOP_FRAGMENT_MARGIN); - this.enableHorizontalAlphaEffect = attributes.getBoolean(R.styleable.draggable_view_enable_minimized_horizontal_alpha_effect, DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFECT); + this.topViewMarginRight = attributes.getDimension(R.styleable.draggable_view_top_view_margin_right, DEFAULT_TOP_VIEW_MARGIN); + this.topViewMarginBottom = attributes.getDimension(R.styleable.draggable_view_top_view_margin_bottom, DEFAULT_TOP_VIEW_MARGIN); + this.enableHorizontalAlphaEffect = attributes.getBoolean(R.styleable.draggable_view_enable_minimized_horizontal_alpha_effect, DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFFECT); attributes.recycle(); } @@ -534,14 +545,14 @@ private boolean smoothSlideTo(float slideOffset) { * @return configured dragged view margin right configured. */ private float getDragViewMarginRight() { - return topFragmentMarginRight; + return topViewMarginRight; } /** * @return configured dragged view margin bottom. */ private float getDragViewMarginBottom() { - return topFragmentMarginBottom; + return topViewMarginBottom; } /** From 33a6e548ff35513f68f763db175254d6371745b3 Mon Sep 17 00:00:00 2001 From: pedrovgs Date: Sat, 26 Apr 2014 13:47:02 +0200 Subject: [PATCH 2/3] Increment release version number --- draggablepanel/pom.xml | 7 ++++--- gradle.properties | 2 +- pom.xml | 7 ++++--- sample/pom.xml | 7 ++++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/draggablepanel/pom.xml b/draggablepanel/pom.xml index 9df3553..c7c3bc3 100755 --- a/draggablepanel/pom.xml +++ b/draggablepanel/pom.xml @@ -1,15 +1,16 @@ - + 4.0.0 com.github.pedrovgs draggablepanel-parent - 1.0.2-SNAPSHOT + 1.0.3 draggablepanel - 1.0.3-SNAPSHOT + 1.0.3 apklib DRAGGABLE PANEL - LIBRARY diff --git a/gradle.properties b/gradle.properties index 2ebff52..1ec2d55 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.0.3-SNAPSHOT +VERSION_NAME=1.0.3 VERSION_CODE=2 GROUP=com.github.pedrovgs diff --git a/pom.xml b/pom.xml index a3e6510..af91df2 100755 --- a/pom.xml +++ b/pom.xml @@ -1,10 +1,11 @@ - + 4.0.0 com.github.pedrovgs draggablepanel-parent - 1.0.2-SNAPSHOT + 1.0.3 pom @@ -137,7 +138,7 @@ google-play-services-jar 7 - + com.actionbarsherlock actionbarsherlock diff --git a/sample/pom.xml b/sample/pom.xml index 4d20e45..d230a45 100755 --- a/sample/pom.xml +++ b/sample/pom.xml @@ -1,15 +1,16 @@ - + 4.0.0 com.github.pedrovgs draggablepanel-parent - 1.0.2-SNAPSHOT + 1.0.3 sample - 1.0.2-SNAPSHOT + 1.0.3 apk DRAGGABLE PANEL - SAMPLE From 6e87c62e058d44c6f783a6da155d64b79778b8c8 Mon Sep 17 00:00:00 2001 From: pedrovgs Date: Sat, 26 Apr 2014 13:52:58 +0200 Subject: [PATCH 3/3] Modify version numbers to snapshot version 1.0.4 --- draggablepanel/pom.xml | 4 ++-- gradle.properties | 4 ++-- pom.xml | 2 +- sample/pom.xml | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/draggablepanel/pom.xml b/draggablepanel/pom.xml index c7c3bc3..cbdb9fd 100755 --- a/draggablepanel/pom.xml +++ b/draggablepanel/pom.xml @@ -6,11 +6,11 @@ com.github.pedrovgs draggablepanel-parent - 1.0.3 + 1.0.4-SNAPSHOT draggablepanel - 1.0.3 + 1.0.4-SNAPSHOT apklib DRAGGABLE PANEL - LIBRARY diff --git a/gradle.properties b/gradle.properties index 1ec2d55..007608c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ -VERSION_NAME=1.0.3 -VERSION_CODE=2 +VERSION_NAME=1.0.4-SNAPSHOT +VERSION_CODE=4 GROUP=com.github.pedrovgs POM_DESCRIPTION=Android library created to create a draggable user interface similar to the last YouTube draggable video component. diff --git a/pom.xml b/pom.xml index af91df2..791cd9c 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.github.pedrovgs draggablepanel-parent - 1.0.3 + 1.0.4-SNAPSHOT pom diff --git a/sample/pom.xml b/sample/pom.xml index d230a45..6be79bc 100755 --- a/sample/pom.xml +++ b/sample/pom.xml @@ -6,11 +6,11 @@ com.github.pedrovgs draggablepanel-parent - 1.0.3 + 1.0.4-SNAPSHOT sample - 1.0.3 + 1.0.4-SNAPSHOT apk DRAGGABLE PANEL - SAMPLE