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