Example usage for android.support.v4.view ViewPropertyAnimatorCompat setUpdateListener

List of usage examples for android.support.v4.view ViewPropertyAnimatorCompat setUpdateListener

Introduction

In this page you can find the example usage for android.support.v4.view ViewPropertyAnimatorCompat setUpdateListener.

Prototype

public ViewPropertyAnimatorCompat setUpdateListener(
            ViewPropertyAnimatorUpdateListener viewPropertyAnimatorUpdateListener) 

Source Link

Usage

From source file:android.support.v7.app.WindowDecorActionBar.java

public void doHide(boolean fromSystem) {
    if (mCurrentShowAnim != null) {
        mCurrentShowAnim.cancel();//from ww  w . j av a2 s .c o  m
    }

    if (mCurWindowVisibility == View.VISIBLE && ALLOW_SHOW_HIDE_ANIMATIONS
            && (mShowHideAnimationEnabled || fromSystem)) {
        ViewCompat.setAlpha(mContainerView, 1f);
        mContainerView.setTransitioning(true);
        ViewPropertyAnimatorCompatSet anim = new ViewPropertyAnimatorCompatSet();
        float endingY = -mContainerView.getHeight();
        if (fromSystem) {
            int topLeft[] = { 0, 0 };
            mContainerView.getLocationInWindow(topLeft);
            endingY -= topLeft[1];
        }
        ViewPropertyAnimatorCompat a = ViewCompat.animate(mContainerView).translationY(endingY);
        a.setUpdateListener(mUpdateListener);
        anim.play(a);
        if (mContentAnimations && mContentView != null) {
            anim.play(ViewCompat.animate(mContentView).translationY(endingY));
        }
        anim.setInterpolator(sHideInterpolator);
        anim.setDuration(250);
        anim.setListener(mHideListener);
        mCurrentShowAnim = anim;
        anim.start();
    } else {
        mHideListener.onAnimationEnd(null);
    }
}

From source file:android.support.v7.internal.app.WindowDecorActionBar.java

public void doHide(boolean fromSystem) {
    if (mCurrentShowAnim != null) {
        mCurrentShowAnim.cancel();/*from   w ww  .  j  av a2s .c om*/
    }

    if (mCurWindowVisibility == View.VISIBLE && ALLOW_SHOW_HIDE_ANIMATIONS
            && (mShowHideAnimationEnabled || fromSystem)) {
        ViewCompat.setAlpha(mContainerView, 1f);
        mContainerView.setTransitioning(true);
        ViewPropertyAnimatorCompatSet anim = new ViewPropertyAnimatorCompatSet();
        float endingY = -mContainerView.getHeight();
        if (fromSystem) {
            int topLeft[] = { 0, 0 };
            mContainerView.getLocationInWindow(topLeft);
            endingY -= topLeft[1];
        }
        ViewPropertyAnimatorCompat a = ViewCompat.animate(mContainerView).translationY(endingY);
        a.setUpdateListener(mUpdateListener);
        anim.play(a);
        if (mContentAnimations && mContentView != null) {
            anim.play(ViewCompat.animate(mContentView).translationY(endingY));
        }
        if (mSplitView != null && mSplitView.getVisibility() == View.VISIBLE) {
            ViewCompat.setAlpha(mSplitView, 1f);
            anim.play(ViewCompat.animate(mSplitView).translationY(mSplitView.getHeight()));
        }
        anim.setInterpolator(AnimationUtils.loadInterpolator(mContext, android.R.anim.accelerate_interpolator));
        anim.setDuration(250);
        anim.setListener(mHideListener);
        mCurrentShowAnim = anim;
        anim.start();
    } else {
        mHideListener.onAnimationEnd(null);
    }
}

From source file:android.support.v7.app.WindowDecorActionBar.java

public void doShow(boolean fromSystem) {
    if (mCurrentShowAnim != null) {
        mCurrentShowAnim.cancel();//from w  w  w. j  av a  2s.co  m
    }
    mContainerView.setVisibility(View.VISIBLE);

    if (mCurWindowVisibility == View.VISIBLE && ALLOW_SHOW_HIDE_ANIMATIONS
            && (mShowHideAnimationEnabled || fromSystem)) {
        // because we're about to ask its window loc
        ViewCompat.setTranslationY(mContainerView, 0f);
        float startingY = -mContainerView.getHeight();
        if (fromSystem) {
            int topLeft[] = { 0, 0 };
            mContainerView.getLocationInWindow(topLeft);
            startingY -= topLeft[1];
        }
        ViewCompat.setTranslationY(mContainerView, startingY);
        ViewPropertyAnimatorCompatSet anim = new ViewPropertyAnimatorCompatSet();
        ViewPropertyAnimatorCompat a = ViewCompat.animate(mContainerView).translationY(0f);
        a.setUpdateListener(mUpdateListener);
        anim.play(a);
        if (mContentAnimations && mContentView != null) {
            ViewCompat.setTranslationY(mContentView, startingY);
            anim.play(ViewCompat.animate(mContentView).translationY(0f));
        }
        anim.setInterpolator(sShowInterpolator);
        anim.setDuration(250);
        // If this is being shown from the system, add a small delay.
        // This is because we will also be animating in the status bar,
        // and these two elements can't be done in lock-step.  So we give
        // a little time for the status bar to start its animation before
        // the action bar animates.  (This corresponds to the corresponding
        // case when hiding, where the status bar has a small delay before
        // starting.)
        anim.setListener(mShowListener);
        mCurrentShowAnim = anim;
        anim.start();
    } else {
        ViewCompat.setAlpha(mContainerView, 1f);
        ViewCompat.setTranslationY(mContainerView, 0);
        if (mContentAnimations && mContentView != null) {
            ViewCompat.setTranslationY(mContentView, 0);
        }
        mShowListener.onAnimationEnd(null);
    }
    if (mOverlayLayout != null) {
        ViewCompat.requestApplyInsets(mOverlayLayout);
    }
}

From source file:android.support.v7.internal.app.WindowDecorActionBar.java

public void doShow(boolean fromSystem) {
    if (mCurrentShowAnim != null) {
        mCurrentShowAnim.cancel();//from   w  ww  .  j av  a 2  s  .co  m
    }
    mContainerView.setVisibility(View.VISIBLE);

    if (mCurWindowVisibility == View.VISIBLE && ALLOW_SHOW_HIDE_ANIMATIONS
            && (mShowHideAnimationEnabled || fromSystem)) {
        // because we're about to ask its window loc
        ViewCompat.setTranslationY(mContainerView, 0f);
        float startingY = -mContainerView.getHeight();
        if (fromSystem) {
            int topLeft[] = { 0, 0 };
            mContainerView.getLocationInWindow(topLeft);
            startingY -= topLeft[1];
        }
        ViewCompat.setTranslationY(mContainerView, startingY);
        ViewPropertyAnimatorCompatSet anim = new ViewPropertyAnimatorCompatSet();
        ViewPropertyAnimatorCompat a = ViewCompat.animate(mContainerView).translationY(0f);
        a.setUpdateListener(mUpdateListener);
        anim.play(a);
        if (mContentAnimations && mContentView != null) {
            ViewCompat.setTranslationY(mContentView, startingY);
            anim.play(ViewCompat.animate(mContentView).translationY(0f));
        }
        if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
            ViewCompat.setTranslationY(mSplitView, mSplitView.getHeight());
            mSplitView.setVisibility(View.VISIBLE);
            anim.play(ViewCompat.animate(mSplitView).translationY(0f));
        }
        anim.setInterpolator(AnimationUtils.loadInterpolator(mContext, android.R.anim.decelerate_interpolator));
        anim.setDuration(250);
        // If this is being shown from the system, add a small delay.
        // This is because we will also be animating in the status bar,
        // and these two elements can't be done in lock-step.  So we give
        // a little time for the status bar to start its animation before
        // the action bar animates.  (This corresponds to the corresponding
        // case when hiding, where the status bar has a small delay before
        // starting.)
        anim.setListener(mShowListener);
        mCurrentShowAnim = anim;
        anim.start();
    } else {
        ViewCompat.setAlpha(mContainerView, 1f);
        ViewCompat.setTranslationY(mContainerView, 0);
        if (mContentAnimations && mContentView != null) {
            ViewCompat.setTranslationY(mContentView, 0);
        }
        if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
            ViewCompat.setAlpha(mSplitView, 1f);
            ViewCompat.setTranslationY(mSplitView, 0);
            mSplitView.setVisibility(View.VISIBLE);
        }
        mShowListener.onAnimationEnd(null);
    }
    if (mOverlayLayout != null) {
        ViewCompat.requestApplyInsets(mOverlayLayout);
    }
}