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:sg.fxl.topekaport.QuizActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void prepareCircularReveal(View startView, FrameLayout targetView) {
    int centerX = (startView.getLeft() + startView.getRight()) / 2;
    // Subtract the start view's height to adjust for relative coordinates on screen.
    int centerY = (startView.getTop() + startView.getBottom()) / 2 - startView.getHeight();
    float endRadius = (float) Math.hypot((double) centerX, (double) centerY);
    circularReveal = ViewAnimationUtils.createCircularReveal(targetView, centerX, centerY, startView.getWidth(),
            endRadius);//from w w  w  . j a  va  2s  .com
    circularReveal.setInterpolator(new FastOutLinearInInterpolator());

    circularReveal.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            icon.setVisibility(View.GONE);
            circularReveal.removeListener(this);
        }
    });
    // Adding a color animation from the FAB's color to transparent creates a dissolve like
    // effect to the circular reveal.
    int accentColor = ContextCompat.getColor(this, quiz.getTheme().getAccentColor());
    colorChange = ObjectAnimator.ofInt(targetView, ViewUtils.FOREGROUND_COLOR, accentColor, Color.TRANSPARENT);
    colorChange.setEvaluator(new ArgbEvaluator());
    colorChange.setInterpolator(interpolator);
}

From source file:springindicator.SpringIndicator.java

@SuppressLint("NewApi")
private void createIndicatorColorAnim() {
    indicatorColorAnim = ObjectAnimator.ofInt(springView, "indicatorColor", indicatorColorArray);
    indicatorColorAnim.setEvaluator(new ArgbEvaluator());
    indicatorColorAnim.setDuration(INDICATOR_ANIM_DURATION);
}

From source file:com.google.samples.apps.topeka.view.quiz.QuizActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void prepareCircularReveal(View startView, FrameLayout targetView, int themeAccentColor) {
    int centerX = (startView.getLeft() + startView.getRight()) / 2;
    // Subtract the start view's height to adjust for relative coordinates on screen.
    int centerY = (startView.getTop() + startView.getBottom()) / 2 - startView.getHeight();
    float endRadius = (float) Math.hypot(centerX, centerY);
    mCircularReveal = ViewAnimationUtils.createCircularReveal(targetView, centerX, centerY,
            startView.getWidth(), endRadius);
    mCircularReveal.setInterpolator(new FastOutLinearInInterpolator());

    mCircularReveal.addListener(new AnimatorListenerAdapter() {
        @Override//  ww  w  .  j av a 2s.c  o m
        public void onAnimationEnd(Animator animation) {
            mIcon.setVisibility(View.GONE);
            mCircularReveal.removeListener(this);
        }
    });
    // Adding a color animation from the FAB's color to transparent creates a dissolve like
    // effect to the circular reveal.
    mColorChange = ObjectAnimator.ofInt(targetView, ViewUtils.FOREGROUND_COLOR, themeAccentColor,
            Color.TRANSPARENT);
    mColorChange.setEvaluator(new ArgbEvaluator());
    mColorChange.setInterpolator(mInterpolator);
}

From source file:ca.zadrox.dota2esportticker.ui.TeamDetailActivity.java

private void createCompatReveal() {
    mHeaderTeamLogo.setVisibility(View.VISIBLE);
    mHeaderTeamLogo.setImageBitmap(mTeam.logo);

    mHeaderTeamLogo.setTranslationY(-UIUtils.calculateActionBarSize(this) - mHeaderTeamLogo.getHeight());

    mHeaderTeamLogo.animate().translationY(0).setDuration(100)
            .setInterpolator(new AccelerateDecelerateInterpolator())
            .setListener(new Animator.AnimatorListener() {
                @Override/*from w ww.  j a v  a 2 s.c o m*/
                public void onAnimationStart(Animator animation) {

                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    mHeaderTeamName.animate().alpha(1).setDuration(150)
                            .setInterpolator(new AccelerateDecelerateInterpolator()).start();

                    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
                            getResources().getColor(R.color.theme_primary),
                            mTeam.palette.getDarkVibrantColor(getResources().getColor(R.color.theme_primary)));

                    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        @Override
                        public void onAnimationUpdate(ValueAnimator animator) {
                            mHeaderBox.setBackgroundColor((Integer) animator.getAnimatedValue());
                        }

                    });

                    colorAnimation.setDuration(150);
                    colorAnimation.start();
                }

                @Override
                public void onAnimationCancel(Animator animation) {

                }

                @Override
                public void onAnimationRepeat(Animator animation) {

                }
            }).start();
}

From source file:com.ltf.mytoolslibrary.viewbase.viewPagerGuidanceActivityMyLib.SpringIndicator.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void createIndicatorColorAnim() {
    indicatorColorAnim = ObjectAnimator.ofInt(springView, "indicatorColor", indicatorColorArray);
    indicatorColorAnim.setEvaluator(new ArgbEvaluator());
    indicatorColorAnim.setDuration(INDICATOR_ANIM_DURATION);
}

From source file:com.geecko.QuickLyric.adapter.IntroScreenSlidePagerAdapter.java

@SuppressWarnings({ "deprecation", "ResourceAsColor" })
@Override//ww  w.j  a  va 2  s. c  o  m
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.setNavBarColor(mActivity.getWindow(), mActivity.getTheme(),
            (int) evaluator.evaluate(0.5f, mActivity.getResources().getColor(R.color.action_dark), background));
    MainActivity.setStatusBarColor(mActivity.getWindow(), mActivity.getTheme(),
            (int) evaluator.evaluate(0.5f, mActivity.getResources().getColor(R.color.action_dark), background));

    View bigFab = tutorialLayout.findViewById(R.id.big_fab);
    View handImage = tutorialLayout.findViewById(R.id.musicid_demo_hand_image);
    View soundImage = tutorialLayout.findViewById(R.id.musicid_demo_sound_image);
    View redKey = tutorialLayout.findViewById(R.id.intro_4_red_key);
    View yellowKey = tutorialLayout.findViewById(R.id.intro_4_yellow_key);
    View gearA = tutorialLayout.findViewById(R.id.redGear);
    View gearB = tutorialLayout.findViewById(R.id.blueGear);

    BubblePopImageView tableImageView = (BubblePopImageView) tutorialLayout.findViewById(R.id.table);
    position = rightToLeft ? getCount() - 1 - position : position;
    if (rightToLeft && positionOffset > 0.0) {
        position -= 1;
        positionOffset = 1f - positionOffset;
        positionOffsetPixels = (int) (positionOffset * mPager.getWidth());
    }

    switch (position) {
    case 0:
        if (tableImageView != null) {
            tableImageView.setProgress(positionOffset);
            tableImageView.setTranslationX((rightToLeft ? -1f : 1f) * (1f - positionOffset)
                    * (tableImageView.getMeasuredWidth() / 3f));
        }
        break;
    case 1:
        if (tableImageView != null) {
            tableImageView.setProgress(1f);
            tableImageView.setTranslationX((rightToLeft ? 0.15f : -0.4f) * positionOffsetPixels);
        }
        if (bigFab != null) {
            bigFab.setTranslationX(
                    (rightToLeft ? -1f : 1f) * (1f - positionOffset) * (bigFab.getMeasuredWidth() / 3f));
            if (mCurrentPage == 1 ^ rightToLeft)
                bigFab.setRotation(positionOffset * 360f);
            else
                bigFab.setRotation((1f - positionOffset) * 360f);
        }
        break;
    case 2:
        if (bigFab != null)
            ((View) bigFab.getParent()).setTranslationX((!rightToLeft ? -0.4f : 0.4f) * positionOffsetPixels);
        if (soundImage != null && handImage != null) {
            soundImage.setTranslationX(300f - 300f * positionOffset);
            handImage.setTranslationX(-400f + 400f * positionOffset);
        }
        break;
    case 3:
        if (redKey != null && yellowKey != null) {
            if (redKey.getMeasuredHeight() < redKey.getResources().getDimensionPixelSize(R.dimen.dp) * 15) {
                redKey.setVisibility(View.INVISIBLE);
                yellowKey.setVisibility(View.INVISIBLE);
                break;
            } else {
                redKey.setVisibility(View.VISIBLE);
                yellowKey.setVisibility(View.VISIBLE);
            }
            redKey.setTranslationY(330f * (1 - positionOffset));
            yellowKey.setTranslationY(290f * Math.min(1.3f * (1 - positionOffset), 1.0f));
            yellowKey.setTranslationX(105f * Math.min(1.3f * (1 - positionOffset), 1.0f));
        }
        if (3 == count - 2 && gearA != null && gearB != null) {
            gearA.setRotation(-180f * positionOffset);
            gearB.setRotation(180f * positionOffset);
        }
        break;
    case 4:
        if (gearA != null && gearB != null) {
            gearA.setRotation(-180f * positionOffset);
            gearB.setRotation(180f * positionOffset);
        }
        break;
    }
}

From source file:com.google.samples.apps.topeka.widget.quiz.AbsQuizView.java

private void animateForegroundColor(@ColorInt final int targetColor) {
    ObjectAnimator animator = ObjectAnimator.ofInt(this, ViewUtils.FOREGROUND_COLOR, Color.TRANSPARENT,
            targetColor);//ww w.java2 s  .  c om
    animator.setEvaluator(new ArgbEvaluator());
    animator.setStartDelay(FOREGROUND_COLOR_CHANGE_DELAY);
    animator.start();
}

From source file:com.musenkishi.atelier.Atelier.java

private static void applyColorToView(final ImageView imageView, int color, boolean fromCache,
        boolean shouldMask) {
    if (fromCache) {
        if (shouldMask) {
            if (imageView.getDrawable() != null) {
                imageView.getDrawable().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
            } else if (imageView.getBackground() != null) {
                imageView.getBackground().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
            }//from  w ww.  j  a  v  a2 s  .  c o m
        } else {
            imageView.setBackgroundColor(color);
        }
    } else {
        if (shouldMask) {
            Integer colorFrom;
            ValueAnimator.AnimatorUpdateListener imageAnimatorUpdateListener = new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    if (imageView.getDrawable() != null) {
                        imageView.getDrawable().mutate().setColorFilter(
                                (Integer) valueAnimator.getAnimatedValue(), PorterDuff.Mode.MULTIPLY);
                    } else if (imageView.getBackground() != null) {
                        imageView.getBackground().mutate().setColorFilter(
                                (Integer) valueAnimator.getAnimatedValue(), PorterDuff.Mode.MULTIPLY);
                    }
                }
            };
            ValueAnimator.AnimatorUpdateListener animatorUpdateListener;

            PaletteTag paletteTag = (PaletteTag) imageView.getTag(viewTagKey);
            animatorUpdateListener = imageAnimatorUpdateListener;
            colorFrom = paletteTag.getColor();
            imageView.setTag(viewTagKey, new PaletteTag(paletteTag.getId(), color));

            Integer colorTo = color;
            ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
            colorAnimation.addUpdateListener(animatorUpdateListener);
            colorAnimation.setDuration(300);
            colorAnimation.start();
        } else {
            Drawable preDrawable;

            if (imageView.getBackground() == null) {
                preDrawable = new ColorDrawable(Color.TRANSPARENT);
            } else {
                preDrawable = imageView.getBackground();
            }

            TransitionDrawable transitionDrawable = new TransitionDrawable(
                    new Drawable[] { preDrawable, new ColorDrawable(color) });
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                imageView.setBackground(transitionDrawable);
            } else {
                imageView.setBackgroundDrawable(transitionDrawable);
            }
            transitionDrawable.startTransition(300);
        }
    }
}

From source file:com.jmstudios.redmoon.presenter.ScreenFilterPresenter.java

private void animateShadesColor(int toColor) {
    cancelRunningAnimator(mColorAnimator);

    int fromColor = mView.getColorTempProgress();

    mColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
    mColorAnimator.setDuration(FADE_DURATION_MS);
    mColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/*ww  w .  ja  v a2 s . c  o  m*/
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mView.setColorTempProgress((Integer) valueAnimator.getAnimatedValue());
        }
    });

    mColorAnimator.start();
}

From source file:com.advaitaworld.widgets.SlidingTabLayout.java

private void updateTitleColors(int prevSelectedPosition, int newSelectedPosition) {
    if (mSelectedTabColor == 0 && mDefaultTabColor == 0) {
        return;/*from w  w w . ja v  a 2s .c  o  m*/
    }
    View tabViewPrev = mTabStrip.getChildAt(prevSelectedPosition);
    View tabViewNew = mTabStrip.getChildAt(newSelectedPosition);
    final TextView tabTitlePrev = getTabTitleView(tabViewPrev);
    final TextView tabTitleNew = getTabTitleView(tabViewNew);

    ArgbEvaluator evaluator = new ArgbEvaluator();
    ValueAnimator anim1 = new ValueAnimator();
    anim1.setIntValues(mDefaultTabColor, mSelectedTabColor);
    anim1.setEvaluator(evaluator);
    anim1.setDuration(300);
    anim1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            tabTitleNew.setTextColor((Integer) valueAnimator.getAnimatedValue());
        }
    });

    ValueAnimator anim2 = new ValueAnimator();
    anim2.setIntValues(mSelectedTabColor, mDefaultTabColor);
    anim2.setEvaluator(evaluator);
    anim2.setDuration(300);
    anim2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            tabTitlePrev.setTextColor((Integer) valueAnimator.getAnimatedValue());
        }
    });

    anim1.start();
    anim2.start();
}