use of android.animation.AnimatorListenerAdapter in project gdk-compass-sample by googleglass.
the class CompassView method setupAnimator.
/**
* Sets up a {@link ValueAnimator} that will be used to animate the compass
* when the distance between two sensor events is large.
*/
private void setupAnimator() {
mAnimator.setInterpolator(new LinearInterpolator());
mAnimator.setDuration(250);
// Notifies us at each frame of the animation so we can redraw the view.
mAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
mAnimatedHeading = MathUtils.mod((Float) mAnimator.getAnimatedValue(), 360.0f);
invalidate();
}
});
// Notifies us when the animation is over. During an animation, the user's head may have
// continued to move to a different orientation than the original destination angle of the
// animation. Since we can't easily change the animation goal while it is running, we call
// animateTo() again, which will either redraw at the new orientation (if the difference is
// small enough), or start another animation to the new heading. This seems to produce
// fluid results.
mAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
animateTo(mHeading);
}
});
}
use of android.animation.AnimatorListenerAdapter in project ListenerMusicPlayer by hefuyicoder.
the class LyricView method doFlingAnimator.
/**
* 滑行动画
* @param velocity 滑动速度
* */
private void doFlingAnimator(float velocity) {
//注: Math.abs(velocity) < = 16000
// 计算就已当前的滑动速度理论上的滑行距离是多少
float distance = (velocity / Math.abs(velocity) * Math.min((Math.abs(velocity) * 0.050f), 640));
// 综合考虑边界问题后得出的实际滑行距离
float to = Math.min(Math.max(0, (mScrollY - distance)), (mLineCount - 1) * mLineHeight);
mFlingAnimator = ValueAnimator.ofFloat(mScrollY, to);
mFlingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mScrollY = (float) animation.getAnimatedValue();
measureCurrentLine();
invalidateView();
}
});
mFlingAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
mVelocity = mMinStartUpSpeed - 1;
mSliding = true;
}
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mSliding = false;
}
@Override
public void onAnimationCancel(Animator animation) {
super.onAnimationCancel(animation);
}
});
mFlingAnimator.setDuration(420);
mFlingAnimator.setInterpolator(new DecelerateInterpolator());
mFlingAnimator.start();
}
use of android.animation.AnimatorListenerAdapter in project ListenerMusicPlayer by hefuyicoder.
the class PlayPauseDrawable method getPausePlayAnimator.
public Animator getPausePlayAnimator() {
final Animator anim = ObjectAnimator.ofFloat(this, PROGRESS, mIsPlay ? 1 : 0, mIsPlay ? 0 : 1);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mIsPlay = !mIsPlay;
}
});
return anim;
}
use of android.animation.AnimatorListenerAdapter in project material-components-android by material-components.
the class FloatingActionButtonIcs method show.
@Override
void show(@Nullable final InternalVisibilityChangedListener listener, final boolean fromUser) {
if (isOrWillBeShown()) {
// We either are or will soon be visible, skip the call
return;
}
mView.animate().cancel();
if (shouldAnimateVisibilityChange()) {
mAnimState = ANIM_STATE_SHOWING;
if (mView.getVisibility() != View.VISIBLE) {
// If the view isn't visible currently, we'll animate it from a single pixel
mView.setAlpha(0f);
mView.setScaleY(0f);
mView.setScaleX(0f);
}
mView.animate().scaleX(1f).scaleY(1f).alpha(1f).setDuration(SHOW_HIDE_ANIM_DURATION).setInterpolator(AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mView.internalSetVisibility(View.VISIBLE, fromUser);
}
@Override
public void onAnimationEnd(Animator animation) {
mAnimState = ANIM_STATE_NONE;
if (listener != null) {
listener.onShown();
}
}
});
} else {
mView.internalSetVisibility(View.VISIBLE, fromUser);
mView.setAlpha(1f);
mView.setScaleY(1f);
mView.setScaleX(1f);
if (listener != null) {
listener.onShown();
}
}
}
use of android.animation.AnimatorListenerAdapter in project material-components-android by material-components.
the class FloatingActionButtonIcs method hide.
@Override
void hide(@Nullable final InternalVisibilityChangedListener listener, final boolean fromUser) {
if (isOrWillBeHidden()) {
// We either are or will soon be hidden, skip the call
return;
}
mView.animate().cancel();
if (shouldAnimateVisibilityChange()) {
mAnimState = ANIM_STATE_HIDING;
mView.animate().scaleX(0f).scaleY(0f).alpha(0f).setDuration(SHOW_HIDE_ANIM_DURATION).setInterpolator(AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR).setListener(new AnimatorListenerAdapter() {
private boolean mCancelled;
@Override
public void onAnimationStart(Animator animation) {
mView.internalSetVisibility(View.VISIBLE, fromUser);
mCancelled = false;
}
@Override
public void onAnimationCancel(Animator animation) {
mCancelled = true;
}
@Override
public void onAnimationEnd(Animator animation) {
mAnimState = ANIM_STATE_NONE;
if (!mCancelled) {
mView.internalSetVisibility(fromUser ? View.GONE : View.INVISIBLE, fromUser);
if (listener != null) {
listener.onHidden();
}
}
}
});
} else {
// If the view isn't laid out, or we're in the editor, don't run the animation
mView.internalSetVisibility(fromUser ? View.GONE : View.INVISIBLE, fromUser);
if (listener != null) {
listener.onHidden();
}
}
}
Aggregations