Example usage for android.animation ValueAnimator removeAllUpdateListeners

List of usage examples for android.animation ValueAnimator removeAllUpdateListeners

Introduction

In this page you can find the example usage for android.animation ValueAnimator removeAllUpdateListeners.

Prototype

public void removeAllUpdateListeners() 

Source Link

Document

Removes all listeners from the set listening to frame updates for this animation.

Usage

From source file:Main.java

public static void cancelWithoutListenersNotified(ValueAnimator animator) {
    animator.removeAllUpdateListeners();
    animator.removeAllListeners();//  w  ww  .  j  av a2 s . co  m
    animator.cancel();
}

From source file:com.velli.passwordmanager.ActivityMain.java

public boolean lockDrawer(final boolean lock, boolean animate) {
    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    boolean locked = isDrawerLocked();

    if (drawer != null && lock != locked) {
        if (lock) {
            drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        } else {/*from  w w w  .  ja  v a2 s  .co  m*/
            drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
            if (!animate) {
                initDrawer();
            }
        }

        if (animate) {
            final ValueAnimator anim = ValueAnimator.ofFloat(lock ? 0 : 1, lock ? 1 : 0);
            anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    float slideOffset = (Float) valueAnimator.getAnimatedValue();
                    mToolbarDrawerToggle.onDrawerSlide(drawer, slideOffset);
                }
            });
            anim.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    anim.removeAllUpdateListeners();
                    if (!lock) {
                        initDrawer();
                    }
                    animation.removeAllListeners();
                }
            });
            anim.setInterpolator(new DecelerateInterpolator());
            anim.setDuration(500);
            anim.start();
        } else {
            mToolbarDrawerToggle.onDrawerSlide(drawer, lock ? 1 : 0);

        }
        return true;
    }
    return false;
}