Search in sources :

Example 41 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 42 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)

Example 43 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project PageIndicatorView by romandanylyk.

the class ColorAnimation method createColorPropertyHolder.

protected PropertyValuesHolder createColorPropertyHolder(boolean isReverse) {
    String propertyName;
    int startColorValue;
    int endColorValue;
    if (isReverse) {
        propertyName = ANIMATION_COLOR_REVERSE;
        startColorValue = endColor;
        endColorValue = startColor;
    } else {
        propertyName = ANIMATION_COLOR;
        startColorValue = startColor;
        endColorValue = endColor;
    }
    PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startColorValue, endColorValue);
    holder.setEvaluator(new ArgbEvaluator());
    return holder;
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) PropertyValuesHolder(android.animation.PropertyValuesHolder)

Example 44 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project Transitions-Everywhere by andkulikov.

the class Recolor method createAnimator.

@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }
    final View view = endValues.view;
    Drawable startBackground = (Drawable) startValues.values.get(PROPNAME_BACKGROUND);
    Drawable endBackground = (Drawable) endValues.values.get(PROPNAME_BACKGROUND);
    ObjectAnimator bgAnimator = null;
    if (startBackground instanceof ColorDrawable && endBackground instanceof ColorDrawable) {
        ColorDrawable startColor = (ColorDrawable) startBackground;
        ColorDrawable endColor = (ColorDrawable) endBackground;
        if (startColor.getColor() != endColor.getColor()) {
            final int finalColor = endColor.getColor();
            endColor.setColor(startColor.getColor());
            bgAnimator = ObjectAnimator.ofInt(endColor, COLORDRAWABLE_COLOR, startColor.getColor(), finalColor);
            bgAnimator.setEvaluator(new ArgbEvaluator());
        }
    }
    ObjectAnimator textColorAnimator = null;
    if (view instanceof TextView) {
        TextView textView = (TextView) view;
        int start = (Integer) startValues.values.get(PROPNAME_TEXT_COLOR);
        int end = (Integer) endValues.values.get(PROPNAME_TEXT_COLOR);
        if (start != end) {
            textView.setTextColor(end);
            textColorAnimator = ObjectAnimator.ofInt(textView, TEXTVIEW_TEXT_COLOR, start, end);
            textColorAnimator.setEvaluator(new ArgbEvaluator());
        }
    }
    return TransitionUtils.mergeAnimators(bgAnimator, textColorAnimator);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 45 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project native-navigation by airbnb.

the class DefaultNavigationImplementation method reconcileStatusBarStyleOnLollipop.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void reconcileStatusBarStyleOnLollipop(final Activity activity, ReadableMap prev, ReadableMap next, boolean firstCall) {
    if (firstCall || numberHasChanged("statusBarColor", prev, next)) {
        boolean animated = false;
        if (next.hasKey("statusBarAnimation")) {
            animated = !("none".equals(next.getString("statusBarAnimation")));
        }
        Integer color = defaults.statusBarColor;
        if (next.hasKey("statusBarColor")) {
            color = next.getInt("statusBarColor");
        }
        if (animated) {
            int curColor = activity.getWindow().getStatusBarColor();
            ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), curColor, color);
            colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(ValueAnimator animator) {
                    activity.getWindow().setStatusBarColor((Integer) animator.getAnimatedValue());
                }
            });
            colorAnimation.setDuration(300).setStartDelay(0);
            colorAnimation.start();
        } else {
            activity.getWindow().setStatusBarColor(color);
        }
    }
    if (firstCall || boolHasChanged("statusBarTranslucent", prev, next)) {
        boolean translucent = defaults.statusBarTranslucent;
        if (next.hasKey("statusBarTranslucent")) {
            translucent = next.getBoolean("statusBarTranslucent");
        }
        View decorView = activity.getWindow().getDecorView();
        // and consume all the top insets so no padding will be added under the status bar.
        if (translucent) {
            decorView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {

                @Override
                public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
                    WindowInsets defaultInsets = v.onApplyWindowInsets(insets);
                    return defaultInsets.replaceSystemWindowInsets(defaultInsets.getSystemWindowInsetLeft(), 0, defaultInsets.getSystemWindowInsetRight(), defaultInsets.getSystemWindowInsetBottom());
                }
            });
        } else {
            decorView.setOnApplyWindowInsetsListener(null);
        }
        ViewCompat.requestApplyInsets(decorView);
    }
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator) BottomNavigationItemView(android.support.design.internal.BottomNavigationItemView) BottomNavigationView(android.support.design.widget.BottomNavigationView) BottomNavigationMenuView(android.support.design.internal.BottomNavigationMenuView) TargetApi(android.annotation.TargetApi)

Aggregations

ArgbEvaluator (android.animation.ArgbEvaluator)58 ValueAnimator (android.animation.ValueAnimator)28 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 SuppressLint (android.annotation.SuppressLint)3 ViewGroup (android.view.ViewGroup)3 AnimatorListener (android.animation.Animator.AnimatorListener)2 AnimatorSet (android.animation.AnimatorSet)2 PropertyValuesHolder (android.animation.PropertyValuesHolder)2 Intent (android.content.Intent)2 Drawable (android.graphics.drawable.Drawable)2 Toolbar (android.support.v7.widget.Toolbar)2