use of android.animation.ValueAnimator.AnimatorUpdateListener in project remusic by aa112901.
the class SwipeRefreshLayout method animatorFooterToBottom.
/**
* 松手之后,使用动画将Footer从距离start变化到end
*
* @param start
* @param end
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void animatorFooterToBottom(int start, final int end) {
ValueAnimator valueAnimator = ValueAnimator.ofInt(start, end);
valueAnimator.setDuration(150);
valueAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
// update
pushDistance = (Integer) valueAnimator.getAnimatedValue();
updateFooterViewPosition();
}
});
valueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (end > 0 && mOnPushLoadMoreListener != null) {
// start loading more
mLoadMore = true;
mOnPushLoadMoreListener.onLoadMore();
} else {
resetTargetLayout();
mLoadMore = false;
}
}
});
valueAnimator.setInterpolator(mDecelerateInterpolator);
valueAnimator.start();
}
use of android.animation.ValueAnimator.AnimatorUpdateListener 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.ValueAnimator.AnimatorUpdateListener 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.ValueAnimator.AnimatorUpdateListener in project AndroidChromium by JackyAndroid.
the class ToolbarPhone method onPrimaryColorChanged.
@Override
protected void onPrimaryColorChanged(boolean shouldAnimate) {
super.onPrimaryColorChanged(shouldAnimate);
if (mBrandColorTransitionActive)
mBrandColorTransitionAnimation.cancel();
final int initialColor = mToolbarBackground.getColor();
final int finalColor = getToolbarDataProvider().getPrimaryColor();
if (initialColor == finalColor)
return;
if (!isVisualStateValidForBrandColorTransition(mVisualState))
return;
if (!shouldAnimate) {
updateToolbarBackground(finalColor);
return;
}
boolean shouldUseOpaque = ColorUtils.shouldUseOpaqueTextboxBackground(finalColor);
final int initialAlpha = mLocationBarBackgroundAlpha;
final int finalAlpha = shouldUseOpaque ? 255 : LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA;
final boolean shouldAnimateAlpha = initialAlpha != finalAlpha;
mBrandColorTransitionAnimation = ValueAnimator.ofFloat(0, 1).setDuration(THEME_COLOR_TRANSITION_DURATION);
mBrandColorTransitionAnimation.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
mBrandColorTransitionAnimation.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float fraction = animation.getAnimatedFraction();
if (shouldAnimateAlpha) {
mLocationBarBackgroundAlpha = (int) (MathUtils.interpolate(initialAlpha, finalAlpha, fraction));
}
updateToolbarBackground(ColorUtils.getColorWithOverlay(initialColor, finalColor, fraction));
}
});
mBrandColorTransitionAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mBrandColorTransitionActive = false;
updateVisualsForToolbarState();
}
});
mBrandColorTransitionAnimation.start();
mBrandColorTransitionActive = true;
}
use of android.animation.ValueAnimator.AnimatorUpdateListener in project android_frameworks_base by ParanoidAndroid.
the class SwipeHelper method snapChild.
public void snapChild(final View view, float velocity) {
final View animView = mCallback.getChildContentView(view);
final boolean canAnimViewBeDismissed = mCallback.canChildBeDismissed(animView);
ObjectAnimator anim = createTranslationAnimation(animView, 0);
int duration = SNAP_ANIM_LEN;
anim.setDuration(duration);
anim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
updateAlphaFromOffset(animView, canAnimViewBeDismissed);
}
});
anim.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animator) {
updateAlphaFromOffset(animView, canAnimViewBeDismissed);
}
});
anim.start();
}
Aggregations