1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.launcher3.anim;
17 
18 import androidx.dynamicanimation.animation.SpringForce;
19 
20 /**
21  * Utility class to store configurations for spring animation
22  */
23 public class SpringProperty {
24 
25     public static final SpringProperty DEFAULT = new SpringProperty();
26 
27     // Play spring when the animation is going towards the end
28     public static final int FLAG_CAN_SPRING_ON_END = 1 << 0;
29     // Play spring when animation is going towards the start (in reverse direction)
30     public static final int FLAG_CAN_SPRING_ON_START = 1 << 1;
31 
32     public final int flags;
33 
34     float mDampingRatio = SpringForce.DAMPING_RATIO_MEDIUM_BOUNCY;
35     float mStiffness = SpringForce.STIFFNESS_MEDIUM;
36 
SpringProperty()37     public SpringProperty() {
38         this(0);
39     }
40 
SpringProperty(int flags)41     public SpringProperty(int flags) {
42         this.flags = flags;
43     }
44 
setDampingRatio(float dampingRatio)45     public SpringProperty setDampingRatio(float dampingRatio) {
46         mDampingRatio = dampingRatio;
47         return this;
48     }
49 
setStiffness(float stiffness)50     public SpringProperty setStiffness(float stiffness) {
51         mStiffness = stiffness;
52         return this;
53     }
54 }
55