Browse Source

work on bridge and react packages with guyc

Daniel Zlotin 8 years ago
parent
commit
51811361f3

+ 65
- 134
android/app/src/main/java/com/reactnativenavigation/activities/BaseReactActivity.java View File

@@ -21,7 +21,6 @@ import android.widget.Toast;
21 21
 import com.facebook.common.logging.FLog;
22 22
 import com.facebook.react.ReactInstanceManager;
23 23
 import com.facebook.react.ReactPackage;
24
-import com.facebook.react.ReactRootView;
25 24
 import com.facebook.react.bridge.Arguments;
26 25
 import com.facebook.react.bridge.ReadableMap;
27 26
 import com.facebook.react.bridge.WritableMap;
@@ -29,13 +28,12 @@ import com.facebook.react.common.ReactConstants;
29 28
 import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
30 29
 import com.facebook.react.shell.MainReactPackage;
31 30
 import com.reactnativenavigation.BuildConfig;
31
+import com.reactnativenavigation.bridge.NavigationReactPackage;
32 32
 import com.reactnativenavigation.controllers.ModalController;
33
-import com.reactnativenavigation.core.RctManager;
34 33
 import com.reactnativenavigation.core.objects.Button;
35 34
 import com.reactnativenavigation.core.objects.Drawer;
36 35
 import com.reactnativenavigation.core.objects.Screen;
37 36
 import com.reactnativenavigation.modal.RnnModal;
38
-import com.reactnativenavigation.bridge.NavigationReactPackage;
39 37
 import com.reactnativenavigation.utils.ContextProvider;
40 38
 import com.reactnativenavigation.utils.StyleHelper;
41 39
 import com.reactnativenavigation.views.RnnToolBar;
@@ -62,73 +60,13 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
62 60
             "Overlay permissions needs to be granted in order for react native apps to run in dev mode";
63 61
 
64 62
     @Nullable
65
-    protected ReactInstanceManager mReactInstanceManager;
66
-    private boolean mDoRefresh = false;
67
-    private Menu mMenu;
68
-    protected RnnToolBar mToolbar;
69
-    protected ActionBarDrawerToggle mDrawerToggle;
70
-    protected DrawerLayout mDrawerLayout;
71
-    protected ScreenStack mDrawerStack;
72
-
73
-    /**
74
-     * Returns the name of the bundle in assets. If this is null, and no file path is specified for
75
-     * the bundle, the app will only work with {@code getUseDeveloperSupport} enabled and will
76
-     * always try to load the JS bundle from the packager server.
77
-     * e.g. "index.android.bundle"
78
-     */
79
-    @Nullable
80
-    public String getBundleAssetName() {
81
-        return "index.android.bundle";
82
-    }
83
-
84
-    /**
85
-     * Returns a custom path of the bundle file. This is used in cases the bundle should be loaded
86
-     * from a custom path. By default it is loaded from Android assets, from a path specified
87
-     * by {getBundleAssetName}.
88
-     * e.g. "file://sdcard/myapp_cache/index.android.bundle"
89
-     */
90
-    @Nullable
91
-    public String getJSBundleFile() {
92
-        return null;
93
-    }
94
-
95
-    /**
96
-     * Returns the name of the main module. Determines the URL used to fetch the JS bundle
97
-     * from the packager server. It is only used when dev support is enabled.
98
-     * This is the first file to be executed once the {@link ReactInstanceManager} is created.
99
-     * e.g. "index.android"
100
-     */
101
-    public String getJSMainModuleName() {
102
-        return "index.android";
103
-    }
104
-
105
-    /**
106
-     * Returns the launchOptions which will be passed to the {@link ReactInstanceManager}
107
-     * when the application is started. By default, this will return null and an empty
108
-     * object will be passed to your top level component as its initial props.
109
-     * If your React Native application requires props set outside of JS, override
110
-     * this method to return the Android.os.Bundle of your desired initial props.
111
-     */
112
-    @Nullable
113
-    protected Bundle getLaunchOptions() {
114
-        return null;
115
-    }
116
-
117
-    /**
118
-     * Returns the name of the main component registered from JavaScript.
119
-     * This is used to schedule rendering of the component.
120
-     * e.g. "MoviesApp"
121
-     */
122
-    protected String getMainComponentName() {
123
-        return "";
124
-    }
125
-
126
-    /**
127
-     * Returns whether dev mode should be enabled. This enables e.g. the dev menu.
128
-     */
129
-    public boolean getUseDeveloperSupport() {
130
-        return BuildConfig.DEBUG;
131
-    }
63
+    protected ReactInstanceManager reactInstanceManager;
64
+    private boolean shouldRefreshOnRR = false;
65
+    private Menu menu;
66
+    protected RnnToolBar toolbar;
67
+    protected ActionBarDrawerToggle drawerToggle;
68
+    protected DrawerLayout drawerLayout;
69
+    protected ScreenStack drawerStack;
132 70
 
133 71
     /**
134 72
      * Returns a list of {@link ReactPackage} used by the app.
@@ -143,18 +81,11 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
143 81
         );
144 82
     }
145 83
 
146
-    /**
147
-     * A subclass may override this method if it needs to use a custom {@link ReactRootView}.
148
-     */
149
-    protected ReactRootView createRootView() {
150
-        return new ReactRootView(this);
151
-    }
152
-
153 84
     @Override
154 85
     protected void onCreate(Bundle savedInstanceState) {
155 86
         super.onCreate(savedInstanceState);
156 87
         ContextProvider.setActivityContext(this);
157
-        mReactInstanceManager = createReactInstanceManager();
88
+        reactInstanceManager = createReactInstanceManager();
158 89
         handleOnCreate();
159 90
 
160 91
     }
@@ -180,7 +111,7 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
180 111
     }
181 112
 
182 113
     private void permissionToShowRedboxIfNeeded() {
183
-        if (getUseDeveloperSupport() && Build.VERSION.SDK_INT >= 23 && !Settings.canDrawOverlays(this)) {
114
+        if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= 23 && !Settings.canDrawOverlays(this)) {
184 115
             Intent serviceIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
185 116
             startActivity(serviceIntent);
186 117
             FLog.w(ReactConstants.TAG, REDBOX_PERMISSION_MESSAGE);
@@ -193,8 +124,8 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
193 124
         super.onResume();
194 125
         ContextProvider.setActivityContext(this);
195 126
 
196
-        if (mReactInstanceManager != null) {
197
-            mReactInstanceManager.onHostResume(this, this);
127
+        if (reactInstanceManager != null) {
128
+            reactInstanceManager.onHostResume(this, this);
198 129
         }
199 130
     }
200 131
 
@@ -202,8 +133,8 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
202 133
     protected void onPause() {
203 134
         super.onPause();
204 135
 
205
-        if (mReactInstanceManager != null) {
206
-            mReactInstanceManager.onHostPause();
136
+        if (reactInstanceManager != null) {
137
+            reactInstanceManager.onHostPause();
207 138
         }
208 139
 
209 140
         ContextProvider.clearActivityContext();
@@ -215,9 +146,9 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
215 146
 
216 147
         // Destroy react instance manager only if there are no resumed react activities
217 148
         BaseReactActivity activity = ContextProvider.getActivityContext();
218
-        if (mReactInstanceManager != null && (activity == null || activity.isFinishing())) {
149
+        if (reactInstanceManager != null && (activity == null || activity.isFinishing())) {
219 150
             Log.i(TAG, "Destroying ReactInstanceManager");
220
-            mReactInstanceManager.onHostDestroy();
151
+            reactInstanceManager.onHostDestroy();
221 152
             RctManager.getInstance().onDestroy();
222 153
         } else {
223 154
             Log.d(TAG, "Not destroying ReactInstanceManager");
@@ -226,23 +157,23 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
226 157
 
227 158
     @CallSuper
228 159
     public void push(Screen screen) {
229
-        StyleHelper.updateStyles(mToolbar, screen);
230
-        if (mToolbar != null) {
231
-            mToolbar.update(screen);
160
+        StyleHelper.updateStyles(toolbar, screen);
161
+        if (toolbar != null) {
162
+            toolbar.update(screen);
232 163
 
233 164
             if (getCurrentNavigatorId().equals(screen.navigatorId) &&
234 165
                     getScreenStackSize() >= 1) {
235
-                mToolbar.setNavUpButton(screen);
166
+                toolbar.setNavUpButton(screen);
236 167
             }
237 168
         }
238 169
     }
239 170
 
240 171
     @CallSuper
241 172
     public Screen pop(String navigatorId) {
242
-        if (mToolbar != null &&
173
+        if (toolbar != null &&
243 174
                 getCurrentNavigatorId().equals(navigatorId) &&
244 175
                 getScreenStackSize() <= 2) {
245
-            mToolbar.setNavUpButton();
176
+            toolbar.setNavUpButton();
246 177
         }
247 178
 
248 179
         return null;
@@ -250,8 +181,8 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
250 181
 
251 182
     @CallSuper
252 183
     public Screen popToRoot(String navigatorId) {
253
-        if (mToolbar != null) {
254
-            mToolbar.setNavUpButton();
184
+        if (toolbar != null) {
185
+            toolbar.setNavUpButton();
255 186
         }
256 187
 
257 188
         return null;
@@ -259,9 +190,9 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
259 190
 
260 191
     @CallSuper
261 192
     public Screen resetTo(Screen screen) {
262
-        StyleHelper.updateStyles(mToolbar, screen);
263
-        if (mToolbar != null) {
264
-            mToolbar.setNavUpButton();
193
+        StyleHelper.updateStyles(toolbar, screen);
194
+        if (toolbar != null) {
195
+            toolbar.setNavUpButton();
265 196
         }
266 197
 
267 198
         return null;
@@ -286,26 +217,26 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
286 217
     @Override
287 218
     public void onConfigurationChanged(Configuration newConfig) {
288 219
         super.onConfigurationChanged(newConfig);
289
-        if (mDrawerToggle != null) {
290
-            mDrawerToggle.onConfigurationChanged(newConfig);
220
+        if (drawerToggle != null) {
221
+            drawerToggle.onConfigurationChanged(newConfig);
291 222
         }
292 223
     }
293 224
 
294 225
     @Override
295 226
     public boolean onCreateOptionsMenu(Menu menu) {
296
-        mMenu = menu;
227
+        this.menu = menu;
297 228
         Screen currentScreen = getCurrentScreen();
298
-        if (mToolbar != null && currentScreen != null && !isFinishing()) {
299
-            mToolbar.setupToolbarButtonsAsync(currentScreen);
229
+        if (toolbar != null && currentScreen != null && !isFinishing()) {
230
+            toolbar.setupToolbarButtonsAsync(currentScreen);
300 231
         }
301 232
         return super.onCreateOptionsMenu(menu);
302 233
     }
303 234
 
304 235
     @Override
305 236
     public boolean onOptionsItemSelected(MenuItem item) {
306
-        if (mDrawerToggle != null &&
237
+        if (drawerToggle != null &&
307 238
                 getScreenStackSize() == 1 &&
308
-                mDrawerToggle.onOptionsItemSelected(item)) {
239
+                drawerToggle.onOptionsItemSelected(item)) {
309 240
             return true;
310 241
         }
311 242
 
@@ -324,42 +255,42 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
324 255
     @Override
325 256
     public void onPostCreate(Bundle savedInstanceState) {
326 257
         super.onPostCreate(savedInstanceState);
327
-        if (mDrawerToggle != null) {
328
-            mDrawerToggle.syncState();
258
+        if (drawerToggle != null) {
259
+            drawerToggle.syncState();
329 260
         }
330 261
     }
331 262
 
332 263
     public Menu getMenu() {
333
-        return mMenu;
264
+        return menu;
334 265
     }
335 266
 
336 267
     @Override
337 268
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
338
-        if (mReactInstanceManager != null) {
339
-            mReactInstanceManager.onActivityResult(requestCode, resultCode, data);
269
+        if (reactInstanceManager != null) {
270
+            reactInstanceManager.onActivityResult(requestCode, resultCode, data);
340 271
         }
341 272
     }
342 273
 
343 274
     @Override
344 275
     public boolean onKeyUp(int keyCode, KeyEvent event) {
345
-        if (mReactInstanceManager != null &&
346
-                mReactInstanceManager.getDevSupportManager().getDevSupportEnabled()) {
276
+        if (reactInstanceManager != null &&
277
+                reactInstanceManager.getDevSupportManager().getDevSupportEnabled()) {
347 278
             if (keyCode == KeyEvent.KEYCODE_MENU) {
348
-                mReactInstanceManager.showDevOptionsDialog();
279
+                reactInstanceManager.showDevOptionsDialog();
349 280
                 return true;
350 281
             }
351 282
             if (keyCode == KeyEvent.KEYCODE_R && !(getCurrentFocus() instanceof EditText)) {
352 283
                 // Enable double-tap-R-to-reload
353
-                if (mDoRefresh) {
354
-                    mReactInstanceManager.getDevSupportManager().handleReloadJS();
355
-                    mDoRefresh = false;
284
+                if (shouldRefreshOnRR) {
285
+                    reactInstanceManager.getDevSupportManager().handleReloadJS();
286
+                    shouldRefreshOnRR = false;
356 287
                 } else {
357
-                    mDoRefresh = true;
288
+                    shouldRefreshOnRR = true;
358 289
                     new Handler().postDelayed(
359 290
                             new Runnable() {
360 291
                                 @Override
361 292
                                 public void run() {
362
-                                    mDoRefresh = false;
293
+                                    shouldRefreshOnRR = false;
363 294
                                 }
364 295
                             },
365 296
                             200);
@@ -388,8 +319,8 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
388 319
 
389 320
         if (getScreenStackSize() > 1) {
390 321
             pop(getCurrentNavigatorId());
391
-        } else if (mReactInstanceManager != null) {
392
-            mReactInstanceManager.onBackPressed();
322
+        } else if (reactInstanceManager != null) {
323
+            reactInstanceManager.onBackPressed();
393 324
         } else {
394 325
             super.onBackPressed();
395 326
         }
@@ -405,47 +336,47 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
405 336
             return;
406 337
         }
407 338
 
408
-        mDrawerStack = new ScreenStack(this);
339
+        drawerStack = new ScreenStack(this);
409 340
         FrameLayout drawerFrame = (FrameLayout) findViewById(drawerFrameId);
410
-        drawerFrame.addView(mDrawerStack);
411
-        mDrawerStack.push(drawer.left);
341
+        drawerFrame.addView(drawerStack);
342
+        drawerStack.push(drawer.left);
412 343
 
413
-        mDrawerLayout = (DrawerLayout) findViewById(drawerLayoutId);
414
-        mDrawerToggle = mToolbar.setupDrawer(mDrawerLayout, drawer.left, screen);
344
+        drawerLayout = (DrawerLayout) findViewById(drawerLayoutId);
345
+        drawerToggle = toolbar.setupDrawer(drawerLayout, drawer.left, screen);
415 346
     }
416 347
 
417 348
     public void setNavigationButtons(ReadableMap buttons) {
418
-        if (mToolbar == null) {
349
+        if (toolbar == null) {
419 350
             return;
420 351
         }
421 352
         getCurrentScreen().setButtons(buttons);
422
-        mToolbar.setupToolbarButtonsAsync(getCurrentScreen());
353
+        toolbar.setupToolbarButtonsAsync(getCurrentScreen());
423 354
     }
424 355
 
425 356
     public void setNavigationTitle(ReadableMap title) {
426
-        if (mToolbar == null) {
357
+        if (toolbar == null) {
427 358
             return;
428 359
         }
429 360
 
430
-        mToolbar.setTitle(title.getString(KEY_TITLE));
361
+        toolbar.setTitle(title.getString(KEY_TITLE));
431 362
     }
432 363
 
433 364
     public void toggleNavigationBar(ReadableMap params) {
434
-        if (mToolbar == null) {
365
+        if (toolbar == null) {
435 366
             return;
436 367
         }
437 368
 
438 369
         boolean hide = params.getBoolean(KEY_HIDDEN);
439 370
         boolean animated = params.getBoolean(KEY_ANIMATED);
440 371
         if (hide) {
441
-            mToolbar.hideToolbar(animated);
372
+            toolbar.hideToolbar(animated);
442 373
         } else {
443
-            mToolbar.showToolbar(animated);
374
+            toolbar.showToolbar(animated);
444 375
         }
445 376
     }
446 377
 
447 378
     public void toggleDrawer(ReadableMap params) {
448
-        if (mToolbar == null || mDrawerToggle == null) {
379
+        if (toolbar == null || drawerToggle == null) {
449 380
             return;
450 381
         }
451 382
 
@@ -454,13 +385,13 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
454 385
         String to = params.getString(KEY_TO);
455 386
         switch (to) {
456 387
             case "open":
457
-                mToolbar.showDrawer(animated);
388
+                toolbar.showDrawer(animated);
458 389
                 break;
459 390
             case "closed":
460
-                mToolbar.hideDrawer(animated);
391
+                toolbar.hideDrawer(animated);
461 392
                 break;
462 393
             default:
463
-                mToolbar.toggleDrawer(animated);
394
+                toolbar.toggleDrawer(animated);
464 395
                 break;
465 396
         }
466 397
     }

+ 14
- 15
android/app/src/main/java/com/reactnativenavigation/activities/BottomTabActivity.java View File

@@ -11,7 +11,6 @@ import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
11 11
 import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
12 12
 import com.facebook.react.bridge.ReadableMap;
13 13
 import com.reactnativenavigation.R;
14
-import com.reactnativenavigation.core.RctManager;
15 14
 import com.reactnativenavigation.core.objects.Drawer;
16 15
 import com.reactnativenavigation.core.objects.Screen;
17 16
 import com.reactnativenavigation.utils.StyleHelper;
@@ -44,10 +43,10 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
44 43
     @Override
45 44
     protected void handleOnCreate() {
46 45
         super.handleOnCreate();
47
-        mReactInstanceManager = RctManager.getInstance().getReactInstanceManager();
46
+        reactInstanceManager = RctManager.getInstance().getReactInstanceManager();
48 47
 
49 48
         setContentView(R.layout.bottom_tab_activity);
50
-        mToolbar = (RnnToolBar) findViewById(R.id.toolbar);
49
+        toolbar = (RnnToolBar) findViewById(R.id.toolbar);
51 50
         mBottomNavigation = (AHBottomNavigation) findViewById(R.id.bottom_tab_bar);
52 51
         mContentFrame = (CoordinatorLayout) findViewById(R.id.contentFrame);
53 52
 
@@ -68,21 +67,21 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
68 67
     }
69 68
 
70 69
     private void setupPages(ArrayList<Screen> screens) {
71
-        new SetupTabsTask(this, mToolbar, screens).execute();
70
+        new SetupTabsTask(this, toolbar, screens).execute();
72 71
     }
73 72
 
74 73
     private void setupToolbar(ArrayList<Screen> screens) {
75
-        mToolbar.setScreens(screens);
74
+        toolbar.setScreens(screens);
76 75
         Screen initialScreen = screens.get(0);
77
-        mToolbar.update(initialScreen);
78
-        StyleHelper.updateStyles(mToolbar, initialScreen);
76
+        toolbar.update(initialScreen);
77
+        StyleHelper.updateStyles(toolbar, initialScreen);
79 78
     }
80 79
 
81 80
     @Override
82 81
     protected void onResume() {
83 82
         super.onResume();
84 83
         if (mScreenStacks != null) {
85
-            StyleHelper.updateStyles(mToolbar, getCurrentScreen());
84
+            StyleHelper.updateStyles(toolbar, getCurrentScreen());
86 85
         }
87 86
     }
88 87
 
@@ -110,7 +109,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
110 109
                 stack.push(screen);
111 110
             }
112 111
         }
113
-        StyleHelper.updateStyles(mToolbar, getCurrentScreen());
112
+        StyleHelper.updateStyles(toolbar, getCurrentScreen());
114 113
 
115 114
         if (shouldToggleTabs(screen)) {
116 115
             toggleTabs(screen.bottomTabsHidden, false);
@@ -124,7 +123,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
124 123
             if (stack.peek().navigatorId.equals(navigatorId)) {
125 124
                 Screen popped = stack.pop();
126 125
                 Screen currentScreen = getCurrentScreen();
127
-                StyleHelper.updateStyles(mToolbar, currentScreen);
126
+                StyleHelper.updateStyles(toolbar, currentScreen);
128 127
 
129 128
                 if (shouldToggleTabs(currentScreen)) {
130 129
                     toggleTabs(currentScreen.bottomTabsHidden, false);
@@ -143,7 +142,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
143 142
             if (stack.peek().navigatorId.equals(navigatorId)) {
144 143
                 Screen popped = stack.popToRoot();
145 144
                 Screen currentScreen = getCurrentScreen();
146
-                StyleHelper.updateStyles(mToolbar, currentScreen);
145
+                StyleHelper.updateStyles(toolbar, currentScreen);
147 146
 
148 147
                 if (shouldToggleTabs(currentScreen)) {
149 148
                     toggleTabs(currentScreen.bottomTabsHidden, false);
@@ -167,7 +166,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
167 166
 
168 167
     public Screen resetTo(Screen screen) {
169 168
         super.resetTo(screen);
170
-        StyleHelper.updateStyles(mToolbar, screen);
169
+        StyleHelper.updateStyles(toolbar, screen);
171 170
         return mScreenStacks.get(mCurrentStackPosition).resetTo(screen);
172 171
     }
173 172
 
@@ -196,13 +195,13 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
196 195
         mScreenStacks.get(position).addToScreen(mContentFrame);
197 196
 
198 197
         mCurrentStackPosition = position;
199
-        StyleHelper.updateStyles(mToolbar, getCurrentScreen());
198
+        StyleHelper.updateStyles(toolbar, getCurrentScreen());
200 199
 
201 200
         // Hide or show back button if needed
202 201
         if (getScreenStackSize() > 1) {
203
-            mToolbar.setNavUpButton(getCurrentScreen());
202
+            toolbar.setNavUpButton(getCurrentScreen());
204 203
         } else {
205
-            mToolbar.setNavUpButton();
204
+            toolbar.setNavUpButton();
206 205
         }
207 206
     }
208 207
 

+ 33
- 0
android/app/src/main/java/com/reactnativenavigation/activities/NavigationActivity.java View File

@@ -0,0 +1,33 @@
1
+package com.reactnativenavigation.activities;
2
+
3
+import android.os.Bundle;
4
+
5
+public class NavigationActivity extends BaseReactActivity {
6
+
7
+    @Override
8
+    protected void onCreate(Bundle savedInstanceState) {
9
+        super.onCreate(savedInstanceState);
10
+        startReactContextOnceInBackgroundAndExecuteJS();
11
+    }
12
+
13
+    private void startReactContextOnceInBackgroundAndExecuteJS() {
14
+        if (!getReactInstanceManager().hasStartedCreatingInitialContext()) {
15
+            getReactInstanceManager().createReactContextInBackground();
16
+        }
17
+    }
18
+
19
+    @Override
20
+    protected String getCurrentNavigatorId() {
21
+        return null;
22
+    }
23
+
24
+    @Override
25
+    public int getScreenStackSize() {
26
+        return 0;
27
+    }
28
+
29
+    @Override
30
+    protected void removeAllReactViews() {
31
+
32
+    }
33
+}

+ 0
- 54
android/app/src/main/java/com/reactnativenavigation/activities/RootActivity.java View File

@@ -1,54 +0,0 @@
1
-package com.reactnativenavigation.activities;
2
-
3
-import android.view.ViewGroup;
4
-
5
-import com.facebook.react.ReactRootView;
6
-import com.reactnativenavigation.core.objects.Screen;
7
-
8
-/**
9
- * This activity is used to start the JS execution where we load our actual app/screens (index.android.js)
10
- * Triggering react context initialization execute global code before any {@link ReactRootView}
11
- * are displayed.
12
- * <p>Only your MainActivity or activities with {@code action.MAIN} and {@code category.LAUNCHER}
13
- * should extend this activity.
14
- * Created by guyc on 13/04/16.
15
- */
16
-public class RootActivity extends BaseReactActivity {
17
-
18
-    @Override
19
-    protected void handleOnCreate() {
20
-        super.handleOnCreate();
21
-        if (!getReactInstanceManager().hasStartedCreatingInitialContext()) {
22
-            // Trigger react context initialization, global javascript code will now execute
23
-            getReactInstanceManager().createReactContextInBackground();
24
-        }
25
-    }
26
-
27
-    @Override
28
-    protected void onPause() {
29
-        super.onPause();
30
-        finish();
31
-    }
32
-
33
-    // No need to implement stack interface since this activity is only used to start other
34
-    // activities such as TabActivity or SingleScreenActivity.
35
-    @Override
36
-    public Screen getCurrentScreen() {
37
-        return null;
38
-    }
39
-
40
-    @Override
41
-    public String getCurrentNavigatorId() {
42
-        return null;
43
-    }
44
-
45
-    @Override
46
-    public int getScreenStackSize() {
47
-        return 0;
48
-    }
49
-
50
-    @Override
51
-    public void removeAllReactViews() {
52
-
53
-    }
54
-}

+ 7
- 8
android/app/src/main/java/com/reactnativenavigation/activities/SingleScreenActivity.java View File

@@ -4,7 +4,6 @@ import android.support.design.widget.CoordinatorLayout;
4 4
 
5 5
 import com.facebook.react.bridge.ReadableMap;
6 6
 import com.reactnativenavigation.R;
7
-import com.reactnativenavigation.core.RctManager;
8 7
 import com.reactnativenavigation.core.objects.Drawer;
9 8
 import com.reactnativenavigation.core.objects.Screen;
10 9
 import com.reactnativenavigation.utils.StyleHelper;
@@ -22,10 +21,10 @@ public class SingleScreenActivity extends BaseReactActivity {
22 21
     @Override
23 22
     protected void handleOnCreate() {
24 23
         super.handleOnCreate();
25
-        mReactInstanceManager = RctManager.getInstance().getReactInstanceManager();
24
+        reactInstanceManager = RctManager.getInstance().getReactInstanceManager();
26 25
 
27 26
         setContentView(R.layout.single_screen_activity);
28
-        mToolbar = (RnnToolBar) findViewById(R.id.toolbar);
27
+        toolbar = (RnnToolBar) findViewById(R.id.toolbar);
29 28
 
30 29
         final Screen screen = (Screen) getIntent().getSerializableExtra(EXTRA_SCREEN);
31 30
         final Drawer drawer = (Drawer) getIntent().getSerializableExtra(DRAWER_PARAMS);
@@ -50,21 +49,21 @@ public class SingleScreenActivity extends BaseReactActivity {
50 49
     }
51 50
 
52 51
     protected void setupToolbar(Screen screen) {
53
-        StyleHelper.updateStyles(mToolbar, screen);
52
+        StyleHelper.updateStyles(toolbar, screen);
54 53
     }
55 54
 
56 55
     @Override
57 56
     public void push(Screen screen) {
58 57
         super.push(screen);
59 58
         mScreenStack.push(screen);
60
-        StyleHelper.updateStyles(mToolbar, screen);
59
+        StyleHelper.updateStyles(toolbar, screen);
61 60
     }
62 61
 
63 62
     @Override
64 63
     public Screen pop(String navigatorId) {
65 64
         super.pop(navigatorId);
66 65
         Screen popped = mScreenStack.pop();
67
-        StyleHelper.updateStyles(mToolbar, getCurrentScreen());
66
+        StyleHelper.updateStyles(toolbar, getCurrentScreen());
68 67
         return popped;
69 68
     }
70 69
 
@@ -72,7 +71,7 @@ public class SingleScreenActivity extends BaseReactActivity {
72 71
     public Screen popToRoot(String navigatorId) {
73 72
         super.popToRoot(navigatorId);
74 73
         Screen screen = mScreenStack.popToRoot();
75
-        StyleHelper.updateStyles(mToolbar, getCurrentScreen());
74
+        StyleHelper.updateStyles(toolbar, getCurrentScreen());
76 75
         return screen;
77 76
     }
78 77
 
@@ -80,7 +79,7 @@ public class SingleScreenActivity extends BaseReactActivity {
80 79
     public Screen resetTo(Screen screen) {
81 80
         super.resetTo(screen);
82 81
         Screen popped = mScreenStack.resetTo(screen);
83
-        StyleHelper.updateStyles(mToolbar, screen);
82
+        StyleHelper.updateStyles(toolbar, screen);
84 83
         return popped;
85 84
     }
86 85
 

+ 7
- 9
android/app/src/main/java/com/reactnativenavigation/activities/TabActivity.java View File

@@ -2,11 +2,9 @@ package com.reactnativenavigation.activities;
2 2
 
3 3
 import android.support.v4.view.ViewPager;
4 4
 import android.view.Menu;
5
-import android.view.ViewGroup;
6 5
 
7 6
 import com.reactnativenavigation.R;
8 7
 import com.reactnativenavigation.adapters.ViewPagerAdapter;
9
-import com.reactnativenavigation.core.RctManager;
10 8
 import com.reactnativenavigation.core.objects.Screen;
11 9
 import com.reactnativenavigation.utils.StyleHelper;
12 10
 import com.reactnativenavigation.views.RnnTabLayout;
@@ -29,10 +27,10 @@ public class TabActivity extends BaseReactActivity {
29 27
     @Override
30 28
     protected void handleOnCreate() {
31 29
         super.handleOnCreate();
32
-        mReactInstanceManager = RctManager.getInstance().getReactInstanceManager();
30
+        reactInstanceManager = RctManager.getInstance().getReactInstanceManager();
33 31
 
34 32
         setContentView(R.layout.tab_activity);
35
-        mToolbar = (RnnToolBar) findViewById(R.id.toolbar);
33
+        toolbar = (RnnToolBar) findViewById(R.id.toolbar);
36 34
         mTabLayout = (RnnTabLayout) findViewById(R.id.tabLayout);
37 35
         mViewPager = (ViewPager) findViewById(R.id.viewPager);
38 36
 
@@ -44,8 +42,8 @@ public class TabActivity extends BaseReactActivity {
44 42
 
45 43
     private void setupToolbar(ArrayList<Screen> screens) {
46 44
         Screen initialScreen = screens.get(0);
47
-        mToolbar.setScreens(screens);
48
-        mToolbar.update(initialScreen);
45
+        toolbar.setScreens(screens);
46
+        toolbar.update(initialScreen);
49 47
         setNavigationStyle(initialScreen);
50 48
     }
51 49
 
@@ -54,7 +52,7 @@ public class TabActivity extends BaseReactActivity {
54 52
     }
55 53
 
56 54
     private void setupViewPager(ArrayList<Screen> screens) {
57
-        mAdapter = new ViewPagerAdapter(this, mViewPager, mToolbar, screens);
55
+        mAdapter = new ViewPagerAdapter(this, mViewPager, toolbar, screens);
58 56
         mViewPager.setAdapter(mAdapter);
59 57
         mTabLayout.setupWithViewPager(mViewPager);
60 58
         mTabLayout.setOnTabSelectedListener(mAdapter);
@@ -64,7 +62,7 @@ public class TabActivity extends BaseReactActivity {
64 62
     @Override
65 63
     public boolean onCreateOptionsMenu(Menu menu) {
66 64
         boolean ret = super.onCreateOptionsMenu(menu);
67
-        mToolbar.handleOnCreateOptionsMenuAsync();
65
+        toolbar.handleOnCreateOptionsMenuAsync();
68 66
         return ret;
69 67
     }
70 68
 
@@ -76,7 +74,7 @@ public class TabActivity extends BaseReactActivity {
76 74
     @Override
77 75
     public void push(Screen screen) {
78 76
         super.push(screen);
79
-        StyleHelper.updateStyles(mToolbar, screen);
77
+        StyleHelper.updateStyles(toolbar, screen);
80 78
         mAdapter.push(screen);
81 79
     }
82 80
 

+ 0
- 1
android/app/src/main/java/com/reactnativenavigation/adapters/ViewPagerAdapter.java View File

@@ -9,7 +9,6 @@ import android.view.ViewGroup;
9 9
 import com.facebook.react.bridge.Arguments;
10 10
 import com.facebook.react.bridge.WritableMap;
11 11
 import com.reactnativenavigation.activities.BaseReactActivity;
12
-import com.reactnativenavigation.core.RctManager;
13 12
 import com.reactnativenavigation.core.objects.Screen;
14 13
 import com.reactnativenavigation.utils.StyleHelper;
15 14
 import com.reactnativenavigation.views.RnnToolBar;

+ 24
- 0
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactEventEmitter.java View File

@@ -0,0 +1,24 @@
1
+package com.reactnativenavigation.bridge;
2
+
3
+import com.facebook.react.bridge.WritableMap;
4
+import com.facebook.react.modules.core.DeviceEventManagerModule;
5
+import com.reactnativenavigation.core.objects.Screen;
6
+
7
+public class NavigationReactEventEmitter {
8
+
9
+    private static final String KEY_EVENT_ID = "id";
10
+    private static final String KEY_EVENT_TYPE = "type";
11
+    private static final String EVENT_TYPE = "NavBarButtonPress";
12
+
13
+    public void sendEvent(String eventName, String navigatorEventId, WritableMap params) {
14
+        DeviceEventManagerModule.RCTDeviceEventEmitter eventEmitter = getEventEmitter();
15
+        if (eventEmitter == null) {
16
+            return;
17
+        }
18
+
19
+        params.putString(KEY_EVENT_TYPE, EVENT_TYPE);
20
+        params.putString(KEY_EVENT_ID, eventName);
21
+        params.putString(Screen.KEY_NAVIGATOR_EVENT_ID, navigatorEventId);
22
+        eventEmitter.emit(navigatorEventId, params);
23
+    }
24
+}

+ 0
- 204
android/app/src/main/java/com/reactnativenavigation/core/RctManager.java View File

@@ -1,204 +0,0 @@
1
-package com.reactnativenavigation.core;
2
-
3
-import android.app.Application;
4
-import android.util.Log;
5
-
6
-import com.facebook.react.LifecycleState;
7
-import com.facebook.react.ReactInstanceManager;
8
-import com.facebook.react.ReactPackage;
9
-import com.facebook.react.bridge.JavaJSExecutor;
10
-import com.facebook.react.bridge.ReactContext;
11
-import com.facebook.react.bridge.ReactContextBaseJavaModule;
12
-import com.facebook.react.bridge.WritableMap;
13
-import com.facebook.react.devsupport.DevSupportManager;
14
-import com.facebook.react.devsupport.ReactInstanceDevCommandsHandler;
15
-import com.reactnativenavigation.activities.BaseReactActivity;
16
-import com.reactnativenavigation.core.objects.Screen;
17
-import com.reactnativenavigation.utils.ContextProvider;
18
-import com.reactnativenavigation.utils.ReflectionUtils;
19
-
20
-import static com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
21
-
22
-/**
23
- * Created by guyc on 22/02/16.
24
- */
25
-public class RctManager {
26
-    private static final String TAG = "RctManager";
27
-    private static final String KEY_EVENT_ID = "id";
28
-    private static final String KEY_EVENT_TYPE = "type";
29
-    private static final String EVENT_TYPE = "NavBarButtonPress";
30
-    private static RctManager sInstance;
31
-
32
-    private ReactInstanceManager mReactManager;
33
-
34
-    private RctManager() {
35
-        // Singleton
36
-    }
37
-
38
-    public static synchronized RctManager getInstance() {
39
-        if (sInstance == null) {
40
-            sInstance = new RctManager();
41
-        }
42
-        return sInstance;
43
-    }
44
-
45
-    public ReactInstanceManager getReactInstanceManager() {
46
-        return mReactManager;
47
-    }
48
-
49
-    public boolean isInitialized() {
50
-        return mReactManager != null;
51
-    }
52
-
53
-    public void init(BaseReactActivity context) {
54
-        createReactInstanceManager(context);
55
-    }
56
-
57
-    /**
58
-     * Creates a React Instance Manager associated with this component name
59
-     */
60
-    public ReactInstanceManager createReactInstanceManager(BaseReactActivity reactActivity) {
61
-        ReactInstanceManager.Builder builder = ReactInstanceManager.builder()
62
-                .setApplication((Application) reactActivity.getApplicationContext())
63
-                .setJSMainModuleName(reactActivity.getJSMainModuleName())
64
-                .setUseDeveloperSupport(reactActivity.getUseDeveloperSupport())
65
-                .setInitialLifecycleState(LifecycleState.BEFORE_RESUME);
66
-
67
-        for (ReactPackage reactPackage : reactActivity.getPackages()) {
68
-            builder.addPackage(reactPackage);
69
-        }
70
-
71
-        String jsBundleFile = reactActivity.getJSBundleFile();
72
-
73
-        if (jsBundleFile != null) {
74
-            builder.setJSBundleFile(jsBundleFile);
75
-        } else {
76
-            builder.setBundleAssetName(reactActivity.getBundleAssetName());
77
-        }
78
-
79
-        mReactManager = builder.build();
80
-        if (reactActivity.getUseDeveloperSupport()) {
81
-            setupDevSupportHandler(mReactManager);
82
-        }
83
-        return mReactManager;
84
-    }
85
-
86
-    /**
87
-     * Inject our CustomDevCommandsHandler to {@code reactInstanceManager} so we can detect when the bundle was
88
-     * parsed and is about to load.
89
-     * @param reactInstanceManager
90
-     */
91
-    private void setupDevSupportHandler(ReactInstanceManager reactInstanceManager) {
92
-        final ReactInstanceDevCommandsHandler devInterface = (ReactInstanceDevCommandsHandler)
93
-                ReflectionUtils.getDeclaredField(reactInstanceManager, "mDevInterface");
94
-        if (devInterface == null) {
95
-            Log.e(TAG, "Could not get field mDevInterface");
96
-            return;
97
-        }
98
-
99
-        // Create customDevCommandsHandler
100
-        CustomDevCommandsHandler customDevCommandsHandler = new CustomDevCommandsHandler(devInterface);
101
-        boolean success = ReflectionUtils.setField(reactInstanceManager, "mDevInterface", customDevCommandsHandler);
102
-        if (!success) {
103
-            Log.e(TAG, "Could not set field mDevInterface");
104
-            return;
105
-        }
106
-
107
-        // Set customDevCommandsHandler in devSupportManager. Fun =).
108
-        DevSupportManager devSupportManager = (DevSupportManager)
109
-                ReflectionUtils.getDeclaredField(reactInstanceManager, "mDevSupportManager");
110
-        if (devSupportManager == null) {
111
-            Log.e(TAG, "Could not get field mDevSupportManager");
112
-            return;
113
-        }
114
-
115
-        success = ReflectionUtils.setField(devSupportManager, "mReactInstanceCommandsHandler", customDevCommandsHandler);
116
-        if (!success) {
117
-            Log.e(TAG, "Could not set field mReactInstanceCommandsHandler");
118
-        }
119
-    }
120
-
121
-    public <T extends ReactContextBaseJavaModule> T getNativeModule(Class<T> nativeModuleClass) {
122
-        if (mReactManager == null || mReactManager.getCurrentReactContext() == null) {
123
-            return null;
124
-        }
125
-
126
-        return mReactManager.getCurrentReactContext().getNativeModule(nativeModuleClass);
127
-    }
128
-
129
-    /**
130
-     * Sends an event to JavaScript using <a href="https://facebook.github.io/react-native/docs/native-modules-android.html#sending-events-to-javascript">RCTDeviceEventEmitter</a>
131
-     * @param eventName Name of the event
132
-     * @param params Event params
133
-     * @param screen screen which should receive the event
134
-     */
135
-    public void sendEvent(String eventName, Screen screen, WritableMap params) {
136
-        RCTDeviceEventEmitter eventEmitter = getEventEmitter();
137
-        if (eventEmitter == null) {
138
-            return;
139
-        }
140
-
141
-        params.putString(KEY_EVENT_TYPE, EVENT_TYPE);
142
-        params.putString(KEY_EVENT_ID, eventName);
143
-        params.putString(Screen.KEY_NAVIGATOR_EVENT_ID, screen.navigatorEventId);
144
-        eventEmitter.emit(screen.navigatorEventId, params);
145
-    }
146
-
147
-    private RCTDeviceEventEmitter getEventEmitter() {
148
-        if (mReactManager == null) {
149
-            return null;
150
-        }
151
-
152
-        ReactContext currentReactContext = mReactManager.getCurrentReactContext();
153
-        if (currentReactContext == null) {
154
-            return null;
155
-        }
156
-
157
-        return currentReactContext.getJSModule(RCTDeviceEventEmitter.class);
158
-    }
159
-
160
-    public void onDestroy() {
161
-        mReactManager = null;
162
-        sInstance = null;
163
-    }
164
-
165
-    /**
166
-     * Proxy for {@link ReactInstanceDevCommandsHandler} used by {@link DevSupportManager} for requesting React
167
-     * instance recreation. Used to notify {@link BaseReactActivity} that the bundle has been reloaded.
168
-     */
169
-    private static class CustomDevCommandsHandler implements ReactInstanceDevCommandsHandler {
170
-        private ReactInstanceDevCommandsHandler mCommandsHandler;
171
-
172
-        public CustomDevCommandsHandler(ReactInstanceDevCommandsHandler commandsHandler) {
173
-            mCommandsHandler = commandsHandler;
174
-        }
175
-
176
-        @Override
177
-        public void onReloadWithJSDebugger(JavaJSExecutor.Factory proxyExecutorFactory) {
178
-            onJSBundleReloaded();
179
-            mCommandsHandler.onReloadWithJSDebugger(proxyExecutorFactory);
180
-        }
181
-
182
-        @Override
183
-        public void onJSBundleLoadedFromServer() {
184
-            onJSBundleReloaded();
185
-            mCommandsHandler.onJSBundleLoadedFromServer();
186
-        }
187
-
188
-        /**
189
-         * Detach previously added ReactRootViews before handling bundle.
190
-         */
191
-        private void onJSBundleReloaded() {
192
-            BaseReactActivity context = ContextProvider.getActivityContext();
193
-            if (context != null) {
194
-                context.onJSBundleReloaded();
195
-            }
196
-        }
197
-
198
-        @Override
199
-        public void toggleElementInspector() {
200
-            mCommandsHandler.toggleElementInspector();
201
-        }
202
-    }
203
-}
204
-

+ 69
- 0
android/app/src/main/java/com/reactnativenavigation/react/JsDevReloadListenerReplacer.java View File

@@ -0,0 +1,69 @@
1
+package com.reactnativenavigation.react;
2
+
3
+import com.facebook.react.ReactInstanceManager;
4
+import com.facebook.react.bridge.JavaJSExecutor;
5
+import com.facebook.react.devsupport.DevSupportManager;
6
+import com.facebook.react.devsupport.ReactInstanceDevCommandsHandler;
7
+import com.reactnativenavigation.utils.ReflectionUtils;
8
+
9
+public class JsDevReloadListenerReplacer {
10
+    private final ReactInstanceManager reactInstanceManager;
11
+    private final Listener listener;
12
+
13
+    public interface Listener {
14
+        void onJsDevReload();
15
+    }
16
+
17
+    public JsDevReloadListenerReplacer(ReactInstanceManager reactInstanceManager, Listener listener) {
18
+        this.reactInstanceManager = reactInstanceManager;
19
+        this.listener = listener;
20
+    }
21
+
22
+    public void replace() {
23
+        ReactInstanceDevCommandsHandler originalHandler = getOriginalHandler();
24
+        DevCommandsHandlerProxy proxy = new DevCommandsHandlerProxy(originalHandler, listener);
25
+        replaceInReactInstanceManager(proxy);
26
+        replaceInDevSupportManager(proxy);
27
+    }
28
+
29
+    private void replaceInDevSupportManager(DevCommandsHandlerProxy proxy) {
30
+        DevSupportManager devSupportManager = (DevSupportManager)
31
+                ReflectionUtils.getDeclaredField(reactInstanceManager, "mDevSupportManager");
32
+        ReflectionUtils.setField(devSupportManager, "mReactInstanceCommandsHandler", proxy);
33
+    }
34
+
35
+    private ReactInstanceDevCommandsHandler getOriginalHandler() {
36
+        return (ReactInstanceDevCommandsHandler) ReflectionUtils.getDeclaredField(reactInstanceManager, "mDevInterface");
37
+    }
38
+
39
+    private void replaceInReactInstanceManager(DevCommandsHandlerProxy proxy) {
40
+        ReflectionUtils.setField(reactInstanceManager, "mDevInterface", proxy);
41
+    }
42
+
43
+    private static class DevCommandsHandlerProxy implements ReactInstanceDevCommandsHandler {
44
+        private ReactInstanceDevCommandsHandler originalReactHandler;
45
+        private final Listener listener;
46
+
47
+        public DevCommandsHandlerProxy(ReactInstanceDevCommandsHandler originalReactHandler, Listener listener) {
48
+            this.originalReactHandler = originalReactHandler;
49
+            this.listener = listener;
50
+        }
51
+
52
+        @Override
53
+        public void onReloadWithJSDebugger(JavaJSExecutor.Factory proxyExecutorFactory) {
54
+            listener.onJsDevReload();
55
+            originalReactHandler.onReloadWithJSDebugger(proxyExecutorFactory);
56
+        }
57
+
58
+        @Override
59
+        public void onJSBundleLoadedFromServer() {
60
+            listener.onJsDevReload();
61
+            originalReactHandler.onJSBundleLoadedFromServer();
62
+        }
63
+
64
+        @Override
65
+        public void toggleElementInspector() {
66
+            originalReactHandler.toggleElementInspector();
67
+        }
68
+    }
69
+}

+ 66
- 0
android/app/src/main/java/com/reactnativenavigation/react/NavigationReactInstance.java View File

@@ -0,0 +1,66 @@
1
+package com.reactnativenavigation.react;
2
+
3
+import android.app.Application;
4
+
5
+import com.facebook.react.LifecycleState;
6
+import com.facebook.react.ReactInstanceManager;
7
+import com.facebook.react.ReactPackage;
8
+import com.facebook.react.bridge.ReactContext;
9
+import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
10
+import com.reactnativenavigation.BuildConfig;
11
+
12
+import java.util.List;
13
+
14
+public class NavigationReactInstance {
15
+
16
+    private final ReactInstanceManager reactInstanceManager;
17
+
18
+    public interface ReactContextCreator {
19
+        Application getApplication();
20
+
21
+        List<ReactPackage> createReactPackages();
22
+
23
+        void onJsDevReload();
24
+    }
25
+
26
+    public NavigationReactInstance(final ReactContextCreator reactContextCreator) {
27
+        reactInstanceManager = createReactInstanceManager(reactContextCreator);
28
+
29
+        if (BuildConfig.DEBUG) {
30
+            replaceJsDevReloadListener(reactContextCreator);
31
+        }
32
+    }
33
+
34
+    private RCTDeviceEventEmitter getEventEmitter() {
35
+        ReactContext currentReactContext = reactInstanceManager.getCurrentReactContext();
36
+        if (currentReactContext == null) {
37
+            return null;
38
+        }
39
+
40
+        return currentReactContext.getJSModule(RCTDeviceEventEmitter.class);
41
+    }
42
+
43
+    private void replaceJsDevReloadListener(final ReactContextCreator reactContextCreator) {
44
+        new JsDevReloadListenerReplacer(reactInstanceManager, new JsDevReloadListenerReplacer.Listener() {
45
+            @Override
46
+            public void onJsDevReload() {
47
+                reactContextCreator.onJsDevReload();
48
+            }
49
+        }).replace();
50
+    }
51
+
52
+    private ReactInstanceManager createReactInstanceManager(final ReactContextCreator reactContextCreator) {
53
+        ReactInstanceManager.Builder builder = ReactInstanceManager.builder()
54
+                .setApplication(reactContextCreator.getApplication())
55
+                .setJSMainModuleName("index.android")
56
+                .setBundleAssetName("index.android.bundle")
57
+                .setUseDeveloperSupport(BuildConfig.DEBUG)
58
+                .setInitialLifecycleState(LifecycleState.BEFORE_RESUME);
59
+
60
+        for (ReactPackage reactPackage : reactContextCreator.createReactPackages()) {
61
+            builder.addPackage(reactPackage);
62
+        }
63
+
64
+        return builder.build();
65
+    }
66
+}

+ 0
- 1
android/app/src/main/java/com/reactnativenavigation/views/ScreenStack.java View File

@@ -8,7 +8,6 @@ import android.view.ViewGroup;
8 8
 
9 9
 import com.facebook.react.ReactInstanceManager;
10 10
 import com.reactnativenavigation.activities.BaseReactActivity;
11
-import com.reactnativenavigation.core.RctManager;
12 11
 import com.reactnativenavigation.core.objects.Screen;
13 12
 
14 13
 import java.util.Stack;