Selaa lähdekoodia

Add isRootLaunched implementation on Android

returns true if NavigationActivity is resumed (startApp was called)
Guy Carmeli 7 vuotta sitten
vanhempi
commit
6f4aca32a6

+ 5
- 0
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactModule.java Näytä tiedosto

@@ -264,6 +264,11 @@ public class NavigationReactModule extends ReactContextBaseJavaModule {
264 264
         NavigationCommandsHandler.isAppLaunched(promise);
265 265
     }
266 266
 
267
+    @ReactMethod
268
+    public void isRootLaunched(Promise promise) {
269
+        NavigationCommandsHandler.isRootLaunched(promise);
270
+    }
271
+
267 272
     @ReactMethod
268 273
     public void getCurrentlyVisibleScreenId(Promise promise) {
269 274
         NavigationCommandsHandler.getCurrentlyVisibleScreenId(promise);

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java Näytä tiedosto

@@ -543,6 +543,10 @@ public class NavigationCommandsHandler {
543 543
         promise.resolve(isAppLaunched);
544 544
     }
545 545
 
546
+    public static void isRootLaunched(Promise promise) {
547
+        promise.resolve(NavigationActivity.currentActivity != null);
548
+    }
549
+
546 550
     public static void getCurrentlyVisibleScreenId(final Promise promise) {
547 551
         final NavigationActivity currentActivity = NavigationActivity.currentActivity;
548 552
         if (currentActivity == null) {

+ 6
- 1
src/Navigation.js Näytä tiedosto

@@ -166,6 +166,10 @@ async function isAppLaunched() {
166 166
   return await platformSpecific.isAppLaunched();
167 167
 }
168 168
 
169
+async function isRootLaunched() {
170
+  return await platformSpecific.isRootLaunched();
171
+}
172
+
169 173
 function getCurrentlyVisibleScreenId() {
170 174
   return platformSpecific.getCurrentlyVisibleScreenId();
171 175
 }
@@ -187,5 +191,6 @@ export default {
187 191
   setEventHandler: setEventHandler,
188 192
   clearEventHandler: clearEventHandler,
189 193
   handleDeepLink: handleDeepLink,
190
-  isAppLaunched: isAppLaunched
194
+  isAppLaunched: isAppLaunched,
195
+  isRootLaunched: isRootLaunched
191 196
 };

+ 5
- 0
src/deprecated/platformSpecificDeprecated.android.js Näytä tiedosto

@@ -689,6 +689,10 @@ async function isAppLaunched() {
689 689
   return await newPlatformSpecific.isAppLaunched();
690 690
 }
691 691
 
692
+async function isRootLaunched() {
693
+  return await newPlatformSpecific.isRootLaunched();
694
+}
695
+
692 696
 async function getCurrentlyVisibleScreenId() {
693 697
   return await newPlatformSpecific.getCurrentlyVisibleScreenId();
694 698
 }
@@ -724,5 +728,6 @@ export default {
724 728
   showContextualMenu,
725 729
   dismissContextualMenu,
726 730
   isAppLaunched,
731
+  isRootLaunched,
727 732
   getCurrentlyVisibleScreenId
728 733
 };

+ 5
- 0
src/platformSpecific.android.js Näytä tiedosto

@@ -181,6 +181,10 @@ async function isAppLaunched() {
181 181
   return await NativeReactModule.isAppLaunched();
182 182
 }
183 183
 
184
+async function isRootLaunched() {
185
+  return await NativeReactModule.isRootLaunched();
186
+}
187
+
184 188
 async function getCurrentlyVisibleScreenId() {
185 189
   return await NativeReactModule.getCurrentlyVisibleScreenId();
186 190
 }
@@ -220,5 +224,6 @@ module.exports = {
220 224
   dismissContextualMenu,
221 225
   setScreenStyle,
222 226
   isAppLaunched,
227
+  isRootLaunched,
223 228
   getCurrentlyVisibleScreenId
224 229
 };