git ssb

1+

Daan Patchwork / manyverse



Commit 7c9c002ce40a1fb3937430037f5ddf4561e58f25

dx: maybe a ux commit, improved init of nodejs-project

Andre Staltz committed on 11/9/2018, 3:48:42 PM
Parent: b8c2dd9105ec16155590dece83e50e93c09ea19e

Files changed

android/app/src/main/java/se/manyver/MainActivity.javachanged
android/app/src/main/java/se/manyver/MainActivity.javaView
@@ -37,8 +37,10 @@
3737 // view.setLayoutParams(lp);
3838 // return view;
3939 // }
4040
41+ private RNNodeJsMobileModule nodejsModule;
42+
4143 @Override
4244 protected void onCreate(@Nullable Bundle savedInstanceState) {
4345 super.onCreate(savedInstanceState);
4446 try {
@@ -48,8 +50,16 @@
4850 }
4951 }
5052
5153 void maybeStartNodejs() throws Exception {
54+ if (this.nodejsModule != null) {
55+ try {
56+ this.nodejsModule.startNodeProject("loader.js", Arguments.createMap());
57+ } catch (Exception e) {
58+ Log.e("NODEJS-RN", "startNodeProject failed to run loader.js");
59+ }
60+ return;
61+ }
5262 ReactNativeHost host = MainApplication.instance.getReactNativeHost();
5363 if (host == null) {
5464 throw new Exception("maybeStartNodejs() failed because of no ReactNativeHost");
5565 }
@@ -59,11 +69,11 @@
5969 }
6070 manager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
6171 @Override
6272 public void onReactContextInitialized(ReactContext context) {
63- RNNodeJsMobileModule module = context.getNativeModule(RNNodeJsMobileModule.class);
73+ nodejsModule = context.getNativeModule(RNNodeJsMobileModule.class);
6474 try {
65- module.startNodeProject("loader.js", Arguments.createMap());
75+ nodejsModule.startNodeProject("loader.js", Arguments.createMap());
6676 } catch (Exception e) {
6777 Log.e("NODEJS-RN", "startNodeProject failed to run loader.js");
6878 }
6979 manager.removeReactInstanceEventListener(this);
@@ -86,8 +96,18 @@
8696 super.onPause();
8797 emitIfPossible("paused");
8898 }
8999
100+ // @Override
101+ // protected void onDestroy() {
102+ // super.onDestroy();
103+ // }
104+
105+ // @Override
106+ // public void onReload() {
107+ // super.onReload();
108+ // }
109+
90110 View findViewToBeSearched(final Activity activity) {
91111 View rootView;
92112 rootView = activity.getWindow().getDecorView();
93113 if (rootView == null) return null;

Built with git-ssb-web