Browse Source

Rename findControllerById to findController

Guy Carmeli 6 years ago
parent
commit
aa26286ae2

+ 4
- 4
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ParentController.java View File

72
 
72
 
73
 	@Nullable
73
 	@Nullable
74
 	@Override
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
 		if (fromSuper != null) return fromSuper;
77
 		if (fromSuper != null) return fromSuper;
78
 
78
 
79
 		for (ViewController child : getChildControllers()) {
79
 		for (ViewController child : getChildControllers()) {
80
-			ViewController fromChild = child.findControllerById(id);
80
+			ViewController fromChild = child.findController(id);
81
 			if (fromChild != null) return fromChild;
81
 			if (fromChild != null) return fromChild;
82
 		}
82
 		}
83
 
83
 
84
 		return null;
84
 		return null;
85
 	}
85
 	}
86
 
86
 
87
-	@Override
87
+    @Override
88
     public boolean containsComponent(Component component) {
88
     public boolean containsComponent(Component component) {
89
         if (super.containsComponent(component)) {
89
         if (super.containsComponent(component)) {
90
             return true;
90
             return true;

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ViewController.java View File

177
     }
177
     }
178
 
178
 
179
     @Nullable
179
     @Nullable
180
-    public ViewController findControllerById(String id) {
180
+    public ViewController findController(String id) {
181
         return isSameId(id) ? this : null;
181
         return isSameId(id) ? this : null;
182
     }
182
     }
183
 
183
 

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabFinder.java View File

27
     @IntRange(from = -1)
27
     @IntRange(from = -1)
28
     public int findByControllerId(String id) {
28
     public int findByControllerId(String id) {
29
         for (int i = 0; i < tabs.size(); i++) {
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
                 return i;
31
                 return i;
32
             }
32
             }
33
         }
33
         }

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/modal/ModalStack.java View File

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

+ 5
- 5
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/navigator/Navigator.java View File

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

+ 3
- 3
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ParentControllerTest.java View File

95
         children.add(child1);
95
         children.add(child1);
96
         children.add(child2);
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
     @Test
102
     @Test
109
         stackController.push(child2, new CommandListenerAdapter());
109
         stackController.push(child2, new CommandListenerAdapter());
110
         children.add(stackController);
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
     @Test
115
     @Test

+ 2
- 2
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ViewControllerTest.java View File

107
 
107
 
108
     @Test
108
     @Test
109
     public void findControllerById_SelfOrNull() {
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
     @Test
114
     @Test

+ 4
- 4
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.java View File

629
 
629
 
630
     @Test
630
     @Test
631
     public void findControllerById_ReturnsSelfOrChildrenById() {
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
         uut.push(child1, new CommandListenerAdapter());
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
     @Test
638
     @Test
641
         stack.ensureViewIsCreated();
641
         stack.ensureViewIsCreated();
642
         stack.push(child2, new CommandListenerAdapter());
642
         stack.push(child2, new CommandListenerAdapter());
643
         uut.push(stack, new CommandListenerAdapter());
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
     @Test
647
     @Test