use of com.nineoldandroids.animation.AnimatorListenerAdapter in project fresco by facebook.
the class AnimatedZoomableControllerSupport method setTransformAnimated.
public void setTransformAnimated(final Matrix newTransform, long durationMs, @Nullable final Runnable onAnimationComplete) {
FLog.v(getLogTag(), "setTransformAnimated: duration %d ms", durationMs);
stopAnimation();
Preconditions.checkArgument(durationMs > 0);
Preconditions.checkState(!isAnimating());
setAnimating(true);
mValueAnimator.setDuration(durationMs);
getTransform().getValues(getStartValues());
newTransform.getValues(getStopValues());
mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
calculateInterpolation(getWorkingTransform(), (float) valueAnimator.getAnimatedValue());
AnimatedZoomableControllerSupport.super.setTransform(getWorkingTransform());
}
});
mValueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
FLog.v(getLogTag(), "setTransformAnimated: animation cancelled");
onAnimationStopped();
}
@Override
public void onAnimationEnd(Animator animation) {
FLog.v(getLogTag(), "setTransformAnimated: animation finished");
onAnimationStopped();
}
private void onAnimationStopped() {
if (onAnimationComplete != null) {
onAnimationComplete.run();
}
setAnimating(false);
getDetector().restartGesture();
}
});
mValueAnimator.start();
}
use of com.nineoldandroids.animation.AnimatorListenerAdapter in project material-sheet-fab by gowong.
the class FabAnimation method startArcAnim.
protected void startArcAnim(View view, float endX, float endY, float degrees, Side side, long duration, Interpolator interpolator, final AnimationListener listener) {
// Setup animation
// Cast end coordinates to ints so that the FAB will be animated to the same position even
// when there are minute differences in the coordinates
ArcAnimator anim = ArcAnimator.createArcAnimator(view, (int) endX, (int) endY, degrees, side);
anim.setDuration(duration);
anim.setInterpolator(interpolator);
// Add listener
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
if (listener != null) {
listener.onStart();
}
}
@Override
public void onAnimationEnd(Animator animation) {
if (listener != null) {
listener.onEnd();
}
}
});
// Start animation
anim.start();
}
use of com.nineoldandroids.animation.AnimatorListenerAdapter in project PhotoNoter by yydcdut.
the class AnimationTopLayout method doAnimation.
public void doAnimation() {
ObjectAnimator downAnimation = ObjectAnimator.ofFloat(mChildView, "Y", 0f, getResources().getDimension(R.dimen.dimen_48dip));
downAnimation.setDuration(ANIMATION_TIME / 2);
downAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (mOnAnimationHalfFinishListener != null) {
mOnAnimationHalfFinishListener.onHalf(mChildView);
}
}
});
ObjectAnimator upAnimation = ObjectAnimator.ofFloat(mChildView, "Y", -getResources().getDimension(R.dimen.dimen_48dip), 0f);
upAnimation.setDuration(ANIMATION_TIME / 2);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playSequentially(downAnimation, upAnimation);
animatorSet.start();
}
use of com.nineoldandroids.animation.AnimatorListenerAdapter in project PhotoNoter by yydcdut.
the class FeedbackActivity method startSendingAnimation.
private void startSendingAnimation(final RevealView.RevealAnimationListener listener) {
final int width = mFab.getLeft();
final int height = mFab.getTop();
ValueAnimator valueAnimator = new ValueAnimator();
valueAnimator.setDuration(Const.DURATION / 2);
valueAnimator.setObjectValues(new PointF(0, 0));
valueAnimator.setInterpolator(new DecelerateInterpolator());
valueAnimator.setEvaluator(new TypeEvaluator<PointF>() {
@Override
public PointF evaluate(float fraction, PointF startValue, PointF endValue) {
PointF point = new PointF();
point.x = (width) * (1 - fraction / 2);
point.y = (height) - 0.85f * (height) * (fraction / 2) * (fraction / 2);
return point;
}
});
valueAnimator.start();
valueAnimator.addUpdateListener((animation) -> {
PointF point = (PointF) animation.getAnimatedValue();
mFab.setX(point.x);
mFab.setY(point.y);
});
valueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mRevealView.reveal((int) mFab.getX() + mFab.getWidth() / 2, (int) mFab.getY() + mFab.getHeight() / 2, getThemeColor(), Const.RADIUS, Const.DURATION, listener);
}
});
}
use of com.nineoldandroids.animation.AnimatorListenerAdapter in project PhotoNoter by yydcdut.
the class EditTextActivity method finishActivityWithAnimation.
@Override
public void finishActivityWithAnimation(final boolean saved, final int categoryId, final int position, final int comparator) {
int actionBarHeight = getActionBarSize();
int screenHeight = Utils.sScreenHeight;
int contentEditHeight = screenHeight - actionBarHeight;
AnimatorSet animation = new AnimatorSet();
animation.setDuration(Const.DURATION_ACTIVITY);
animation.playTogether(ObjectAnimator.ofFloat(mAppBarLayout, "translationY", 0, -actionBarHeight), ObjectAnimator.ofFloat(mTitleTextInputLayout, "translationY", 0, -actionBarHeight * 3), ObjectAnimator.ofFloat(mContentEdit, "translationY", 0, contentEditHeight), ObjectAnimator.ofFloat(mFabMenuLayout, "translationY", 0, contentEditHeight), ObjectAnimator.ofFloat(mHorizontalEditScrollView, "translationY", 0, contentEditHeight));
animation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (!saved) {
setResult(RESULT_NOTHING);
EditTextActivity.this.finish();
overridePendingTransition(R.anim.activity_no_animation, R.anim.activity_no_animation);
} else {
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putInt(Const.PHOTO_POSITION, position);
bundle.putInt(Const.CATEGORY_ID_4_PHOTNOTES, categoryId);
bundle.putInt(Const.COMPARATOR_FACTORY, comparator);
intent.putExtras(bundle);
setResult(RESULT_DATA, intent);
EditTextActivity.this.finish();
overridePendingTransition(R.anim.activity_no_animation, R.anim.activity_no_animation);
}
}
});
animation.start();
}
Aggregations