Example usage for android.animation ArgbEvaluator ArgbEvaluator

List of usage examples for android.animation ArgbEvaluator ArgbEvaluator

Introduction

In this page you can find the example usage for android.animation ArgbEvaluator ArgbEvaluator.

Prototype

ArgbEvaluator

Source Link

Usage

From source file:Main.java

public static void showBackgroundColorAnimation(View view, int preColor, int currColor, int duration) {
    ObjectAnimator localObjectAnimator = ObjectAnimator.ofInt(view, "backgroundColor",
            new int[] { preColor, currColor });
    localObjectAnimator.setDuration(duration);
    localObjectAnimator.setEvaluator(new ArgbEvaluator());
    localObjectAnimator.start();/*from w w w .  j ava  2s  . co m*/
}

From source file:Main.java

public static void animateColorChange(View view, int fromColor, int toColor, int duration,
        Animator.AnimatorListener listener) {
    if (view.getWindowToken() == null) {
        return;/*from w  w  w. j av a2 s  .  c  om*/
    }
    AnimatorSet animation = new AnimatorSet();
    ObjectAnimator colorAnimator = ObjectAnimator.ofInt(view, COLOR_PROPERTY, fromColor, toColor);
    colorAnimator.setEvaluator(new ArgbEvaluator());
    colorAnimator.setDuration(duration);
    if (listener != null)
        animation.addListener(listener);
    animation.play(colorAnimator);
    animation.start();
}

From source file:me.calebjones.spacelaunchnow.utils.Utils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void animateViewColor(View v, int startColor, int endColor) {

    ObjectAnimator animator = ObjectAnimator.ofObject(v, "backgroundColor", new ArgbEvaluator(), startColor,
            endColor);//from  www .  java 2s . c o  m

    animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
    animator.setDuration(COLOR_ANIMATION_DURATION);
    animator.start();
}

From source file:com.awt.supark.LayoutHandler.java

public void appBackgroundColorChange(View view, int time, int r, int g, int b) {
    ColorDrawable wBack = (ColorDrawable) view.getBackground();
    int color = wBack.getColor();
    int r1 = Color.red(color);
    int g1 = Color.green(color);
    int b1 = Color.blue(color);

    ObjectAnimator colorFade = ObjectAnimator.ofObject(view, "backgroundColor", new ArgbEvaluator(),
            Color.argb(255, r1, g1, b1), Color.argb(255, r, g, b));
    colorFade.setDuration(time);/*w  ww  .jav  a  2  s  . c  om*/
    colorFade.start();
}

From source file:io.github.marktony.espresso.ui.onboarding.OnboardingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    if (sp.getBoolean(SettingsUtil.KEY_FIRST_LAUNCH, true)) {

        setContentView(R.layout.activity_onboarding);

        new InitCompaniesDataTask().execute();

        initViews();//  ww  w.j  a  v a2s.c  om

        initData();

        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                int colorUpdate = (Integer) new ArgbEvaluator().evaluate(positionOffset, bgColors[position],
                        bgColors[position == 2 ? position : position + 1]);
                viewPager.setBackgroundColor(colorUpdate);
            }

            @Override
            public void onPageSelected(int position) {
                currentPosition = position;
                updateIndicators(position);
                viewPager.setBackgroundColor(bgColors[position]);
                buttonPre.setVisibility(position == 0 ? View.GONE : View.VISIBLE);
                buttonNext.setVisibility(position == 2 ? View.GONE : View.VISIBLE);
                buttonFinish.setVisibility(position == 2 ? View.VISIBLE : View.GONE);
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

        buttonFinish.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SharedPreferences.Editor ed = sp.edit();
                ed.putBoolean(SettingsUtil.KEY_FIRST_LAUNCH, false);
                ed.apply();
                navigateToMainActivity();
            }
        });

        buttonNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                currentPosition += 1;
                viewPager.setCurrentItem(currentPosition, true);
            }
        });

        buttonPre.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                currentPosition -= 1;
                viewPager.setCurrentItem(currentPosition, true);
            }
        });

    } else {

        navigateToMainActivity();

        finish();
    }

}

From source file:im.ene.ribbon.ActionTabView.java

public ActionTabView(final BottomNavigationView parent, final boolean expanded, final MenuParser.Menu menu) {
    super(parent.getContext());
    this.evaluator = new ArgbEvaluator();
    this.rippleColor = menu.getRippleColor();
    this.textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    this.textDirty = true;
    this.expanded = expanded;
    this.provider = parent.getBadgeProvider();
}

From source file:im.ene.ribbon.TabletActionTabView.java

public TabletActionTabView(final BottomNavigationView parent, boolean expanded, final MenuParser.Menu menu) {
    super(parent, expanded, menu);
    this.evaluator = new ArgbEvaluator();
    final Resources res = getResources();
    this.iconSize = res.getDimensionPixelSize(R.dimen.ribbon_tablet_item_icon_size);
    this.animationDuration = menu.getItemAnimationDuration();
    this.colorActive = menu.getColorActive();
    this.colorInactive = menu.getColorInactive();
}

From source file:com.geecko.QuickLyric.utils.ScreenSlidePagerAdapter.java

@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    View tutorialLayout = mActivity.findViewById(R.id.tutorial_layout);
    ArgbEvaluator evaluator = new ArgbEvaluator();
    Object background = position < getCount() - 1
            ? evaluator.evaluate(positionOffset, mActivity.getResources().getColor(colors[position]),
                    mActivity.getResources().getColor(colors[position + 1]))
            : mActivity.getResources().getColor(colors[position]);
    tutorialLayout.setBackgroundColor((int) background);
    ((MainActivity) mActivity).setNavBarColor(
            (int) evaluator.evaluate(0.5f, mActivity.getResources().getColor(R.color.action_dark), background));
    ((MainActivity) mActivity).setStatusBarColor(
            (int) evaluator.evaluate(0.5f, mActivity.getResources().getColor(R.color.action_dark), background));
}

From source file:com.facebook.react.modules.statusbar.StatusBarModule.java

@ReactMethod
public void setColor(final int color, final boolean animated, final Promise res) {
    final Activity activity = getCurrentActivity();
    if (activity == null) {
        res.reject(ERROR_NO_ACTIVITY, ERROR_NO_ACTIVITY_MESSAGE);
        return;/*from   w ww  . j  a v  a  2  s  . c o m*/
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        UiThreadUtil.runOnUiThread(new Runnable() {
            @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void run() {
                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);
                }
                res.resolve(null);
            }
        });
    } else {
        res.resolve(null);
    }
}

From source file:pl.kodujdlapolski.na4lapy.ui.introduction.IntroductionActivity.java

private void initPageChangeListener() {
    final ArgbEvaluator evaluator = new ArgbEvaluator();
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override//from w  ww . ja va  2  s .  c  om
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            int fromColor = introductionPages.get(position).getBgColor();
            int toColor = introductionPages.get(position + 1).getBgColor();
            int colorUpdate = (Integer) evaluator.evaluate(positionOffset, fromColor, toColor);
            introductionContainer.setBackgroundColor(colorUpdate);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                getWindow().setNavigationBarColor(colorUpdate);
            }
        }

        @Override
        public void onPageSelected(int position) {
            currentPage = position;
            updateIndicators(currentPage);
            if (position == LAST_INTRO) {
                introductionContainer.setBackgroundColor(
                        ContextCompat.getColor(IntroductionActivity.this, android.R.color.transparent));
                nextBtn.setVisibility(View.GONE);
                finishBtn.setVisibility(View.GONE);
                skipBtn.setVisibility(View.GONE);
                onFinish();
            } else {
                boolean lastPage = position == LAST_INTRO - 1;
                nextBtn.setVisibility(lastPage ? View.GONE : View.VISIBLE);
                finishBtn.setVisibility(lastPage ? View.VISIBLE : View.GONE);
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
}