use of android.animation.ValueAnimator in project qksms by moezbhatti.
the class ThemeManager method setTheme.
public static void setTheme(Theme theme) {
final int startColor = mBackgroundColor;
initializeTheme(theme);
final int endColor = mBackgroundColor;
if (startColor != endColor) {
ValueAnimator backgroundAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), startColor, endColor);
backgroundAnimation.setDuration(TRANSITION_LENGTH);
backgroundAnimation.addUpdateListener(animation -> {
mBackgroundColor = (Integer) animation.getAnimatedValue();
LiveViewManager.refreshViews(QKPreference.BACKGROUND);
});
backgroundAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mBackgroundColor = endColor;
LiveViewManager.refreshViews(QKPreference.BACKGROUND);
WidgetProvider.notifyThemeChanged(mContext);
}
});
backgroundAnimation.start();
} else {
LiveViewManager.refreshViews(QKPreference.BACKGROUND);
WidgetProvider.notifyThemeChanged(mContext);
}
}
use of android.animation.ValueAnimator in project lottie-android by airbnb.
the class AnimationFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_animation, container, false);
ButterKnife.bind(this, view);
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.ic_back);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getFragmentManager().popBackStack();
}
});
postUpdatePlayButtonText();
onLoopChanged();
animationView.addAnimatorListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
startRecordingDroppedFrames();
}
@Override
public void onAnimationEnd(Animator animation) {
recordDroppedFrames();
postUpdatePlayButtonText();
}
@Override
public void onAnimationCancel(Animator animation) {
postUpdatePlayButtonText();
}
@Override
public void onAnimationRepeat(Animator animation) {
recordDroppedFrames();
startRecordingDroppedFrames();
}
});
animationView.addAnimatorUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
seekBar.setProgress((int) (animation.getAnimatedFraction() * 100));
}
});
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (!animationView.isAnimating()) {
animationView.setProgress(progress / 100f);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
return view;
}
use of android.animation.ValueAnimator in project android_frameworks_base by ParanoidAndroid.
the class GlobalScreenshot method createScreenshotDropInAnimation.
private ValueAnimator createScreenshotDropInAnimation() {
final float flashPeakDurationPct = ((float) (SCREENSHOT_FLASH_TO_PEAK_DURATION) / SCREENSHOT_DROP_IN_DURATION);
final float flashDurationPct = 2f * flashPeakDurationPct;
final Interpolator flashAlphaInterpolator = new Interpolator() {
@Override
public float getInterpolation(float x) {
// Flash the flash view in and out quickly
if (x <= flashDurationPct) {
return (float) Math.sin(Math.PI * (x / flashDurationPct));
}
return 0;
}
};
final Interpolator scaleInterpolator = new Interpolator() {
@Override
public float getInterpolation(float x) {
// We start scaling when the flash is at it's peak
if (x < flashPeakDurationPct) {
return 0;
}
return (x - flashDurationPct) / (1f - flashDurationPct);
}
};
ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
anim.setDuration(SCREENSHOT_DROP_IN_DURATION);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mBackgroundView.setAlpha(0f);
mBackgroundView.setVisibility(View.VISIBLE);
mScreenshotView.setAlpha(0f);
mScreenshotView.setTranslationX(0f);
mScreenshotView.setTranslationY(0f);
mScreenshotView.setScaleX(SCREENSHOT_SCALE + mBgPaddingScale);
mScreenshotView.setScaleY(SCREENSHOT_SCALE + mBgPaddingScale);
mScreenshotView.setVisibility(View.VISIBLE);
mScreenshotFlash.setAlpha(0f);
mScreenshotFlash.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(android.animation.Animator animation) {
mScreenshotFlash.setVisibility(View.GONE);
}
});
anim.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float t = (Float) animation.getAnimatedValue();
float scaleT = (SCREENSHOT_SCALE + mBgPaddingScale) - scaleInterpolator.getInterpolation(t) * (SCREENSHOT_SCALE - SCREENSHOT_DROP_IN_MIN_SCALE);
mBackgroundView.setAlpha(scaleInterpolator.getInterpolation(t) * BACKGROUND_ALPHA);
mScreenshotView.setAlpha(t);
mScreenshotView.setScaleX(scaleT);
mScreenshotView.setScaleY(scaleT);
mScreenshotFlash.setAlpha(flashAlphaInterpolator.getInterpolation(t));
}
});
return anim;
}
use of android.animation.ValueAnimator in project android_frameworks_base by ParanoidAndroid.
the class KeyguardMultiUserAvatar method updateVisualsForActive.
void updateVisualsForActive(boolean active, boolean animate, int duration, final Runnable onComplete) {
final float finalAlpha = active ? mActiveAlpha : mInactiveAlpha;
final float initAlpha = active ? mInactiveAlpha : mActiveAlpha;
final float finalScale = active ? 1f : 1f / mActiveScale;
final float initScale = mFramed.getScale();
final int finalTextAlpha = active ? (int) (mActiveTextAlpha * 255) : (int) (mInactiveTextAlpha * 255);
final int initTextAlpha = active ? (int) (mInactiveTextAlpha * 255) : (int) (mActiveTextAlpha * 255);
int textColor = mTextColor;
mUserName.setTextColor(textColor);
if (animate && mTouched) {
ValueAnimator va = ValueAnimator.ofFloat(0f, 1f);
va.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float r = animation.getAnimatedFraction();
float scale = (1 - r) * initScale + r * finalScale;
float alpha = (1 - r) * initAlpha + r * finalAlpha;
int textAlpha = (int) ((1 - r) * initTextAlpha + r * finalTextAlpha);
mFramed.setScale(scale);
mUserImage.setAlpha(alpha);
mUserName.setTextColor(Color.argb(textAlpha, 255, 255, 255));
mUserImage.invalidate();
}
});
va.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (onComplete != null) {
onComplete.run();
}
}
});
va.setDuration(duration);
va.start();
} else {
mFramed.setScale(finalScale);
mUserImage.setAlpha(finalAlpha);
mUserName.setTextColor(Color.argb(finalTextAlpha, 255, 255, 255));
if (onComplete != null) {
post(onComplete);
}
}
mTouched = true;
}
use of android.animation.ValueAnimator in project android_frameworks_base by ParanoidAndroid.
the class KeyguardGlowStripView method makeEmGo.
public void makeEmGo() {
if (mAnimator != null) {
mAnimator.cancel();
}
float from = mLeftToRight ? 0f : 1f;
float to = mLeftToRight ? 1f : 0f;
mAnimator = ValueAnimator.ofFloat(from, to);
mAnimator.setDuration(DURATION);
mAnimator.setInterpolator(new LinearInterpolator());
mAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mDrawDots = false;
// make sure we draw one frame at the end with everything gone.
invalidate();
}
@Override
public void onAnimationStart(Animator animation) {
mDrawDots = true;
}
});
mAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mAnimationProgress = (Float) animation.getAnimatedValue();
invalidate();
}
});
mAnimator.start();
}
Aggregations