Browse Source

Now passing an activity to clearHostOnActivityDestroy (#3133)

- We do that in order to allow the end user to decide
wether they want to destroy the host based on who's
the one calling onDestroy.
Ioannis Kokkinidis 6 years ago
parent
commit
ac95d36753

+ 2
- 1
android/app/src/main/java/com/reactnativenavigation/NavigationApplication.java View File

@@ -1,5 +1,6 @@
1 1
 package com.reactnativenavigation;
2 2
 
3
+import android.app.Activity;
3 4
 import android.app.Application;
4 5
 import android.content.Intent;
5 6
 import android.os.Bundle;
@@ -126,7 +127,7 @@ public abstract class NavigationApplication extends Application implements React
126 127
 
127 128
     public abstract boolean isDebug();
128 129
 
129
-    public boolean clearHostOnActivityDestroy() {
130
+    public boolean clearHostOnActivityDestroy(Activity activity) {
130 131
         return true;
131 132
     }
132 133
 

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/controllers/SplashActivity.java View File

@@ -46,7 +46,7 @@ public abstract class SplashActivity extends AppCompatActivity {
46 46
                 return;
47 47
             }
48 48
             NavigationApplication.instance.getEventEmitter().sendAppLaunchedEvent();
49
-            if (NavigationApplication.instance.clearHostOnActivityDestroy()) {
49
+            if (NavigationApplication.instance.clearHostOnActivityDestroy(this)) {
50 50
                 overridePendingTransition(0, 0);
51 51
                 finish();
52 52
             }

+ 3
- 3
android/app/src/main/java/com/reactnativenavigation/react/NavigationReactGateway.java View File

@@ -64,18 +64,18 @@ public class NavigationReactGateway implements ReactGateway {
64 64
 	}
65 65
 
66 66
 	public void onDestroyApp(Activity activity) {
67
-        if (NavigationApplication.instance.clearHostOnActivityDestroy()) {
67
+        if (NavigationApplication.instance.clearHostOnActivityDestroy(activity)) {
68 68
             getReactInstanceManager().onHostDestroy();
69 69
         } else if (hasStartedCreatingContext() && isInitialized()) {
70 70
             getReactInstanceManager().onHostDestroy(activity);
71 71
         }
72
-        if (NavigationApplication.instance.clearHostOnActivityDestroy()) {
72
+        if (NavigationApplication.instance.clearHostOnActivityDestroy(activity)) {
73 73
             host.clear();
74 74
         }
75 75
     }
76 76
 
77 77
 	public void onPauseActivity(Activity activity) {
78
-        if (NavigationApplication.instance.clearHostOnActivityDestroy()) {
78
+        if (NavigationApplication.instance.clearHostOnActivityDestroy(activity)) {
79 79
             getReactInstanceManager().onHostPause();
80 80
         } else if (hasStartedCreatingContext() && isInitialized()) {
81 81
 		    getReactInstanceManager().onHostPause(activity);