public void closeDrawer(boolean fast) { cancelCurrentAnimation(); AnimatorSetProxy animatorSet = new AnimatorSetProxy(); animatorSet.playTogether(ObjectAnimatorProxy.ofFloat(this, "drawerPosition", 0)); animatorSet.setInterpolator(new DecelerateInterpolator()); if (fast) { animatorSet.setDuration( Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * drawerPosition), 50)); } else { animatorSet.setDuration(300); } animatorSet.addListener( new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animator) { onDrawerAnimationEnd(false); } @Override public void onAnimationCancel(Object animator) { onDrawerAnimationEnd(false); } }); animatorSet.start(); }
public void openDrawer(boolean fast) { if (!allowOpenDrawer) { return; } if (AndroidUtilities.isTablet() && parentActionBarLayout != null && parentActionBarLayout.parentActivity != null) { AndroidUtilities.hideKeyboard(parentActionBarLayout.parentActivity.getCurrentFocus()); } cancelCurrentAnimation(); AnimatorSetProxy animatorSet = new AnimatorSetProxy(); animatorSet.playTogether( ObjectAnimatorProxy.ofFloat(this, "drawerPosition", drawerLayout.getMeasuredWidth())); animatorSet.setInterpolator(new DecelerateInterpolator()); if (fast) { animatorSet.setDuration( Math.max( (int) (200.0f / drawerLayout.getMeasuredWidth() * (drawerLayout.getMeasuredWidth() - drawerPosition)), 50)); } else { animatorSet.setDuration(300); } animatorSet.addListener( new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animator) { onDrawerAnimationEnd(true); } @Override public void onAnimationCancel(Object animator) { onDrawerAnimationEnd(true); } }); animatorSet.start(); currentAnimation = animatorSet; }