Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ public static AnimationComposer with(BaseViewAnimator animator) {
return new AnimationComposer(animator);
}

public interface AnimatorCallback {
public void call(Animator animator);
}

private static class EmptyAnimatorListener implements Animator.AnimatorListener {
@Override
public void onAnimationStart(Animator animation){}
@Override
public void onAnimationEnd(Animator animation){}
@Override
public void onAnimationCancel(Animator animation){}
@Override
public void onAnimationRepeat(Animator animation){}
}

public static final class AnimationComposer {

private List<Animator.AnimatorListener> callbacks = new ArrayList<Animator.AnimatorListener>();
Expand Down Expand Up @@ -101,6 +116,38 @@ public AnimationComposer withListener(Animator.AnimatorListener listener) {
return this;
}

public AnimationComposer onStart(final AnimatorCallback callback) {
callbacks.add(new EmptyAnimatorListener() {
@Override
public void onAnimationStart(Animator animation) { callback.call(animation); }
});
return this;
}

public AnimationComposer onEnd(final AnimatorCallback callback) {
callbacks.add(new EmptyAnimatorListener() {
@Override
public void onAnimationEnd(Animator animation) { callback.call(animation); }
});
return this;
}

public AnimationComposer onCancel(final AnimatorCallback callback) {
callbacks.add(new EmptyAnimatorListener() {
@Override
public void onAnimationCancel(Animator animation) { callback.call(animation); }
});
return this;
}

public AnimationComposer onRepeat(final AnimatorCallback callback) {
callbacks.add(new EmptyAnimatorListener() {
@Override
public void onAnimationRepeat(Animator animation) { callback.call(animation); }
});
return this;
}

public YoYoString playOn(View target) {
this.target = target;
return new YoYoString(new YoYo(this).play(), this.target);
Expand Down