use of android.animation.ArgbEvaluator in project android_packages_apps_Dialer by MoKee.
the class PseudoEmergencyAnimator method start.
public void start() {
if (mPseudoEmergencyColorAnimator == null) {
Integer colorFrom = Color.BLUE;
Integer colorTo = Color.RED;
mPseudoEmergencyColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
mPseudoEmergencyColorAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
try {
int color = (int) animator.getAnimatedValue();
ColorFilter colorFilter = new LightingColorFilter(Color.BLACK, color);
View floatingActionButtonContainer = getView().findViewById(R.id.dialpad_floating_action_button_container);
if (floatingActionButtonContainer != null) {
floatingActionButtonContainer.getBackground().setColorFilter(colorFilter);
}
} catch (Exception e) {
animator.cancel();
}
}
});
mPseudoEmergencyColorAnimator.addListener(new AnimatorListener() {
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
try {
vibrate(VIBRATE_LENGTH_MILLIS);
} catch (Exception e) {
animation.cancel();
}
}
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
try {
View floatingActionButtonContainer = getView().findViewById(R.id.dialpad_floating_action_button_container);
if (floatingActionButtonContainer != null) {
floatingActionButtonContainer.getBackground().clearColorFilter();
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
try {
vibrate(VIBRATE_LENGTH_MILLIS);
} catch (Exception e) {
// ignored
}
}
}, ITERATION_LENGTH_MILLIS);
} catch (Exception e) {
animation.cancel();
}
}
});
mPseudoEmergencyColorAnimator.setDuration(VIBRATE_LENGTH_MILLIS);
mPseudoEmergencyColorAnimator.setRepeatMode(ValueAnimator.REVERSE);
mPseudoEmergencyColorAnimator.setRepeatCount(ANIMATION_ITERATION_COUNT);
}
if (!mPseudoEmergencyColorAnimator.isStarted()) {
mPseudoEmergencyColorAnimator.start();
}
}
use of android.animation.ArgbEvaluator in project Xposed-Tinted-Status-Bar by MohammadAG.
the class OverlayDrawable method setOverrideColor.
public void setOverrideColor(final int color) {
int animateFrom;
final int animateTo;
if (mOverrideColor != -3) {
animateFrom = mOverrideColor;
} else {
animateFrom = mColor;
}
if (color == -3) {
animateTo = mColor;
} else {
animateTo = color;
}
if (mAnimator != null && mAnimator.isRunning()) {
mAnimator.cancel();
animateFrom = mOverrideColor;
mAnimator = null;
}
mAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), animateFrom, animateTo);
mAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
mOverrideColor = (Integer) animator.getAnimatedValue();
invalidateSelf();
}
});
mAnimator.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
if (color == -3) {
mOverrideColor = -3;
mColor = animateTo;
invalidateSelf();
}
mAnimator = null;
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
mAnimator.start();
}
use of android.animation.ArgbEvaluator in project Xposed-Tinted-Status-Bar by MohammadAG.
the class ColourChangerMod method setStatusBarTint.
@SuppressLint("NewApi")
public void setStatusBarTint(final int tintColor) {
if (mStatusBarView == null)
return;
log("Setting statusbar color to " + tintColor);
if (mSettingsHelper.animateStatusBarTintChange()) {
int animateFrom = mLastSetColor == KITKAT_TRANSPARENT_COLOR ? Color.TRANSPARENT : mLastSetColor;
int animateTo = tintColor == KITKAT_TRANSPARENT_COLOR ? Color.TRANSPARENT : tintColor;
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), animateFrom, animateTo);
colorAnimation.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
mGradientDrawable.setColor((Integer) animator.getAnimatedValue());
}
});
Utils.setViewBackground(mStatusBarView, mGradientDrawable);
colorAnimation.start();
} else {
mStatusBarView.setAlpha(1f);
if (tintColor == KITKAT_TRANSPARENT_COLOR) {
Utils.setViewBackground(mStatusBarView, mGradientDrawable);
mGradientDrawable.setColor(Color.TRANSPARENT);
} else {
Utils.setViewBackground(mStatusBarView, mGradientDrawable);
mGradientDrawable.setColor(tintColor);
}
}
mGradientDrawable.setMode(mSettingsHelper.getOverlayMode(), mSettingsHelper.getSemiTransparentOverlayOpacity());
mGradientDrawable.setIsTransparentCauseOfKitKatApi(tintColor == KITKAT_TRANSPARENT_COLOR && mSettingsHelper.isLegacyGradientMode());
mLastSetColor = tintColor;
if (mSettingsHelper.shouldLinkStatusBarAndNavBar() && !mKeyboardUp) {
mNavigationBarTint = tintColor;
setNavigationBarTint(tintColor, true);
}
}
use of android.animation.ArgbEvaluator in project MaterialViewPager by florent37.
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();
}
use of android.animation.ArgbEvaluator in project ENViews by codeestX.
the class ENScrollView method unSelect.
public void unSelect() {
if (mCurrentState == STATE_UNSELECT) {
return;
}
mCurrentState = STATE_UNSELECT;
ValueAnimator valueAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), mLineColor, mBgLineColor);
valueAnimator.setDuration(mDuration);
valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mFraction = 1 - valueAnimator.getAnimatedFraction();
mCurrentColor = (int) valueAnimator.getAnimatedValue();
invalidate();
}
});
if (!valueAnimator.isRunning()) {
valueAnimator.start();
}
valueAnimator.start();
}
Aggregations