Преглед на файлове

Rename findControllerById to findController

Guy Carmeli преди 6 години
родител
ревизия
aa26286ae2

+ 4
- 4
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ParentController.java Целия файл

@@ -72,19 +72,19 @@ public abstract class ParentController<T extends ViewGroup> extends ChildControl
72 72
 
73 73
 	@Nullable
74 74
 	@Override
75
-	public ViewController findControllerById(final String id) {
76
-		ViewController fromSuper = super.findControllerById(id);
75
+	public ViewController findController(final String id) {
76
+		ViewController fromSuper = super.findController(id);
77 77
 		if (fromSuper != null) return fromSuper;
78 78
 
79 79
 		for (ViewController child : getChildControllers()) {
80
-			ViewController fromChild = child.findControllerById(id);
80
+			ViewController fromChild = child.findController(id);
81 81
 			if (fromChild != null) return fromChild;
82 82
 		}
83 83
 
84 84
 		return null;
85 85
 	}
86 86
 
87
-	@Override
87
+    @Override
88 88
     public boolean containsComponent(Component component) {
89 89
         if (super.containsComponent(component)) {
90 90
             return true;

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ViewController.java Целия файл

@@ -177,7 +177,7 @@ public abstract class ViewController<T extends ViewGroup> implements ViewTreeObs
177 177
     }
178 178
 
179 179
     @Nullable
180
-    public ViewController findControllerById(String id) {
180
+    public ViewController findController(String id) {
181 181
         return isSameId(id) ? this : null;
182 182
     }
183 183
 

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabFinder.java Целия файл

@@ -27,7 +27,7 @@ public class BottomTabFinder {
27 27
     @IntRange(from = -1)
28 28
     public int findByControllerId(String id) {
29 29
         for (int i = 0; i < tabs.size(); i++) {
30
-            if (tabs.get(i).findControllerById(id) != null) {
30
+            if (tabs.get(i).findController(id) != null) {
31 31
                 return i;
32 32
             }
33 33
         }

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/modal/ModalStack.java Целия файл

@@ -137,7 +137,7 @@ public class ModalStack {
137 137
     @Nullable
138 138
     private ViewController findModalByComponentId(String componentId) {
139 139
         for (ViewController modal : modals) {
140
-            if (modal.findControllerById(componentId) != null) {
140
+            if (modal.findController(componentId) != null) {
141 141
                 return modal;
142 142
             }
143 143
         }
@@ -148,7 +148,7 @@ public class ModalStack {
148 148
     @Nullable
149 149
     public ViewController findControllerById(String componentId) {
150 150
         for (ViewController modal : modals) {
151
-            ViewController controllerById = modal.findControllerById(componentId);
151
+            ViewController controllerById = modal.findController(componentId);
152 152
             if (controllerById != null) {
153 153
                 return controllerById;
154 154
             }

+ 5
- 5
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/navigator/Navigator.java Целия файл

@@ -137,7 +137,7 @@ public class Navigator extends ParentController {
137 137
     }
138 138
 
139 139
     public void mergeOptions(final String componentId, Options options) {
140
-        ViewController target = findControllerById(componentId);
140
+        ViewController target = findController(componentId);
141 141
         if (target != null) {
142 142
             target.mergeOptions(options);
143 143
         }
@@ -160,7 +160,7 @@ public class Navigator extends ParentController {
160 160
     }
161 161
 
162 162
     public void popTo(final String id, Options mergeOptions, CommandListener listener) {
163
-        ViewController target = findControllerById(id);
163
+        ViewController target = findController(id);
164 164
         if (target != null) {
165 165
             target.performOnParentStack(stack -> ((StackController) stack).popTo(target, mergeOptions, listener));
166 166
         } else {
@@ -194,13 +194,13 @@ public class Navigator extends ParentController {
194 194
 
195 195
     @Nullable
196 196
     @Override
197
-    public ViewController findControllerById(String id) {
198
-        ViewController controllerById = super.findControllerById(id);
197
+    public ViewController findController(String id) {
198
+        ViewController controllerById = super.findController(id);
199 199
         return controllerById != null ? controllerById : modalStack.findControllerById(id);
200 200
     }
201 201
 
202 202
     private void applyOnStack(String fromId, CommandListener listener, Task<StackController> task) {
203
-        ViewController from = findControllerById(fromId);
203
+        ViewController from = findController(fromId);
204 204
         if (from != null) {
205 205
             if (from instanceof StackController) {
206 206
                 task.run((StackController) from);

+ 3
- 3
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ParentControllerTest.java Целия файл

@@ -95,8 +95,8 @@ public class ParentControllerTest extends BaseTest {
95 95
         children.add(child1);
96 96
         children.add(child2);
97 97
 
98
-        assertThat(uut.findControllerById("uut")).isEqualTo(uut);
99
-        assertThat(uut.findControllerById("child1")).isEqualTo(child1);
98
+        assertThat(uut.findController("uut")).isEqualTo(uut);
99
+        assertThat(uut.findController("child1")).isEqualTo(child1);
100 100
     }
101 101
 
102 102
     @Test
@@ -109,7 +109,7 @@ public class ParentControllerTest extends BaseTest {
109 109
         stackController.push(child2, new CommandListenerAdapter());
110 110
         children.add(stackController);
111 111
 
112
-        assertThat(uut.findControllerById("child2")).isEqualTo(child2);
112
+        assertThat(uut.findController("child2")).isEqualTo(child2);
113 113
     }
114 114
 
115 115
     @Test

+ 2
- 2
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ViewControllerTest.java Целия файл

@@ -107,8 +107,8 @@ public class ViewControllerTest extends BaseTest {
107 107
 
108 108
     @Test
109 109
     public void findControllerById_SelfOrNull() {
110
-        assertThat(uut.findControllerById("456")).isNull();
111
-        assertThat(uut.findControllerById("uut")).isEqualTo(uut);
110
+        assertThat(uut.findController("456")).isNull();
111
+        assertThat(uut.findController("uut")).isEqualTo(uut);
112 112
     }
113 113
 
114 114
     @Test

+ 4
- 4
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.java Целия файл

@@ -629,10 +629,10 @@ public class StackControllerTest extends BaseTest {
629 629
 
630 630
     @Test
631 631
     public void findControllerById_ReturnsSelfOrChildrenById() {
632
-        assertThat(uut.findControllerById("123")).isNull();
633
-        assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
632
+        assertThat(uut.findController("123")).isNull();
633
+        assertThat(uut.findController(uut.getId())).isEqualTo(uut);
634 634
         uut.push(child1, new CommandListenerAdapter());
635
-        assertThat(uut.findControllerById(child1.getId())).isEqualTo(child1);
635
+        assertThat(uut.findController(child1.getId())).isEqualTo(child1);
636 636
     }
637 637
 
638 638
     @Test
@@ -641,7 +641,7 @@ public class StackControllerTest extends BaseTest {
641 641
         stack.ensureViewIsCreated();
642 642
         stack.push(child2, new CommandListenerAdapter());
643 643
         uut.push(stack, new CommandListenerAdapter());
644
-        assertThat(uut.findControllerById(child2.getId())).isEqualTo(child2);
644
+        assertThat(uut.findController(child2.getId())).isEqualTo(child2);
645 645
     }
646 646
 
647 647
     @Test