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