Search in sources :

Example 61 with AnimatorUpdateListener

use of android.animation.ValueAnimator.AnimatorUpdateListener in project remusic by aa112901.

the class SwipeRefreshLayout method animatorFooterToBottom.

/**
     * 松手之后,使用动画将Footer从距离start变化到end
     *
     * @param start
     * @param end
     */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void animatorFooterToBottom(int start, final int end) {
    ValueAnimator valueAnimator = ValueAnimator.ofInt(start, end);
    valueAnimator.setDuration(150);
    valueAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            // update
            pushDistance = (Integer) valueAnimator.getAnimatedValue();
            updateFooterViewPosition();
        }
    });
    valueAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (end > 0 && mOnPushLoadMoreListener != null) {
                // start loading more
                mLoadMore = true;
                mOnPushLoadMoreListener.onLoadMore();
            } else {
                resetTargetLayout();
                mLoadMore = false;
            }
        }
    });
    valueAnimator.setInterpolator(mDecelerateInterpolator);
    valueAnimator.start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) TargetApi(android.annotation.TargetApi)

Example 62 with AnimatorUpdateListener

use of android.animation.ValueAnimator.AnimatorUpdateListener in project Xposed-Tinted-Status-Bar by MohammadAG.

the class OverlayDrawable method setOverrideColor.

public void setOverrideColor(final int color) {
    int animateFrom;
    final int animateTo;
    if (mOverrideColor != -3) {
        animateFrom = mOverrideColor;
    } else {
        animateFrom = mColor;
    }
    if (color == -3) {
        animateTo = mColor;
    } else {
        animateTo = color;
    }
    if (mAnimator != null && mAnimator.isRunning()) {
        mAnimator.cancel();
        animateFrom = mOverrideColor;
        mAnimator = null;
    }
    mAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), animateFrom, animateTo);
    mAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            mOverrideColor = (Integer) animator.getAnimatedValue();
            invalidateSelf();
        }
    });
    mAnimator.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (color == -3) {
                mOverrideColor = -3;
                mColor = animateTo;
                invalidateSelf();
            }
            mAnimator = null;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }
    });
    mAnimator.start();
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) ArgbEvaluator(android.animation.ArgbEvaluator) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) Paint(android.graphics.Paint)

Example 63 with AnimatorUpdateListener

use of android.animation.ValueAnimator.AnimatorUpdateListener in project Xposed-Tinted-Status-Bar by MohammadAG.

the class ColourChangerMod method setStatusBarTint.

@SuppressLint("NewApi")
public void setStatusBarTint(final int tintColor) {
    if (mStatusBarView == null)
        return;
    log("Setting statusbar color to " + tintColor);
    if (mSettingsHelper.animateStatusBarTintChange()) {
        int animateFrom = mLastSetColor == KITKAT_TRANSPARENT_COLOR ? Color.TRANSPARENT : mLastSetColor;
        int animateTo = tintColor == KITKAT_TRANSPARENT_COLOR ? Color.TRANSPARENT : tintColor;
        ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), animateFrom, animateTo);
        colorAnimation.addUpdateListener(new AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                mGradientDrawable.setColor((Integer) animator.getAnimatedValue());
            }
        });
        Utils.setViewBackground(mStatusBarView, mGradientDrawable);
        colorAnimation.start();
    } else {
        mStatusBarView.setAlpha(1f);
        if (tintColor == KITKAT_TRANSPARENT_COLOR) {
            Utils.setViewBackground(mStatusBarView, mGradientDrawable);
            mGradientDrawable.setColor(Color.TRANSPARENT);
        } else {
            Utils.setViewBackground(mStatusBarView, mGradientDrawable);
            mGradientDrawable.setColor(tintColor);
        }
    }
    mGradientDrawable.setMode(mSettingsHelper.getOverlayMode(), mSettingsHelper.getSemiTransparentOverlayOpacity());
    mGradientDrawable.setIsTransparentCauseOfKitKatApi(tintColor == KITKAT_TRANSPARENT_COLOR && mSettingsHelper.isLegacyGradientMode());
    mLastSetColor = tintColor;
    if (mSettingsHelper.shouldLinkStatusBarAndNavBar() && !mKeyboardUp) {
        mNavigationBarTint = tintColor;
        setNavigationBarTint(tintColor, true);
    }
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) SuppressLint(android.annotation.SuppressLint) Tint(com.mohammadag.colouredstatusbar.SettingsHelper.Tint) SuppressLint(android.annotation.SuppressLint)

Example 64 with AnimatorUpdateListener

use of android.animation.ValueAnimator.AnimatorUpdateListener in project AndroidChromium by JackyAndroid.

the class ToolbarPhone method onPrimaryColorChanged.

@Override
protected void onPrimaryColorChanged(boolean shouldAnimate) {
    super.onPrimaryColorChanged(shouldAnimate);
    if (mBrandColorTransitionActive)
        mBrandColorTransitionAnimation.cancel();
    final int initialColor = mToolbarBackground.getColor();
    final int finalColor = getToolbarDataProvider().getPrimaryColor();
    if (initialColor == finalColor)
        return;
    if (!isVisualStateValidForBrandColorTransition(mVisualState))
        return;
    if (!shouldAnimate) {
        updateToolbarBackground(finalColor);
        return;
    }
    boolean shouldUseOpaque = ColorUtils.shouldUseOpaqueTextboxBackground(finalColor);
    final int initialAlpha = mLocationBarBackgroundAlpha;
    final int finalAlpha = shouldUseOpaque ? 255 : LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA;
    final boolean shouldAnimateAlpha = initialAlpha != finalAlpha;
    mBrandColorTransitionAnimation = ValueAnimator.ofFloat(0, 1).setDuration(THEME_COLOR_TRANSITION_DURATION);
    mBrandColorTransitionAnimation.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
    mBrandColorTransitionAnimation.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float fraction = animation.getAnimatedFraction();
            if (shouldAnimateAlpha) {
                mLocationBarBackgroundAlpha = (int) (MathUtils.interpolate(initialAlpha, finalAlpha, fraction));
            }
            updateToolbarBackground(ColorUtils.getColorWithOverlay(initialColor, finalColor, fraction));
        }
    });
    mBrandColorTransitionAnimation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mBrandColorTransitionActive = false;
            updateVisualsForToolbarState();
        }
    });
    mBrandColorTransitionAnimation.start();
    mBrandColorTransitionActive = true;
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 65 with AnimatorUpdateListener

use of android.animation.ValueAnimator.AnimatorUpdateListener in project android_frameworks_base by ParanoidAndroid.

the class SwipeHelper method snapChild.

public void snapChild(final View view, float velocity) {
    final View animView = mCallback.getChildContentView(view);
    final boolean canAnimViewBeDismissed = mCallback.canChildBeDismissed(animView);
    ObjectAnimator anim = createTranslationAnimation(animView, 0);
    int duration = SNAP_ANIM_LEN;
    anim.setDuration(duration);
    anim.addUpdateListener(new AnimatorUpdateListener() {

        public void onAnimationUpdate(ValueAnimator animation) {
            updateAlphaFromOffset(animView, canAnimViewBeDismissed);
        }
    });
    anim.addListener(new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator animator) {
            updateAlphaFromOffset(animView, canAnimViewBeDismissed);
        }
    });
    anim.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) View(android.view.View)

Aggregations

AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)94 ValueAnimator (android.animation.ValueAnimator)88 Animator (android.animation.Animator)65 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)62 ObjectAnimator (android.animation.ObjectAnimator)31 TimeInterpolator (android.animation.TimeInterpolator)14 View (android.view.View)13 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)12 Interpolator (android.view.animation.Interpolator)12 Resources (android.content.res.Resources)9 SuppressLint (android.annotation.SuppressLint)8 AnimatorSet (android.animation.AnimatorSet)7 Rect (android.graphics.Rect)7 ImageView (android.widget.ImageView)7 PropertyValuesHolder (android.animation.PropertyValuesHolder)6 AppWidgetHostView (android.appwidget.AppWidgetHostView)6 Point (android.graphics.Point)6 PointF (android.graphics.PointF)6 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)6 TextView (android.widget.TextView)6