I have the beginnings of an sdk 15 compatible class that can be used to build complex animation chains hope it helps someone. You should be able to follow the design pattern to add your own methods. If you do please comment them here and I will update the answer, Cheers!
package com.stuartclark45.magicmatt.util;
import java.util.LinkedList;
import java.util.List;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
/**
* Used to build complex animations for a view. Example usage bellow makes view move out to the
* right whilst rotating 45 degrees, then move out to the left.
*
* {@code
* int rotateDuration = 200;
* int rotation = 45;
* new AnimationBuilder(view)
* .translationX(100, rotateDuration)
* .rotateTo(rotation, rotateDuration)
* .then()
* .translationX(-200, rotateDuration)
* .start();
* }
*
* @author Stuart Clark
*/
public class AnimationBuilder {
private View view;
private List<Animator> setsList;
private List<Animator> buildingList;
public AnimationBuilder(View view) {
this.view = view;
this.setsList = new LinkedList<>();
this.buildingList = new LinkedList<>();
}
public AnimationBuilder rotateTo(float deg, long duration) {
buildingList.add(ObjectAnimator.ofFloat(view, "rotation", deg).setDuration(duration));
return this;
}
public AnimationBuilder translationX(int deltaX, long duration) {
buildingList.add(ObjectAnimator.ofFloat(view, "translationX", deltaX).setDuration(duration));
return this;
}
public AnimationBuilder translationY(int deltaX, long duration) {
buildingList.add(ObjectAnimator.ofFloat(view, "translationY", deltaX).setDuration(duration));
return this;
}
public AnimationBuilder then() {
createAniSet();
// Reset the building list
buildingList = new LinkedList<>();
return this;
}
public void start() {
createAniSet();
AnimatorSet metaSet = new AnimatorSet();
metaSet.playSequentially(setsList);
metaSet.start();
}
private void createAniSet() {
AnimatorSet aniSet = new AnimatorSet();
aniSet.playTogether(buildingList);
setsList.add(aniSet);
}
}