use of com.nineoldandroids.animation.AnimatorListenerAdapter in project Carbon by ZieIony.
the class DefaultItemAnimator method animateRemoveImpl.
private void animateRemoveImpl(final RecyclerView.ViewHolder holder) {
final View view = holder.itemView;
final ValueAnimator animator = ValueAnimator.ofFloat(ViewHelper.getAlpha(view), 0);
mRemoveAnimations.add(holder);
animator.setDuration(getRemoveDuration());
animator.addUpdateListener(animation -> ViewHelper.setAlpha(view, (Float) animation.getAnimatedValue()));
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
dispatchRemoveStarting(holder);
}
@Override
public void onAnimationEnd(Animator animation) {
dispatchRemoveFinished(holder);
mRemoveAnimations.remove(holder);
dispatchFinishedWhenDone();
}
});
animator.start();
}
use of com.nineoldandroids.animation.AnimatorListenerAdapter in project Carbon by ZieIony.
the class DefaultItemAnimator method animateAddImpl.
private void animateAddImpl(final RecyclerView.ViewHolder holder) {
final View view = holder.itemView;
final ValueAnimator animator = ValueAnimator.ofFloat(ViewHelper.getAlpha(view), 1);
mAddAnimations.add(holder);
animator.setDuration(getAddDuration());
animator.addUpdateListener(animation -> ViewHelper.setAlpha(view, (Float) animation.getAnimatedValue()));
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
dispatchAddStarting(holder);
}
@Override
public void onAnimationCancel(Animator animation) {
ViewHelper.setAlpha(view, 1);
}
@Override
public void onAnimationEnd(Animator animation) {
dispatchAddFinished(holder);
mAddAnimations.remove(holder);
dispatchFinishedWhenDone();
}
});
animator.start();
}
use of com.nineoldandroids.animation.AnimatorListenerAdapter in project Carbon by ZieIony.
the class CoordinatorLayout method startReveal.
@Override
public Animator startReveal(int x, int y, float startRadius, float finishRadius) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
android.animation.Animator circularReveal = ViewAnimationUtils.createCircularReveal(this, x, y, startRadius, finishRadius);
circularReveal.start();
return new Animator() {
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public long getStartDelay() {
return circularReveal.getStartDelay();
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public void setStartDelay(long startDelay) {
circularReveal.setStartDelay(startDelay);
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public Animator setDuration(long duration) {
circularReveal.setDuration(duration);
return this;
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public long getDuration() {
return circularReveal.getDuration();
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public void setInterpolator(Interpolator value) {
circularReveal.setInterpolator(value);
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public boolean isRunning() {
return circularReveal.isRunning();
}
};
} else {
reveal = new Reveal(x, y, startRadius);
ValueAnimator animator = ValueAnimator.ofFloat(startRadius, finishRadius);
animator.setDuration(Carbon.getDefaultRevealDuration());
animator.addUpdateListener(animation -> {
reveal.radius = (float) animation.getAnimatedValue();
reveal.mask.reset();
reveal.mask.addCircle(reveal.x, reveal.y, Math.max(reveal.radius, 1), Path.Direction.CW);
postInvalidate();
});
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
reveal = null;
}
@Override
public void onAnimationEnd(Animator animation) {
reveal = null;
}
});
animator.start();
return animator;
}
}
use of com.nineoldandroids.animation.AnimatorListenerAdapter in project Carbon by ZieIony.
the class EditText method setVisibility.
public void setVisibility(final int visibility) {
if (visibility == View.VISIBLE && (getVisibility() != View.VISIBLE || animator != null)) {
if (animator != null)
animator.cancel();
if (inAnim != AnimUtils.Style.None) {
animator = AnimUtils.animateIn(this, inAnim, new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator a) {
animator = null;
clearAnimation();
}
});
}
super.setVisibility(visibility);
} else if (visibility != View.VISIBLE && (getVisibility() == View.VISIBLE || animator != null)) {
if (animator != null)
animator.cancel();
if (outAnim == AnimUtils.Style.None) {
super.setVisibility(visibility);
return;
}
animator = AnimUtils.animateOut(this, outAnim, new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator a) {
if (((ValueAnimator) a).getAnimatedFraction() == 1)
EditText.super.setVisibility(visibility);
animator = null;
clearAnimation();
}
});
}
}
use of com.nineoldandroids.animation.AnimatorListenerAdapter in project Carbon by ZieIony.
the class DrawerLayout method startReveal.
@Override
public Animator startReveal(int x, int y, float startRadius, float finishRadius) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
android.animation.Animator circularReveal = ViewAnimationUtils.createCircularReveal(this, x, y, startRadius, finishRadius);
circularReveal.start();
return new Animator() {
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public long getStartDelay() {
return circularReveal.getStartDelay();
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public void setStartDelay(long startDelay) {
circularReveal.setStartDelay(startDelay);
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public Animator setDuration(long duration) {
circularReveal.setDuration(duration);
return this;
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public long getDuration() {
return circularReveal.getDuration();
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public void setInterpolator(Interpolator value) {
circularReveal.setInterpolator(value);
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public boolean isRunning() {
return circularReveal.isRunning();
}
};
} else {
reveal = new Reveal(x, y, startRadius);
ValueAnimator animator = ValueAnimator.ofFloat(startRadius, finishRadius);
animator.setDuration(Carbon.getDefaultRevealDuration());
animator.addUpdateListener(animation -> {
reveal.radius = (float) animation.getAnimatedValue();
reveal.mask.reset();
reveal.mask.addCircle(reveal.x, reveal.y, Math.max(reveal.radius, 1), Path.Direction.CW);
postInvalidate();
});
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
reveal = null;
}
@Override
public void onAnimationEnd(Animator animation) {
reveal = null;
}
});
animator.start();
return animator;
}
}
Aggregations