|
@@ -117,27 +117,27 @@ public class NavigationReactGateway implements ReactGateway {
|
117
|
117
|
|
118
|
118
|
@Override
|
119
|
119
|
protected List<ReactPackage> getPackages() {
|
120
|
|
- List<ReactPackage> list = new ArrayList<>();
|
121
|
|
- list.add(new MainReactPackage());
|
122
|
|
- list.add(new NavigationReactPackage());
|
123
|
|
- addAdditionalReactPackagesIfNeeded(list);
|
124
|
|
- return list;
|
125
|
|
- }
|
|
120
|
+ List<ReactPackage> result = new ArrayList<>();
|
126
|
121
|
|
127
|
|
- private void addAdditionalReactPackagesIfNeeded(List<ReactPackage> list) {
|
128
|
122
|
List<ReactPackage> additionalReactPackages = NavigationApplication.instance.createAdditionalReactPackages();
|
129
|
|
- if (additionalReactPackages == null) {
|
130
|
|
- return;
|
131
|
|
- }
|
|
123
|
+ if (additionalReactPackages != null)
|
|
124
|
+ result.addAll(additionalReactPackages);
|
132
|
125
|
|
133
|
|
- for (ReactPackage reactPackage : additionalReactPackages) {
|
134
|
|
- if (reactPackage instanceof MainReactPackage)
|
135
|
|
- throw new RuntimeException("Do not create a new MainReactPackage. This is created for you.");
|
136
|
|
- if (reactPackage instanceof NavigationReactPackage)
|
137
|
|
- throw new RuntimeException("Do not create a new NavigationReactPackage. This is created for you.");
|
|
126
|
+ if (!containsInstanceOfClass(result, MainReactPackage.class)) {
|
|
127
|
+ result.add(new MainReactPackage());
|
|
128
|
+ }
|
|
129
|
+ if (!containsInstanceOfClass(result, NavigationReactPackage.class)) {
|
|
130
|
+ result.add(new NavigationReactPackage());
|
138
|
131
|
}
|
139
|
132
|
|
140
|
|
- list.addAll(additionalReactPackages);
|
|
133
|
+ return result;
|
|
134
|
+ }
|
|
135
|
+
|
|
136
|
+ private <T extends ReactPackage> boolean containsInstanceOfClass(List<ReactPackage> list, Class<T> packageClass) {
|
|
137
|
+ for (ReactPackage reactPackage : list) {
|
|
138
|
+ if (packageClass.isInstance(reactPackage)) return true;
|
|
139
|
+ }
|
|
140
|
+ return false;
|
141
|
141
|
}
|
142
|
142
|
|
143
|
143
|
@Override
|