Browse Source

Minor code cleanup

Mostly leftover code related to shared element transition
Guy Carmeli 6 years ago
parent
commit
f9bdc786a8

+ 6
- 12
lib/android/app/src/main/java/com/reactnativenavigation/parse/ValueAnimationOptions.java View File

41
     private Interpolation interpolation = Interpolation.NO_VALUE;
41
     private Interpolation interpolation = Interpolation.NO_VALUE;
42
 
42
 
43
     Animator getAnimation(View view) {
43
     Animator getAnimation(View view) {
44
-        if (!this.from.hasValue() || !this.to.hasValue())
45
-            throw new IllegalArgumentException("Params 'from' and 'to' are mandatory");
46
-        ObjectAnimator animator = ObjectAnimator.ofFloat(view, animProp, this.from.get(), this.to.get());
47
-        animator.setInterpolator(this.interpolation.getInterpolator());
48
-        if (this.duration.hasValue())
49
-            animator.setDuration(this.duration.get());
50
-        if (this.startDelay.hasValue())
51
-            animator.setStartDelay(this.startDelay.get());
44
+        if (!from.hasValue() || !to.hasValue()) throw new IllegalArgumentException("Params 'from' and 'to' are mandatory");
45
+        ObjectAnimator animator = ObjectAnimator.ofFloat(view, animProp, from.get(), to.get());
46
+        animator.setInterpolator(interpolation.getInterpolator());
47
+        if (duration.hasValue()) animator.setDuration(duration.get());
48
+        if (startDelay.hasValue()) animator.setStartDelay(startDelay.get());
52
         return animator;
49
         return animator;
53
     }
50
     }
54
 
51
 
56
     public boolean equals(Object o) {
53
     public boolean equals(Object o) {
57
         if (this == o) return true;
54
         if (this == o) return true;
58
         if (o == null || getClass() != o.getClass()) return false;
55
         if (o == null || getClass() != o.getClass()) return false;
59
-
60
-        ValueAnimationOptions options = (ValueAnimationOptions) o;
61
-
62
-        return animProp.equals(options.animProp);
56
+        return animProp.equals(((ValueAnimationOptions) o).animProp);
63
     }
57
     }
64
 
58
 
65
     @Override
59
     @Override

+ 0
- 12
lib/android/app/src/main/java/com/reactnativenavigation/utils/TextViewUtils.java View File

7
 import android.text.SpannedString;
7
 import android.text.SpannedString;
8
 import android.text.style.AbsoluteSizeSpan;
8
 import android.text.style.AbsoluteSizeSpan;
9
 import android.text.style.ForegroundColorSpan;
9
 import android.text.style.ForegroundColorSpan;
10
-import android.util.Log;
11
 import android.widget.TextView;
10
 import android.widget.TextView;
12
 
11
 
13
-import com.reactnativenavigation.views.element.animators.AntiRelativeSizeSpan;
14
-
15
 public class TextViewUtils {
12
 public class TextViewUtils {
16
     @ColorInt
13
     @ColorInt
17
     public static int getTextColor(TextView view) {
14
     public static int getTextColor(TextView view) {
29
     public static void setColor(SpannableString span, int color) {
26
     public static void setColor(SpannableString span, int color) {
30
         span.setSpan(new ForegroundColorSpan(color), 0, span.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
27
         span.setSpan(new ForegroundColorSpan(color), 0, span.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
31
     }
28
     }
32
-
33
-    public static void setRelativeTextSize(SpannableString span, float scale) {
34
-        Log.i("TextViewUtils", "setRelativeTextSize: " + scale + " - " + span);
35
-        span.setSpan(new AntiRelativeSizeSpan(scale), 0, span.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
36
-    }
37
-
38
-    public static void setAbsoluteTextSize(SpannableString span, float size) {
39
-        span.setSpan(new AbsoluteSizeSpan((int) size), 0, span.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
40
-    }
41
 }
29
 }

+ 0
- 15
lib/android/app/src/main/java/com/reactnativenavigation/views/element/Element.java View File

7
 import android.support.annotation.Nullable;
7
 import android.support.annotation.Nullable;
8
 import android.text.SpannableString;
8
 import android.text.SpannableString;
9
 import android.text.SpannedString;
9
 import android.text.SpannedString;
10
-import android.util.Log;
11
 import android.view.View;
10
 import android.view.View;
12
 import android.widget.FrameLayout;
11
 import android.widget.FrameLayout;
13
 import android.widget.TextView;
12
 import android.widget.TextView;
83
             ((TextView) getChild()).setText(spannableText);
82
             ((TextView) getChild()).setText(spannableText);
84
         }
83
         }
85
     }
84
     }
86
-
87
-    @Keep
88
-    public void setTextSize(float size) {
89
-        if (spannableText != null) {
90
-            Log.d("Element", "setTextSize: " + size);
91
-//            ((ReactTextView) getChild()).setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
92
-
93
-//            ((ReactTextView) getChild()).updateView();
94
-//            TextViewUtils.setAbsoluteTextSize(spannableText, size);
95
-            TextViewUtils.setRelativeTextSize(spannableText, size);
96
-            ((TextView) getChild()).setText(spannableText);
97
-//            getChild().invalidate();
98
-        }
99
-    }
100
 }
85
 }

+ 0
- 29
lib/android/app/src/main/java/com/reactnativenavigation/views/element/animators/AntiRelativeSizeSpan.java View File

1
-package com.reactnativenavigation.views.element.animators;
2
-
3
-import android.text.TextPaint;
4
-import android.text.style.MetricAffectingSpan;
5
-import android.util.Log;
6
-
7
-public class AntiRelativeSizeSpan extends MetricAffectingSpan {
8
-    private final float size;
9
-
10
-    public AntiRelativeSizeSpan(float size) {
11
-        this.size = size;
12
-    }
13
-
14
-    @Override
15
-    public void updateDrawState(TextPaint ds) {
16
-        updateAnyState(ds);
17
-    }
18
-
19
-    @Override
20
-    public void updateMeasureState(TextPaint ds) {
21
-        updateAnyState(ds);
22
-    }
23
-
24
-    private void updateAnyState(TextPaint ds) {
25
-        Log.i("AntiRelativeSizeSpan", "updateAnyState: " + size + "|" + ds.density);
26
-        ds.setTextSize(size);
27
-    }
28
-}
29
-