@@ -41,10 +41,10 @@ public class DraggableView extends RelativeLayout {
41
41
private static final int ZERO = 0 ;
42
42
private static final int DEFAULT_SCALE_FACTOR = 2 ;
43
43
private static final float DEFAULT_TOP_VIEW_HEIGHT = -1 ;
44
- private static final int DEFAULT_TOP_FRAGMENT_MARGIN = 30 ;
44
+ private static final int DEFAULT_TOP_VIEW_MARGIN = 30 ;
45
45
private static final float SLIDE_TOP = 0f ;
46
46
private static final float SLIDE_BOTTOM = 1f ;
47
- private static final boolean DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFECT = true ;
47
+ private static final boolean DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFFECT = true ;
48
48
private static final int ONE_HUNDRED = 100 ;
49
49
private static final float SENSITIVITY = 1f ;
50
50
@@ -56,8 +56,8 @@ public class DraggableView extends RelativeLayout {
56
56
57
57
private float xScaleFactor = DEFAULT_SCALE_FACTOR ;
58
58
private float yScaleFactor = DEFAULT_SCALE_FACTOR ;
59
- private float topFragmentMarginRight = DEFAULT_TOP_FRAGMENT_MARGIN ;
60
- private float topFragmentMarginBottom = DEFAULT_TOP_FRAGMENT_MARGIN ;
59
+ private float topViewMarginRight = DEFAULT_TOP_VIEW_MARGIN ;
60
+ private float topViewMarginBottom = DEFAULT_TOP_VIEW_MARGIN ;
61
61
private float topViewHeight = DEFAULT_TOP_VIEW_HEIGHT ;
62
62
private boolean enableHorizontalAlphaEffect ;
63
63
private int dragViewId ;
@@ -108,7 +108,7 @@ public void setYTopViewScaleFactor(float yScaleFactor) {
108
108
* @param topFragmentMarginRight in pixels.
109
109
*/
110
110
public void setTopViewMarginRight (float topFragmentMarginRight ) {
111
- this .topFragmentMarginRight = topFragmentMarginRight ;
111
+ this .topViewMarginRight = topFragmentMarginRight ;
112
112
}
113
113
114
114
/**
@@ -117,7 +117,7 @@ public void setTopViewMarginRight(float topFragmentMarginRight) {
117
117
* @param topFragmentMarginBottom
118
118
*/
119
119
public void setTopViewMarginBottom (float topFragmentMarginBottom ) {
120
- this .topFragmentMarginBottom = topFragmentMarginBottom ;
120
+ this .topViewMarginBottom = topFragmentMarginBottom ;
121
121
}
122
122
123
123
/**
@@ -201,7 +201,7 @@ public void closeToLeft() {
201
201
}
202
202
203
203
/**
204
- * Checks if the top Fragment is minimized.
204
+ * Checks if the top view is minimized.
205
205
*
206
206
* @return true if the view is minimized.
207
207
*/
@@ -210,7 +210,7 @@ public boolean isMinimized() {
210
210
}
211
211
212
212
/**
213
- * Checks if the top Fragment is maximized.
213
+ * Checks if the top view is maximized.
214
214
*
215
215
* @return true if the view is maximized.
216
216
*/
@@ -219,7 +219,7 @@ public boolean isMaximized() {
219
219
}
220
220
221
221
/**
222
- * Checks if the top Fragment closed at the right place.
222
+ * Checks if the top view closed at the right place.
223
223
*
224
224
* @return true if the view is closed at right.
225
225
*/
@@ -228,14 +228,23 @@ public boolean isClosedAtRight() {
228
228
}
229
229
230
230
/**
231
- * Checks if the top Fragment is closed at the left place.
231
+ * Checks if the top view is closed at the left place.
232
232
*
233
233
* @return true if the view is closed at left.
234
234
*/
235
235
public boolean isClosedAtLeft () {
236
236
return dragView .getRight () <= 0 ;
237
237
}
238
238
239
+ /**
240
+ * Checks if the top view is closed at the right or left place.
241
+ *
242
+ * @return true if the view is closed.
243
+ */
244
+ public boolean isClosed () {
245
+ return isClosedAtLeft () || isClosedAtRight ();
246
+ }
247
+
239
248
/**
240
249
* Override method to intercept only touch events over the drag view and to cancel the drag when the action
241
250
* associated to the MotionEvent is equals to ACTION_CANCEL or ACTION_UP.
@@ -264,7 +273,9 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
264
273
@ Override
265
274
public boolean onTouchEvent (MotionEvent ev ) {
266
275
viewDragHelper .processTouchEvent (ev );
267
-
276
+ if (isClosed ()) {
277
+ return false ;
278
+ }
268
279
boolean isDragViewHit = isViewHit (dragView , (int ) ev .getX (), (int ) ev .getY ());
269
280
boolean isSecondViewHit = isViewHit (secondView , (int ) ev .getX (), (int ) ev .getY ());
270
281
if (isMaximized ()) {
@@ -505,9 +516,9 @@ private void initializeAttributes(AttributeSet attrs) {
505
516
this .topViewHeight = attributes .getDimension (R .styleable .draggable_view_top_view_height , DEFAULT_TOP_VIEW_HEIGHT );
506
517
this .xScaleFactor = attributes .getFloat (R .styleable .draggable_view_top_view_x_scale_factor , DEFAULT_SCALE_FACTOR );
507
518
this .yScaleFactor = attributes .getFloat (R .styleable .draggable_view_top_view_y_scale_factor , DEFAULT_SCALE_FACTOR );
508
- this .topFragmentMarginRight = attributes .getDimension (R .styleable .draggable_view_top_view_margin_right , DEFAULT_TOP_FRAGMENT_MARGIN );
509
- this .topFragmentMarginBottom = attributes .getDimension (R .styleable .draggable_view_top_view_margin_bottom , DEFAULT_TOP_FRAGMENT_MARGIN );
510
- this .enableHorizontalAlphaEffect = attributes .getBoolean (R .styleable .draggable_view_enable_minimized_horizontal_alpha_effect , DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFECT );
519
+ this .topViewMarginRight = attributes .getDimension (R .styleable .draggable_view_top_view_margin_right , DEFAULT_TOP_VIEW_MARGIN );
520
+ this .topViewMarginBottom = attributes .getDimension (R .styleable .draggable_view_top_view_margin_bottom , DEFAULT_TOP_VIEW_MARGIN );
521
+ this .enableHorizontalAlphaEffect = attributes .getBoolean (R .styleable .draggable_view_enable_minimized_horizontal_alpha_effect , DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFFECT );
511
522
attributes .recycle ();
512
523
513
524
}
@@ -534,14 +545,14 @@ private boolean smoothSlideTo(float slideOffset) {
534
545
* @return configured dragged view margin right configured.
535
546
*/
536
547
private float getDragViewMarginRight () {
537
- return topFragmentMarginRight ;
548
+ return topViewMarginRight ;
538
549
}
539
550
540
551
/**
541
552
* @return configured dragged view margin bottom.
542
553
*/
543
554
private float getDragViewMarginBottom () {
544
- return topFragmentMarginBottom ;
555
+ return topViewMarginBottom ;
545
556
}
546
557
547
558
/**
0 commit comments