Browse Source

Use linearInterpolator as default interpolator for command animations

Guy Carmeli 6 years ago
parent
commit
e1d28d61ae

+ 9
- 5
lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Interpolation.java View File

5
 import android.view.animation.AccelerateDecelerateInterpolator;
5
 import android.view.animation.AccelerateDecelerateInterpolator;
6
 import android.view.animation.AccelerateInterpolator;
6
 import android.view.animation.AccelerateInterpolator;
7
 import android.view.animation.DecelerateInterpolator;
7
 import android.view.animation.DecelerateInterpolator;
8
+import android.view.animation.LinearInterpolator;
8
 
9
 
9
 public enum Interpolation {
10
 public enum Interpolation {
10
-    ACCELERATING,
11
-    DECELERATING,
11
+    ACCELERATE,
12
+    DECELERATE,
13
+    ACCELERATE_DECELERATE,
12
     DEFAULT,
14
     DEFAULT,
13
     NO_VALUE;
15
     NO_VALUE;
14
 
16
 
15
     public TimeInterpolator getInterpolator() {
17
     public TimeInterpolator getInterpolator() {
16
         switch (this) {
18
         switch (this) {
17
-            case ACCELERATING:
19
+            case ACCELERATE:
18
                 return new AccelerateInterpolator();
20
                 return new AccelerateInterpolator();
19
-            case DECELERATING:
21
+            case DECELERATE:
20
                 return new DecelerateInterpolator();
22
                 return new DecelerateInterpolator();
21
-            case DEFAULT:
23
+            case ACCELERATE_DECELERATE:
22
                 return new AccelerateDecelerateInterpolator();
24
                 return new AccelerateDecelerateInterpolator();
25
+            case DEFAULT:
26
+                return new LinearInterpolator();
23
         }
27
         }
24
         return null;
28
         return null;
25
     }
29
     }

+ 9
- 11
lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/InterpolationParser.java View File

7
 
7
 
8
 public class InterpolationParser {
8
 public class InterpolationParser {
9
     public static Interpolation parse(JSONObject json, String interpolation) {
9
     public static Interpolation parse(JSONObject json, String interpolation) {
10
-        Interpolation result = Interpolation.DEFAULT;
11
-        if (json.has(interpolation)) {
12
-            switch (json.optString(interpolation)) {
13
-                case "decelerate":
14
-                    result = Interpolation.DECELERATING;
15
-                    break;
16
-                case "accelerate":
17
-                    result = Interpolation.ACCELERATING;
18
-                    break;
19
-            }
10
+        switch (json.optString(interpolation, "default")) {
11
+            case "decelerate":
12
+                return Interpolation.DECELERATE;
13
+            case "accelerateDecelerate":
14
+                return Interpolation.ACCELERATE_DECELERATE;
15
+            case "accelerate":
16
+                return Interpolation.ACCELERATE;
17
+            default:
18
+                return Interpolation.DEFAULT;
20
         }
19
         }
21
-        return result;
22
     }
20
     }
23
 }
21
 }