1 package com.android.launcher3.anim; 2 3 import android.animation.PropertyValuesHolder; 4 import android.view.View; 5 6 import java.util.ArrayList; 7 8 /** 9 * Helper class to build a list of {@link PropertyValuesHolder} for view properties 10 */ 11 public class PropertyListBuilder { 12 13 private final ArrayList<PropertyValuesHolder> mProperties = new ArrayList<>(); 14 translationX(float value)15 public PropertyListBuilder translationX(float value) { 16 mProperties.add(PropertyValuesHolder.ofFloat(View.TRANSLATION_X, value)); 17 return this; 18 } 19 translationY(float value)20 public PropertyListBuilder translationY(float value) { 21 mProperties.add(PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, value)); 22 return this; 23 } 24 scaleX(float value)25 public PropertyListBuilder scaleX(float value) { 26 mProperties.add(PropertyValuesHolder.ofFloat(View.SCALE_X, value)); 27 return this; 28 } 29 scaleY(float value)30 public PropertyListBuilder scaleY(float value) { 31 mProperties.add(PropertyValuesHolder.ofFloat(View.SCALE_Y, value)); 32 return this; 33 } 34 35 /** 36 * Helper method to set both scaleX and scaleY 37 */ scale(float value)38 public PropertyListBuilder scale(float value) { 39 return scaleX(value).scaleY(value); 40 } 41 alpha(float value)42 public PropertyListBuilder alpha(float value) { 43 mProperties.add(PropertyValuesHolder.ofFloat(View.ALPHA, value)); 44 return this; 45 } 46 build()47 public PropertyValuesHolder[] build() { 48 return mProperties.toArray(new PropertyValuesHolder[mProperties.size()]); 49 } 50 } 51