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
 package com.reactnativenavigation;
1
 package com.reactnativenavigation;
2
 
2
 
3
+import android.app.Activity;
3
 import android.app.Application;
4
 import android.app.Application;
4
 import android.content.Intent;
5
 import android.content.Intent;
5
 import android.os.Bundle;
6
 import android.os.Bundle;
126
 
127
 
127
     public abstract boolean isDebug();
128
     public abstract boolean isDebug();
128
 
129
 
129
-    public boolean clearHostOnActivityDestroy() {
130
+    public boolean clearHostOnActivityDestroy(Activity activity) {
130
         return true;
131
         return true;
131
     }
132
     }
132
 
133
 

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

46
                 return;
46
                 return;
47
             }
47
             }
48
             NavigationApplication.instance.getEventEmitter().sendAppLaunchedEvent();
48
             NavigationApplication.instance.getEventEmitter().sendAppLaunchedEvent();
49
-            if (NavigationApplication.instance.clearHostOnActivityDestroy()) {
49
+            if (NavigationApplication.instance.clearHostOnActivityDestroy(this)) {
50
                 overridePendingTransition(0, 0);
50
                 overridePendingTransition(0, 0);
51
                 finish();
51
                 finish();
52
             }
52
             }

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

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