Search in sources :

Example 26 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project TransitionHelper by ImmortalZ.

the class ColorShowMethod method translate.

@Override
public void translate(InfoBean bean, RenderView parent, View child) {
    if (startColor != 0) {
        startColor = parent.getResources().getColor(startColor);
    } else {
        startColor = parent.getResources().getColor(R.color.showmethod_start_color);
    }
    if (endColor != 0) {
        endColor = parent.getResources().getColor(endColor);
    } else {
        endColor = parent.getResources().getColor(R.color.showmethod_end_color);
    }
    parent.setPaintColor(endColor);
    ObjectAnimator colorAnimator = ObjectAnimator.ofInt(parent, "backgroundColor", startColor, endColor);
    colorAnimator.setEvaluator(new ArgbEvaluator());
    set.playTogether(ObjectAnimator.ofFloat(child, "translationX", 0, -bean.translationX), ObjectAnimator.ofFloat(child, "translationY", 0, -bean.translationY), ObjectAnimator.ofFloat(child, "scaleX", 1 / bean.scalling), ObjectAnimator.ofFloat(child, "scaleY", 1 / bean.scalling), colorAnimator);
    set.setInterpolator(new AccelerateInterpolator());
    set.setDuration(duration).start();
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator)

Example 27 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project AisenWeiBo by wangdan.

the class MaterialSheetAnimation method startColorAnim.

protected void startColorAnim(final View view, final int startColor, final int endColor, long duration, Interpolator interpolator, final AnimationListener listener) {
    // Setup animation
    ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), startColor, endColor);
    anim.setDuration(duration);
    anim.setInterpolator(interpolator);
    // Add listeners
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            if (listener != null) {
                listener.onStart();
            }
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (listener != null) {
                listener.onEnd();
            }
        }
    });
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            // Update background color
            Integer color = (Integer) animator.getAnimatedValue();
            // https://code.google.com/p/android/issues/detail?id=77843
            if (isSupportCardView) {
                // Use setCardBackground() method if it is available
                if (setCardBackgroundColor != null) {
                    try {
                        setCardBackgroundColor.invoke(sheet, color);
                    } catch (Exception e) {
                    // Ignore exceptions since there's no other way set a support CardView's
                    // background color
                    }
                }
            } else // Set background color for all other views
            {
                view.setBackgroundColor(color);
            }
        }
    });
    // Start animation
    anim.start();
}
Also used : SupportAnimator(org.aisen.weibo.sina.ui.widget.io.codetail.animation.SupportAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Example 28 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project TaEmCasa by Dionen.

the class MenuActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.menu_main);
    /* ORGANIZA AS ABAS */
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
    AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
    // clear all scroll flags
    params.setScrollFlags(0);
    /* BOTAO DE NOTIFICAÇÃO */
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View view) {
            Snackbar.make(view, "Tem pessoas interessadas em algumas de suas vagas!", Snackbar.LENGTH_LONG).setAction("Action", null).show();
            animator.setRepeatCount(1);
            Animation fadeout = new AlphaAnimation(1.f, 0.f);
            fadeout.setDuration(500);
            view.startAnimation(fadeout);
            view.postDelayed(new Runnable() {

                @Override
                public void run() {
                    view.setVisibility(View.GONE);
                }
            }, 500);
        }
    });
    /* ANIMAÇÃO DO BOTÃO */
    animator = ObjectAnimator.ofInt(fab, "backgroundTint", Color.rgb(255, 0, 0), Color.rgb(255, 255, 255), Color.rgb(255, 0, 0));
    animator.setDuration(1000);
    animator.setEvaluator(new ArgbEvaluator());
    animator.setInterpolator(new DecelerateInterpolator(2));
    animator.setRepeatCount(Animation.INFINITE);
    animator.addUpdateListener(new ObjectAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            int animatedValue = (int) animation.getAnimatedValue();
            fab.setBackgroundTintList(ColorStateList.valueOf(animatedValue));
        }
    });
    animator.start();
    /* RECEBE OS DADOS DO USUÁRIO */
    Intent intent = getIntent();
    user_id = intent.getStringExtra("user_id");
    user_nome = intent.getStringExtra("nome");
    user_sobrenome = intent.getStringExtra("sobrenome");
    user_email = intent.getStringExtra("email");
    Toast toast = Toast.makeText(MenuActivity.this, "Olá, " + user_nome + " " + user_sobrenome + "!\nSeu ID: " + user_id + "\nSeu email: " + user_email, Toast.LENGTH_LONG);
    toast.show();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator) Intent(android.content.Intent) ValueAnimator(android.animation.ValueAnimator) View(android.view.View) AlphaAnimation(android.view.animation.AlphaAnimation) Toast(android.widget.Toast) TabLayout(android.support.design.widget.TabLayout) Animation(android.view.animation.Animation) AlphaAnimation(android.view.animation.AlphaAnimation) AppBarLayout(android.support.design.widget.AppBarLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 29 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project coursera-android by aporter.

the class ValueAnimatorActivity method startAnimation.

public void startAnimation() {
    final ImageView imageView = (ImageView) findViewById(R.id.image_view);
    ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), RED, BLUE);
    anim.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            imageView.setBackgroundColor((Integer) animation.getAnimatedValue());
        }
    });
    anim.setDuration(10000);
    anim.start();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ImageView(android.widget.ImageView) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator)

Example 30 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project ahbottomnavigation by aurelhubert.

the class AHHelper method updateDrawableColor.

/**
	 * Update image view color with animation
	 */
public static void updateDrawableColor(final Context context, final Drawable drawable, final ImageView imageView, @ColorInt int fromColor, @ColorInt int toColor, final boolean forceTint) {
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
    colorAnimation.setDuration(150);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            imageView.setImageDrawable(AHHelper.getTintDrawable(drawable, (Integer) animator.getAnimatedValue(), forceTint));
            imageView.requestLayout();
        }
    });
    colorAnimation.start();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

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