@@ -70,6 +70,7 @@ public class SwipeLayout extends FrameLayout {
7070 private boolean mRightSwipeEnabled = true ;
7171 private boolean mTopSwipeEnabled = true ;
7272 private boolean mBottomSwipeEnabled = true ;
73+ private boolean mClickToClose = true ;
7374
7475 public static enum DragEdge {
7576 Left ,
@@ -104,6 +105,7 @@ public SwipeLayout(Context context, AttributeSet attrs, int defStyle) {
104105 mRightEdgeSwipeOffset = a .getDimension (R .styleable .SwipeLayout_rightEdgeSwipeOffset , 0 );
105106 mTopEdgeSwipeOffset = a .getDimension (R .styleable .SwipeLayout_topEdgeSwipeOffset , 0 );
106107 mBottomEdgeSwipeOffset = a .getDimension (R .styleable .SwipeLayout_bottomEdgeSwipeOffset , 0 );
108+ setClickToClose (a .getBoolean (R .styleable .SwipeLayout_clickToClose , mClickToClose ));
107109
108110 mDragEdges = new ArrayList <DragEdge >();
109111 if ((dragEdgeChoices & DRAG_LEFT ) == DRAG_LEFT ) {
@@ -881,6 +883,13 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
881883 if (!isSwipeEnabled ()) {
882884 return false ;
883885 }
886+ if (mClickToClose && getOpenStatus () == Status .Open && getSurfaceView ()!=null ){
887+ Rect rect = new Rect ();
888+ getSurfaceView ().getHitRect (rect );
889+ if (rect .contains ((int )ev .getX (), (int )ev .getY ())){
890+ return true ;
891+ }
892+ }
884893 for (SwipeDenier denier : mSwipeDeniers ) {
885894 if (denier != null && denier .shouldDenySwipe (ev )) {
886895 return false ;
@@ -970,6 +979,13 @@ public boolean onTouchEvent(MotionEvent event) {
970979
971980 return super .onTouchEvent (event ) || mIsBeingDragged || action == MotionEvent .ACTION_DOWN ;
972981 }
982+ public boolean isClickToClose () {
983+ return mClickToClose ;
984+ }
985+
986+ public void setClickToClose (boolean mClickToClose ) {
987+ this .mClickToClose = mClickToClose ;
988+ }
973989
974990 public void setSwipeEnabled (boolean enabled ) {
975991 mSwipeEnabled = enabled ;
@@ -1102,6 +1118,13 @@ public void setOnLongClickListener(OnLongClickListener l) {
11021118 private GestureDetector gestureDetector = new GestureDetector (getContext (), new SwipeDetector ());
11031119
11041120 class SwipeDetector extends GestureDetector .SimpleOnGestureListener {
1121+ @ Override
1122+ public boolean onSingleTapUp (MotionEvent e ) {
1123+ if (mClickToClose ){
1124+ close ();
1125+ }
1126+ return super .onSingleTapUp (e );
1127+ }
11051128 @ Override
11061129 public boolean onDoubleTap (MotionEvent e ) {
11071130 if (mDoubleClickListener != null ) {
0 commit comments