android - What is the reason of designing an onAnimationCancel() in Animator.AnimatorListener? -



android - What is the reason of designing an onAnimationCancel() in Animator.AnimatorListener? -

android sdk animator shows:

public void cancel ()

cancels animation. unlike end(), cancel() causes animation stop in tracks, sending onanimationcancel(animator) listeners, followed onanimationend(animator) message.

to phone call method when animation not cancel. here sample aosp`s deskclock:

rotateanimatory.addlistener(new animatorlisteneradapter() { private boolean miscanceled = false; @override public void onanimationcancel(animator animation) { miscanceled = true; } @override public void onanimationend(animator animation) { if (!miscanceled) { view.setrotation(0); } view.setlayertype(view.layer_type_none, null); } });

onanimationcancel() set miscanceled flag, work done in onanimationend(). combine end status , cancel status, there @ 3 type of work need done in cases:

a), cancel & end. these work can live in **onanimationend()** b), cancel &!end. these live in **onanimationcancel()** c), !cancel & end. these annoying.

for c), have involve flag miscanceled.

i search through aosp apps , have not find benefit on making separate method of onanimationcancel(). of them "do nothing" or duplicate of onanimationend() codes.

why not merge cancel flag onanimaitonend:

abstract void onanimationend(animator animation, boolean canceled)

imop, more elegant & lite weight.

what reason of designing onanimationcancel() in animator.animatorlistener?

android animation

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -