use of androidx.customview.widget.ViewDragHelper in project Slide by ccrama.
the class MainActivity method setDrawerEdge.
/**
* Set the drawer edge (i.e. how sensitive the drawer is) Based on a given screen width
* percentage.
*
* @param displayWidthPercentage larger the value, the more sensitive the drawer swipe is;
* percentage of screen width
* @param drawerLayout drawerLayout to adjust the swipe edge
*/
private static void setDrawerEdge(Activity activity, final float displayWidthPercentage, DrawerLayout drawerLayout) {
try {
Field mDragger = drawerLayout.getClass().getSuperclass().getDeclaredField("mLeftDragger");
mDragger.setAccessible(true);
ViewDragHelper leftDragger = (ViewDragHelper) mDragger.get(drawerLayout);
Field mEdgeSize = leftDragger.getClass().getDeclaredField("mEdgeSize");
mEdgeSize.setAccessible(true);
final int currentEdgeSize = mEdgeSize.getInt(leftDragger);
Point displaySize = new Point();
activity.getWindowManager().getDefaultDisplay().getSize(displaySize);
mEdgeSize.setInt(leftDragger, Math.max(currentEdgeSize, (int) (displaySize.x * displayWidthPercentage)));
} catch (Exception e) {
LogUtil.e(e + ": Exception thrown while changing navdrawer edge size");
}
}
Aggregations