Search in sources :

Example 51 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project MaterialProgressBar by DreaminginCodeZH.

the class ObjectAnimatorCompatBase method ofArgb.

public static <T> ObjectAnimator ofArgb(T target, Property<T, Integer> property, int... values) {
    ObjectAnimator animator = ObjectAnimator.ofInt(target, property, values);
    animator.setEvaluator(new ArgbEvaluator());
    return animator;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator)

Example 52 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project BoomMenu by Nightonke.

the class BoomMenuButton method dimBackground.

private void dimBackground(boolean immediately) {
    createBackground();
    Util.setVisibility(VISIBLE, background);
    AnimationManager.animate(background, "backgroundColor", 0, immediately ? 1 : showDuration + showDelay * (pieces.size() - 1), new ArgbEvaluator(), new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            boomStateEnum = BoomStateEnum.DidShow;
            if (onBoomListener != null)
                onBoomListener.onBoomDidShow();
        }
    }, Color.TRANSPARENT, dimColor);
    if (piecePlaceEnum == PiecePlaceEnum.Share) {
        AnimationManager.animate(shareLinesView, "showProcess", 0, immediately ? 1 : showDuration + showDelay * (pieces.size() - 1), Ease.getInstance(EaseEnum.Linear), 0f, 1f);
    }
}
Also used : Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ArgbEvaluator(android.animation.ArgbEvaluator)

Example 53 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project easy by MehdiBenmesa.

the class MaterialViewPagerAnimator method setColor.

/**
     * Change the color of the statusbackground, toolbar, toolbarlayout and pagertitlestrip
     * With a color transition animation
     *
     * @param color    the final color
     * @param duration the transition color animation duration
     */
void setColor(int color, int duration) {
    final ValueAnimator colorAnim = ObjectAnimator.ofInt(mHeader.headerBackground, "backgroundColor", settings.color, color);
    colorAnim.setEvaluator(new ArgbEvaluator());
    colorAnim.setDuration(duration);
    colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            final int animatedValue = (Integer) animation.getAnimatedValue();
            int colorAlpha = colorWithAlpha(animatedValue, lastPercent);
            mHeader.headerBackground.setBackgroundColor(colorAlpha);
            mHeader.statusBackground.setBackgroundColor(colorAlpha);
            mHeader.toolbar.setBackgroundColor(colorAlpha);
            mHeader.toolbarLayoutBackground.setBackgroundColor(colorAlpha);
            mHeader.mPagerSlidingTabStrip.setBackgroundColor(colorAlpha);
            //set the new color as MaterialViewPager's color
            settings.color = animatedValue;
        }
    });
    colorAnim.start();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Example 54 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project weex-example by KalicyZhou.

the class WXAnimationModule method createAnimator.

@Nullable
private static ObjectAnimator createAnimator(@NonNull WXAnimationBean animation, final View target, final int viewPortWidth) {
    if (target == null) {
        return null;
    }
    WXAnimationBean.Style style = animation.styles;
    if (style != null) {
        ObjectAnimator animator;
        List<PropertyValuesHolder> holders = style.getHolders();
        if (!TextUtils.isEmpty(style.backgroundColor)) {
            BorderDrawable borderDrawable;
            if ((borderDrawable = WXViewUtils.getBorderDrawable(target)) != null) {
                holders.add(PropertyValuesHolder.ofObject(WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(), borderDrawable.getColor(), WXResourceUtils.getColor(style.backgroundColor)));
            } else if (target.getBackground() instanceof ColorDrawable) {
                holders.add(PropertyValuesHolder.ofObject(WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(), ((ColorDrawable) target.getBackground()).getColor(), WXResourceUtils.getColor(style.backgroundColor)));
            }
        }
        if (style.getPivot() != null) {
            Pair<Float, Float> pair = style.getPivot();
            target.setPivotX(pair.first);
            target.setPivotY(pair.second);
        }
        animator = ObjectAnimator.ofPropertyValuesHolder(target, holders.toArray(new PropertyValuesHolder[holders.size()]));
        animator.setStartDelay(animation.delay);
        if (target.getLayoutParams() != null && (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) {
            DimensionUpdateListener listener = new DimensionUpdateListener(target);
            ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
            if (!TextUtils.isEmpty(style.width)) {
                listener.setWidth(layoutParams.width, (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width), viewPortWidth));
            }
            if (!TextUtils.isEmpty(style.height)) {
                listener.setHeight(layoutParams.height, (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height), viewPortWidth));
            }
            animator.addUpdateListener(listener);
        }
        return animator;
    } else {
        return null;
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ViewGroup(android.view.ViewGroup) ArgbEvaluator(android.animation.ArgbEvaluator) BorderDrawable(com.taobao.weex.ui.view.border.BorderDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) PropertyValuesHolder(android.animation.PropertyValuesHolder) Nullable(android.support.annotation.Nullable)

Example 55 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project Slidr by r0adkll.

the class Slidr method attach.

/**
     * Attach a slider mechanism to an activity based on the passed {@link com.r0adkll.slidr.model.SlidrConfig}
     *
     * @param activity      the activity to attach the slider to
     * @param config        the slider configuration to make
     * @return              a {@link com.r0adkll.slidr.model.SlidrInterface} that allows
     *                      the user to lock/unlock the sliding mechanism for whatever purpose.
     */
public static SlidrInterface attach(final Activity activity, final SlidrConfig config) {
    // Setup the slider panel and attach it to the decor
    final SliderPanel panel = initSliderPanel(activity, config);
    // Set the panel slide listener for when it becomes closed or opened
    panel.setOnPanelSlideListener(new SliderPanel.OnPanelSlideListener() {

        private final ArgbEvaluator mEvaluator = new ArgbEvaluator();

        @Override
        public void onStateChanged(int state) {
            if (config.getListener() != null) {
                config.getListener().onSlideStateChanged(state);
            }
        }

        @Override
        public void onClosed() {
            if (config.getListener() != null) {
                config.getListener().onSlideClosed();
            }
            activity.finish();
            activity.overridePendingTransition(0, 0);
        }

        @Override
        public void onOpened() {
            if (config.getListener() != null) {
                config.getListener().onSlideOpened();
            }
        }

        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        @Override
        public void onSlideChange(float percent) {
            // TODO: Add support for KitKat
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && config.areStatusBarColorsValid()) {
                int newColor = (int) mEvaluator.evaluate(percent, config.getPrimaryColor(), config.getSecondaryColor());
                activity.getWindow().setStatusBarColor(newColor);
            }
            if (config.getListener() != null) {
                config.getListener().onSlideChange(percent);
            }
        }
    });
    // Return the lock interface
    return initInterface(panel);
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) SliderPanel(com.r0adkll.slidr.widget.SliderPanel) TargetApi(android.annotation.TargetApi)

Aggregations

ArgbEvaluator (android.animation.ArgbEvaluator)61 ValueAnimator (android.animation.ValueAnimator)30 ObjectAnimator (android.animation.ObjectAnimator)18 Animator (android.animation.Animator)10 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)7 TargetApi (android.annotation.TargetApi)6 View (android.view.View)6 Paint (android.graphics.Paint)5 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)4 TextView (android.widget.TextView)4 PropertyValuesHolder (android.animation.PropertyValuesHolder)3 SuppressLint (android.annotation.SuppressLint)3 ViewGroup (android.view.ViewGroup)3 AnimatorListener (android.animation.Animator.AnimatorListener)2 AnimatorSet (android.animation.AnimatorSet)2 Intent (android.content.Intent)2 Drawable (android.graphics.drawable.Drawable)2 Toolbar (android.support.v7.widget.Toolbar)2