use of android.animation.ValueAnimator.AnimatorUpdateListener in project Xposed-Tinted-Status-Bar by MohammadAG.
the class ColourChangerMod method setNavigationBarTint.
@SuppressLint("NewApi")
private void setNavigationBarTint(final int tintColor, boolean force) {
if (mNavigationBarView == null)
return;
if (mSettingsHelper.shouldLinkStatusBarAndNavBar() && !force) {
log("Ignoring manual navigation bar color change cause we're linked");
return;
}
log("Setting navigation bar color to " + tintColor);
if (mSettingsHelper.animateStatusBarTintChange()) {
int animateFrom = mLastSetColor == KITKAT_TRANSPARENT_COLOR ? Color.TRANSPARENT : mLastSetNavBarTint;
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) {
mNavGradientDrawable.setColor((Integer) animator.getAnimatedValue());
}
});
Utils.setViewBackground(mNavigationBarView, mNavGradientDrawable);
colorAnimation.start();
} else {
mNavigationBarView.setAlpha(1f);
if (tintColor == KITKAT_TRANSPARENT_COLOR) {
Utils.setViewBackground(mNavigationBarView, mNavGradientDrawable);
mNavGradientDrawable.setColor(Color.TRANSPARENT);
} else {
Utils.setViewBackground(mNavigationBarView, mNavGradientDrawable);
mNavGradientDrawable.setColor(tintColor);
}
}
mNavGradientDrawable.setMode(mSettingsHelper.getOverlayMode(), mSettingsHelper.getSemiTransparentOverlayOpacity());
mNavGradientDrawable.setIsTransparentCauseOfKitKatApi(tintColor == KITKAT_TRANSPARENT_COLOR && mSettingsHelper.isLegacyGradientMode());
if (mNavigationBarView != null && tintColor != KITKAT_TRANSPARENT_COLOR) {
Intent intent = new Intent("gravitybox.intent.action.ACTION_NAVBAR_CHANGED");
intent.putExtra("navbarBgColor", tintColor);
intent.putExtra("navbarColorEnable", true);
mNavigationBarView.getContext().sendBroadcast(intent);
}
mLastSetNavBarTint = tintColor;
}
use of android.animation.ValueAnimator.AnimatorUpdateListener in project Signal-Android by WhisperSystems.
the class Tweener method to.
@SuppressLint("NewApi")
public static Tweener to(Object object, long duration, Object... vars) {
long delay = 0;
AnimatorUpdateListener updateListener = null;
AnimatorListener listener = null;
TimeInterpolator interpolator = null;
// Iterate through arguments and discover properties to animate
ArrayList<PropertyValuesHolder> props = new ArrayList<PropertyValuesHolder>(vars.length / 2);
for (int i = 0; i < vars.length; i += 2) {
if (!(vars[i] instanceof String)) {
throw new IllegalArgumentException("Key must be a string: " + vars[i]);
}
String key = (String) vars[i];
Object value = vars[i + 1];
if ("simultaneousTween".equals(key)) {
// TODO
} else if ("ease".equals(key)) {
// TODO: multiple interpolators?
interpolator = (TimeInterpolator) value;
} else if ("onUpdate".equals(key) || "onUpdateListener".equals(key)) {
updateListener = (AnimatorUpdateListener) value;
} else if ("onComplete".equals(key) || "onCompleteListener".equals(key)) {
listener = (AnimatorListener) value;
} else if ("delay".equals(key)) {
delay = ((Number) value).longValue();
} else if ("syncWith".equals(key)) {
// TODO
} else if (value instanceof float[]) {
props.add(PropertyValuesHolder.ofFloat(key, ((float[]) value)[0], ((float[]) value)[1]));
} else if (value instanceof Number) {
float floatValue = ((Number) value).floatValue();
props.add(PropertyValuesHolder.ofFloat(key, floatValue));
} else {
throw new IllegalArgumentException("Bad argument for key \"" + key + "\" with value " + value.getClass());
}
}
// Re-use existing tween, if present
Tweener tween = sTweens.get(object);
ObjectAnimator anim = null;
if (tween == null) {
anim = ObjectAnimator.ofPropertyValuesHolder(object, props.toArray(new PropertyValuesHolder[props.size()]));
tween = new Tweener(anim);
sTweens.put(object, tween);
if (DEBUG)
Log.v(TAG, "Added new Tweener " + tween);
} else {
anim = sTweens.get(object).animator;
// Cancel all animators for given object
replace(props, object);
}
if (interpolator != null) {
anim.setInterpolator(interpolator);
}
// Update animation with properties discovered in loop above
anim.setStartDelay(delay);
anim.setDuration(duration);
if (updateListener != null) {
// There should be only one
anim.removeAllUpdateListeners();
anim.addUpdateListener(updateListener);
}
if (listener != null) {
// There should be only one.
anim.removeAllListeners();
anim.addListener(listener);
}
anim.addListener(mCleanupListener);
anim.start();
return tween;
}
use of android.animation.ValueAnimator.AnimatorUpdateListener in project Leonids by plattysoft.
the class ParticleSystem method startAnimator.
private void startAnimator(Interpolator interpolator, long animnationTime) {
mAnimator = ValueAnimator.ofInt(0, (int) animnationTime);
mAnimator.setDuration(animnationTime);
mAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int miliseconds = (Integer) animation.getAnimatedValue();
onUpdate(miliseconds);
}
});
mAnimator.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
cleanupAnimation();
}
@Override
public void onAnimationCancel(Animator animation) {
cleanupAnimation();
}
});
mAnimator.setInterpolator(interpolator);
mAnimator.start();
}
use of android.animation.ValueAnimator.AnimatorUpdateListener in project platform_frameworks_base by android.
the class VolumeDialogMotion method startShowAnimation.
private void startShowAnimation() {
if (D.BUG)
Log.d(TAG, "startShowAnimation");
mDialogView.animate().translationY(0).setDuration(scaledDuration(300)).setInterpolator(new LogDecelerateInterpolator()).setListener(null).setUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
if (mChevronPositionAnimator == null)
return;
// reposition chevron
final float v = (Float) mChevronPositionAnimator.getAnimatedValue();
final int posY = chevronPosY();
mChevron.setTranslationY(posY + v + -mDialogView.getTranslationY());
}
}).start();
mContentsPositionAnimator = ValueAnimator.ofFloat(-chevronDistance(), 0).setDuration(scaledDuration(400));
mContentsPositionAnimator.addListener(new AnimatorListenerAdapter() {
private boolean mCancelled;
@Override
public void onAnimationEnd(Animator animation) {
if (mCancelled)
return;
if (D.BUG)
Log.d(TAG, "show.onAnimationEnd");
setShowing(false);
}
@Override
public void onAnimationCancel(Animator animation) {
if (D.BUG)
Log.d(TAG, "show.onAnimationCancel");
mCancelled = true;
}
});
mContentsPositionAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float v = (Float) animation.getAnimatedValue();
mContents.setTranslationY(v + -mDialogView.getTranslationY());
}
});
mContentsPositionAnimator.setInterpolator(new LogDecelerateInterpolator());
mContentsPositionAnimator.start();
mContents.setAlpha(0);
mContents.animate().alpha(1).setDuration(scaledDuration(150)).setInterpolator(new PathInterpolator(0f, 0f, .2f, 1f)).start();
mChevronPositionAnimator = ValueAnimator.ofFloat(-chevronDistance(), 0).setDuration(scaledDuration(250));
mChevronPositionAnimator.setInterpolator(new PathInterpolator(.4f, 0f, .2f, 1f));
mChevronPositionAnimator.start();
mChevron.setAlpha(0);
mChevron.animate().alpha(1).setStartDelay(scaledDuration(50)).setDuration(scaledDuration(150)).setInterpolator(new PathInterpolator(.4f, 0f, 1f, 1f)).start();
}
use of android.animation.ValueAnimator.AnimatorUpdateListener in project platform_frameworks_base by android.
the class VolumeDialogMotion method startDismiss.
public void startDismiss(final Runnable onComplete) {
if (D.BUG)
Log.d(TAG, "startDismiss");
if (mDismissing)
return;
setDismissing(true);
if (mShowing) {
mDialogView.animate().cancel();
if (mContentsPositionAnimator != null) {
mContentsPositionAnimator.cancel();
}
mContents.animate().cancel();
if (mChevronPositionAnimator != null) {
mChevronPositionAnimator.cancel();
}
mChevron.animate().cancel();
setShowing(false);
}
mDialogView.animate().translationY(-mDialogView.getHeight()).setDuration(scaledDuration(250)).setInterpolator(new LogAccelerateInterpolator()).setUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mContents.setTranslationY(-mDialogView.getTranslationY());
final int posY = chevronPosY();
mChevron.setTranslationY(posY + -mDialogView.getTranslationY());
}
}).setListener(new AnimatorListenerAdapter() {
private boolean mCancelled;
@Override
public void onAnimationEnd(Animator animation) {
if (mCancelled)
return;
if (D.BUG)
Log.d(TAG, "dismiss.onAnimationEnd");
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (D.BUG)
Log.d(TAG, "mDialog.dismiss()");
mDialog.dismiss();
onComplete.run();
setDismissing(false);
}
}, PRE_DISMISS_DELAY);
}
@Override
public void onAnimationCancel(Animator animation) {
if (D.BUG)
Log.d(TAG, "dismiss.onAnimationCancel");
mCancelled = true;
}
}).start();
}
Aggregations