Skip to content

Commit

Permalink
fix stuck panel after dragging back and forth while opened
Browse files Browse the repository at this point in the history
  • Loading branch information
laplamgor committed Oct 21, 2021
1 parent d53f4c0 commit 0a71fb6
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ public CustomDrawerLayout(@NonNull Context context, @Nullable AttributeSet attrs
setDrawerElevation(0);
}

boolean isClosing = false;

@Override
public boolean dispatchTouchEvent(MotionEvent event) {

if (!this.isDrawerOpen(Gravity.LEFT)) {
isClosing = false;
return super.dispatchTouchEvent(event);
}

Expand All @@ -56,10 +58,18 @@ public boolean dispatchTouchEvent(MotionEvent event) {
}

if (clickedOutside) {
this.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
if (!isClosing) {
this.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
}
return true;
}
this.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
return super.dispatchTouchEvent(event);
}
}

@Override
public void closeDrawer(int gravity) {
isClosing = true;
super.closeDrawer(gravity);
}
}

0 comments on commit 0a71fb6

Please sign in to comment.