use of com.nineoldandroids.animation.Animator 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.Animator in project PhotoNoter by yydcdut.
the class SettingActivity method closeActivityAnimation.
private void closeActivityAnimation() {
int actionBarHeight = getActionBarSize();
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int screenHeight = dm.heightPixels;
int contentHeight = screenHeight - actionBarHeight;
AnimatorSet animation = new AnimatorSet();
animation.setDuration(Const.DURATION_ACTIVITY);
animation.playTogether(ObjectAnimator.ofFloat(mToolbarLayout, "translationY", 0, -actionBarHeight), ObjectAnimator.ofFloat(mScrollView, "translationY", 0, contentHeight));
animation.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
mIsHiding = false;
finish();
overridePendingTransition(R.anim.activity_no_animation, R.anim.activity_no_animation);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
animation.start();
}
use of com.nineoldandroids.animation.Animator 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.Animator 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.Animator 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