Browse Source

Corrected styling

Yedidya Kennard 8 years ago
parent
commit
c800aa92cd

+ 6
- 10
android/app/src/main/java/com/reactnativenavigation/core/objects/Screen.java View File

@@ -1,6 +1,5 @@
1 1
 package com.reactnativenavigation.core.objects;
2 2
 
3
-import android.os.Bundle;
4 3
 import android.support.annotation.ColorInt;
5 4
 import android.support.annotation.NonNull;
6 5
 import android.support.annotation.Nullable;
@@ -48,7 +47,7 @@ public class Screen extends JsonObject implements Serializable {
48 47
     public final String navigatorEventId;
49 48
     public final int icon;
50 49
     public final ArrayList<Button> buttons;
51
-    public final HashMap passedProps;
50
+    public HashMap<String, Object> passedProps = new HashMap<>();
52 51
 
53 52
     // Navigation styling
54 53
     @Nullable @ColorInt public Integer toolBarColor;
@@ -62,7 +61,7 @@ public class Screen extends JsonObject implements Serializable {
62 61
 
63 62
     @NonNull
64 63
     public List<Button> getButtons() {
65
-        return buttons == null ? Collections.EMPTY_LIST : buttons;
64
+        return buttons == null ? Collections.<Button>emptyList() : buttons;
66 65
     }
67 66
 
68 67
     public Screen(ReadableMap screen) {
@@ -73,17 +72,15 @@ public class Screen extends JsonObject implements Serializable {
73 72
         navigatorId = getString(screen, KEY_NAVIGATOR_ID);
74 73
         navigatorEventId = getString(screen, KEY_NAVIGATOR_EVENT_ID);
75 74
         icon = getInt(screen, KEY_ICON);
76
-        if(screen.hasKey(KEY_PROPS))
77
-            passedProps = ((ReadableNativeMap)screen.getMap(KEY_PROPS)).toHashMap();
78
-        else
79
-            passedProps = null;
80
-
75
+        if(screen.hasKey(KEY_PROPS)) {
76
+            passedProps = ((ReadableNativeMap) screen.getMap(KEY_PROPS)).toHashMap();
77
+        }
81 78
         buttons = getButtons(screen);
82 79
         setToolbarStyle(screen);
83 80
     }
84 81
 
85 82
     private ArrayList<Button> getButtons(ReadableMap screen) {
86
-        ArrayList<Button> ret = new ArrayList();
83
+        ArrayList<Button> ret = new ArrayList<>();
87 84
         if (screen.hasKey(KEY_RIGHT_BUTTONS)) {
88 85
             ReadableArray rightButtons = screen.getArray(KEY_RIGHT_BUTTONS);
89 86
             for (int i = 0; i < rightButtons.size(); i++) {
@@ -93,7 +90,6 @@ public class Screen extends JsonObject implements Serializable {
93 90
         return ret;
94 91
     }
95 92
 
96
-
97 93
     public void setToolbarStyle(ReadableMap screen) {
98 94
         ReadableMap style = getMap(screen, KEY_TOOL_BAR_STYLE);
99 95
         if (style != null) {

+ 14
- 10
android/app/src/main/java/com/reactnativenavigation/utils/BridgeUtils.java View File

@@ -51,7 +51,7 @@ public class BridgeUtils {
51 51
             } else if (arrayList.get(0) instanceof HashMap) {
52 52
                 bundle.putParcelableArray(key, toBundleArray((ArrayList<HashMap>) arrayList));
53 53
             } else if (arrayList.get(0) instanceof ArrayList) {
54
-                Log.w("RNNNavigation", "Arrays of arrays passed in props are converted to dictionaries with indexes as keys");
54
+                Log.w("RNNavigation", "Arrays of arrays passed in props are converted to dictionaries with indexes as keys");
55 55
                 Bundle innerArray = new Bundle();
56 56
                 for (int i = 0; i < arrayList.size(); i++) {
57 57
                     putArray(String.valueOf(i), (ArrayList) arrayList.get(i), innerArray);
@@ -62,11 +62,10 @@ public class BridgeUtils {
62 62
     }
63 63
 
64 64
     private static void verifyArrayListIsSingleType(ArrayList arrayList) {
65
-        int i = 1;
66
-        while (i < arrayList.size()) {
67
-            if (!arrayList.get(i - 1).getClass().isInstance(arrayList.get(i)))
65
+        for (int i = 1; i < arrayList.size(); i++) {
66
+            if (!arrayList.get(i - 1).getClass().isInstance(arrayList.get(i))) {
68 67
                 throw new IllegalArgumentException("Cannot pass array of multiple types via props");
69
-            i++;
68
+            }
70 69
         }
71 70
     }
72 71
 
@@ -80,36 +79,41 @@ public class BridgeUtils {
80 79
 
81 80
     private static int[] toIntArray(ArrayList<Integer> arrayList) {
82 81
         int[] ret = new int[arrayList.size()];
83
-        for (int i=0; i < ret.length; i++)
82
+        for (int i=0; i < ret.length; i++) {
84 83
             ret[i] = arrayList.get(i);
84
+        }
85 85
         return ret;
86 86
     }
87 87
 
88 88
     private static float[] toFloatArray(ArrayList<Float> arrayList) {
89 89
         float[] ret = new float[arrayList.size()];
90
-        for (int i=0; i < ret.length; i++)
90
+        for (int i=0; i < ret.length; i++) {
91 91
             ret[i] = arrayList.get(i);
92
+        }
92 93
         return ret;
93 94
     }
94 95
 
95 96
     private static double[] toDoubleArray(ArrayList<Double> arrayList) {
96 97
         double[] ret = new double[arrayList.size()];
97
-        for (int i=0; i < ret.length; i++)
98
+        for (int i=0; i < ret.length; i++) {
98 99
             ret[i] = arrayList.get(i);
100
+        }
99 101
         return ret;
100 102
     }
101 103
 
102 104
     private static boolean[] toBooleanArray(ArrayList<Boolean> arrayList) {
103 105
         boolean[] ret = new boolean[arrayList.size()];
104
-        for (int i=0; i < ret.length; i++)
106
+        for (int i=0; i < ret.length; i++) {
105 107
             ret[i] = arrayList.get(i);
108
+        }
106 109
         return ret;
107 110
     }
108 111
 
109 112
     private static String[] toStringArray(ArrayList<String> arrayList) {
110 113
         String[] ret = new String[arrayList.size()];
111
-        for (int i=0; i < ret.length; i++)
114
+        for (int i=0; i < ret.length; i++) {
112 115
             ret[i] = arrayList.get(i);
116
+        }
113 117
         return ret;
114 118
     }
115 119