Kelt il y a 7 ans
Parent
révision
c333451d2f

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/utils/ViewUtils.java Voir le fichier

@@ -185,7 +185,7 @@ public class ViewUtils {
185 185
     }
186 186
 
187 187
     public static ForegroundColorSpan[] getForegroundColorSpans(TextView view) {
188
-        SpannedString text = (SpannedString) view.getText();
188
+        SpannedString text = new SpannedString(view.getText());
189 189
         return text.getSpans(0, text.length(), ForegroundColorSpan.class);
190 190
     }
191 191
 

+ 10
- 2
android/app/src/main/java/com/reactnativenavigation/views/sharedElementTransition/AnimatorValuesResolver.java Voir le fichier

@@ -1,6 +1,7 @@
1 1
 package com.reactnativenavigation.views.sharedElementTransition;
2 2
 
3 3
 import android.graphics.Rect;
4
+import android.text.style.ForegroundColorSpan;
4 5
 import android.widget.TextView;
5 6
 
6 7
 import com.facebook.drawee.drawable.ScalingUtils;
@@ -119,10 +120,17 @@ class AnimatorValuesResolver {
119 120
 
120 121
     private void calculateColor(SharedElementTransition from, SharedElementTransition to) {
121 122
         if (from.getSharedView() instanceof TextView && to.getSharedView() instanceof TextView) {
122
-            startColor = ViewUtils.getForegroundColorSpans((TextView) from.getSharedView())[0].getForegroundColor();
123
-            endColor = ViewUtils.getForegroundColorSpans((TextView) to.getSharedView())[0].getForegroundColor();
123
+            ForegroundColorSpan[] startColorForegroundColorSpans = ViewUtils.getForegroundColorSpans((TextView) from.getSharedView());
124
+            if (startColorForegroundColorSpans.length > 0) {
125
+                startColor = startColorForegroundColorSpans[0].getForegroundColor();
126
+            }
127
+            ForegroundColorSpan[] endColorForegroundColorSpans = ViewUtils.getForegroundColorSpans((TextView) to.getSharedView());
128
+            if (endColorForegroundColorSpans.length > 0) {
129
+                endColor = endColorForegroundColorSpans[0].getForegroundColor();
130
+            }
124 131
         }
125 132
     }
133
+
126 134
     private void calculateDrawingReacts(SharedElementTransition from, SharedElementTransition to) {
127 135
         from.getDrawingRect(startDrawingRect);
128 136
         to.getDrawingRect(endDrawingRect);

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/views/sharedElementTransition/SharedElementTransition.java Voir le fichier

@@ -80,7 +80,7 @@ public class SharedElementTransition extends FrameLayout {
80 80
             @Override
81 81
             public void run() {
82 82
                 if (spannableText == null) {
83
-                    spannedText = (SpannedString) view.getText();
83
+                    spannedText = new SpannedString(view.getText());
84 84
                 }
85 85
                 if (spannableText == null) {
86 86
                     spannableText = new SpannableString(spannedText);