本文整理汇总了Java中android.animation.ValueAnimator.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java ValueAnimator.addListener方法的具体用法?Java ValueAnimator.addListener怎么用?Java ValueAnimator.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.animation.ValueAnimator
的用法示例。
在下文中一共展示了ValueAnimator.addListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startTwoLevel
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public RefreshKernel startTwoLevel(boolean open) {
if (open) {
AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
SmartRefreshLayout.this.notifyStateChanged(RefreshState.TwoLevel);
}
};
ValueAnimator animator = SmartRefreshLayout.this.animSpinner(SmartRefreshLayout.this.getMeasuredHeight());
if (animator != null && animator == SmartRefreshLayout.this.reboundAnimator) {
animator.setDuration(SmartRefreshLayout.this.mFloorDuration);
animator.addListener(listener);
} else {
listener.onAnimationEnd(null);
}
} else {
if (animSpinner(0) == null) {
SmartRefreshLayout.this.notifyStateChanged(RefreshState.None);
}
}
return this;
}
示例2: setStateLoding
import android.animation.ValueAnimator; //导入方法依赖的package包/类
protected void setStateLoding() {
AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
setStateDirectLoading();
}
};
notifyStateChanged(RefreshState.LoadReleased);
ValueAnimator animator = animSpinner(-mFooterHeight);
if (animator != null) {
animator.addListener(listener);
}
if (mRefreshFooter != null) {
//onLoadmoreReleased 的执行顺序定在 animSpinner 之后 onAnimationEnd 之前
// 这样 onLoadmoreReleased 内部 可以做出 对 前面 animSpinner 的覆盖 操作
mRefreshFooter.onLoadmoreReleased(this, mFooterHeight, mFooterExtendHeight);
}
if (mOnMultiPurposeListener != null) {
//同 mRefreshFooter.onLoadmoreReleased 一致
mOnMultiPurposeListener.onFooterReleased(mRefreshFooter, mFooterHeight, mFooterExtendHeight);
}
if (animator == null) {
//onAnimationEnd 会改变状态为 loading 必须在 onLoadmoreReleased 之后调用
listener.onAnimationEnd(null);
}
}
示例3: createExpandValueAnimator
import android.animation.ValueAnimator; //导入方法依赖的package包/类
private ValueAnimator createExpandValueAnimator() {
ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
animator.setDuration(DEFAULT_ANIMATION_DURATION_EXPAND);
animator.setInterpolator(new AccelerateInterpolator());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mExpandedScaleFactor[0] = (float) valueAnimator.getAnimatedValue();
invalidateSelf();
}
});
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
notifyExpanded();
}
});
return animator;
}
示例4: createAnimator
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public Animator createAnimator(ViewGroup sceneRoot,
TransitionValues startValues,
TransitionValues endValues) {
if (animatable == null || endValues == null
|| !(endValues.view instanceof ImageView)) return null;
ImageView iv = (ImageView) endValues.view;
iv.setImageDrawable((Drawable) animatable);
// need to return a non-null Animator even though we just want to listen for the start
ValueAnimator transition = ValueAnimator.ofInt(0, 1);
transition.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
animatable.start();
}
});
return transition;
}
示例5: endAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public void endAnimation(DynamicWeatherView dynamicWeatherView, Animator.AnimatorListener listener) {
super.endAnimation(dynamicWeatherView, listener);
ValueAnimator animator = ValueAnimator.ofFloat(1, -1);
animator.setDuration(1000);
animator.setRepeatCount(0);
animator.setInterpolator(new AccelerateInterpolator());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
hillTransFactor = (float) animation.getAnimatedValue();
}
});
if (listener != null) {
animator.addListener(listener);
}
animator.start();
}
示例6: endAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public void endAnimation(DynamicWeatherView dynamicWeatherView, Animator.AnimatorListener listener) {
super.endAnimation(dynamicWeatherView, listener);
dynamicWeatherView.removeCallbacks(flashRunnable);
ValueAnimator animator = ValueAnimator.ofFloat(getWidth() - bitmap.getWidth() * 0.2f, getWidth());
animator.setDuration(1000);
animator.setRepeatCount(0);
animator.setInterpolator(new AccelerateInterpolator());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
transFactor = (float) animation.getAnimatedValue();
}
});
if (listener != null) {
animator.addListener(listener);
}
animator.start();
}
示例7: animLayoutByTime
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public void animLayoutByTime(int start, int end, long time, AnimatorUpdateListener listener, AnimatorListener animatorListener) {
ValueAnimator va = ValueAnimator.ofInt(start, end);
va.setInterpolator(new DecelerateInterpolator());
va.addUpdateListener(listener);
va.addListener(animatorListener);
va.setDuration(time);
va.start();
}
示例8: createSettlingAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
private ValueAnimator createSettlingAnimation(float curFraction) {
ValueAnimator animator;
DIRECTION direction;
if(curFraction < SCROLL_SETTLING_THRESHOLD_LEFT) {
// settling to current position -1
animator = ValueAnimator.ofFloat(curFraction, ANIMATION_LEFT_VALUE);
direction = DIRECTION.LEFT;
} else if(curFraction >= SCROLL_SETTLING_THRESHOLD_LEFT
&& curFraction <= SCROLL_SETTLING_THRESHOLD_RIGHT) {
// settling to current position
animator = ValueAnimator.ofFloat(curFraction, ANIMATION_MIDDLE_VALUE);
direction = DIRECTION.MIDDLE;
} else {
// settling to current position +1
animator = ValueAnimator.ofFloat(curFraction, ANIMATION_RIGHT_VALUE);
direction = DIRECTION.RIGHT;
}
animator.setDuration(ANIMATION_DURATION_HALF);
animator.setInterpolator(ANIMATION_INTERPOLATOR);
animator.addUpdateListener(animatorUpdateListener);
ImageAnimationListener listener = new ImageAnimationListener(direction);
animator.addListener(listener);
if(keys != null) {
// pre load the image if it did not load by auto scroll
String key = keys[getNextPosition(direction)];
if(imageLoader != null && !imageLoader.isImageLoaded(key)) {
imageLoader.preLoadImage(key);
}
}
return animator;
}
示例9: animateAlphaAtIndex
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* Returns an animator which changes the alpha at the index {@param index}
* to {@param finalAlpha}. Alphas at other index are not affected.
*/
public Animator animateAlphaAtIndex(float finalAlpha, final int index) {
final ValueAnimator anim;
if (Float.compare(finalAlpha, mAlphas[index]) == 0) {
// Return a dummy animator to avoid null checks.
anim = ValueAnimator.ofFloat(0, 0);
} else {
ValueAnimator animator = ValueAnimator.ofFloat(mAlphas[index], finalAlpha);
animator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float value = (Float) valueAnimator.getAnimatedValue();
setAlphaAtIndex(value, index);
}
});
anim = animator;
}
if (Float.compare(finalAlpha, 0f) == 0) {
// In case when any channel is animating to 0, and the current alpha is also 0, do not
// update alpha of the target view while the animation is running.
// We special case '0' because if any channel is set to 0, values of other
// channels do not matter.
anim.addListener(new ZeroAlphaAnimatorListener());
}
return anim;
}
示例10: drawBezierLine
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 绘制水平路径
* **/
private void drawBezierLine() {
PointF pointControl = new PointF(0, endYThree);
PointF pointStart = new PointF(endXTwo, endYTwo);
PointF pointEnd = new PointF(endXThree, endYThree);
BezierEvaluator bezierEvaluator = new BezierEvaluator(pointControl);
ValueAnimator valueLine = ValueAnimator.ofObject(bezierEvaluator, pointStart, pointEnd);
valueLine.setDuration(1000);
valueLine.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
PointF currentPoint = (PointF) valueAnimator.getAnimatedValue();
setLT((int) (currentPoint.x - planeHeight / 2),
(int) (currentPoint.y - planeHeight / 2 - skyHeight));
float angle = (float) Math.atan2((currentPoint.y
- mOldPoint.y),(currentPoint.x - mOldPoint.x));
setRotation((float) (angle * 180 / Math.PI));
mOldPoint = currentPoint;
}
});
valueLine.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
//动画执行结束
ANIMATION_END=true;
}
});
valueLine.setInterpolator(new AccelerateDecelerateInterpolator());
animatorLine=valueLine;
}
示例11: startAnim
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 执行文字编辑区域动画
*/
private void startAnim(float start, float end, AnimatorListenerAdapter listenerAdapter){
ValueAnimator va = ValueAnimator.ofFloat(start, end).setDuration(200);
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (float) animation.getAnimatedValue();
rl_edit_text.setY(value);
}
});
if(listenerAdapter != null) va.addListener(listenerAdapter);
va.start();
}
示例12: animateSuccessfulSet
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* Change card color. This method wraps the Property Animation API mentioned here
* https://stackoverflow.com/a/14467625/7009268
*/
public void animateSuccessfulSet(final AnimationEndCallback callback) {
int colorFrom = ContextCompat.getColor(getContext(), R.color.card_background_normal);
int colorTo = ContextCompat.getColor(getContext(), R.color.fbutton_color_nephritis);
final SetGameCardView card = this;
int duration = getContext().getResources().getInteger(R.integer.card_success_animation_duration);
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
colorAnimation.setDuration(duration); // milliseconds
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
card.setCardBackgroundColor((int) animator.getAnimatedValue());
}
});
colorAnimation.start();
colorAnimation.addListener(new AnimatorListenerAdapter()
{
@Override
public void onAnimationEnd(Animator animation)
{
card.setChecked(false, true);
// Notify our calling method that the animation is over
if (callback != null) {
callback.onAnimationFinish();
}
}
});
}
示例13: addBookmarkWithAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public static void addBookmarkWithAnimation(final View bookmarkImage, Animator.AnimatorListener animatorListener) {
bookmarkImage.setPivotY(0);
ValueAnimator moveAnim = ObjectAnimator.ofFloat(bookmarkImage, View.SCALE_Y, 0, 1);
moveAnim.setDuration(1000);
moveAnim.setInterpolator(new OvershootInterpolator(BOOKMARK_ANIMATING_OVERSHOOT_TENSION));
moveAnim.addListener(animatorListener);
moveAnim.start();
}
示例14: performDismiss
import android.animation.ValueAnimator; //导入方法依赖的package包/类
private void performDismiss() {
// Animate the dismissed view to zero-height and then fire the dismiss callback.
// This triggers layout on each animation frame; in the future we may want to do something
// smarter and more performant.
final ViewGroup.LayoutParams lp = mView.getLayoutParams();
final int originalHeight = mView.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mCallbacks.onDismiss(mView, mToken);
// Reset view presentation
mView.setAlpha(1f);
mView.setTranslationX(0);
lp.height = originalHeight;
mView.setLayoutParams(lp);
}
});
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
mView.setLayoutParams(lp);
}
});
animator.start();
}
示例15: setStateRefreshing
import android.animation.ValueAnimator; //导入方法依赖的package包/类
protected void setStateRefreshing() {
AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mLastRefreshingTime = currentTimeMillis();
notifyStateChanged(RefreshState.Refreshing);
if (mRefreshListener != null) {
mRefreshListener.onRefresh(SmartRefreshLayout.this);
}
if (mRefreshHeader != null) {
mRefreshHeader.onStartAnimator(SmartRefreshLayout.this, mHeaderHeight, mHeaderExtendHeight);
}
if (mOnMultiPurposeListener != null) {
mOnMultiPurposeListener.onRefresh(SmartRefreshLayout.this);
mOnMultiPurposeListener.onHeaderStartAnimator(mRefreshHeader, mHeaderHeight, mHeaderExtendHeight);
}
}
};
notifyStateChanged(RefreshState.RefreshReleased);
ValueAnimator animator = animSpinner(mHeaderHeight);
if (animator != null) {
animator.addListener(listener);
}
if (mRefreshHeader != null) {
//onRefreshReleased 的执行顺序定在 animSpinner 之后 onAnimationEnd 之前
// 这样 onRefreshReleased内部 可以做出 对 前面 animSpinner 的覆盖 操作
mRefreshHeader.onRefreshReleased(this, mHeaderHeight, mHeaderExtendHeight);
}
if (mOnMultiPurposeListener != null) {
//同 mRefreshHeader.onRefreshReleased 一致
mOnMultiPurposeListener.onHeaderReleased(mRefreshHeader, mHeaderHeight, mHeaderExtendHeight);
}
if (animator == null) {
//onAnimationEnd 会改变状态为 Refreshing 必须在 onRefreshReleased 之后调用
listener.onAnimationEnd(null);
}
}