Pārlūkot izejas kodu

Backwards compatibility for clearHostOnActivityDestroy (#1944)

This commit fixes two issues found in #1838. Fixes #1924
1. Keeps calling the deprecated reactInstanceManager methods when host is cleared
    to not introduce undesired behavior when clearHostOnActivityDestroy return true.
2. call onHostDestroy and onHostPause only if react context exists or is being created.
Guy Carmeli 7 gadus atpakaļ
vecāks
revīzija
6c734f107d

+ 10
- 2
android/app/src/main/java/com/reactnativenavigation/react/NavigationReactGateway.java Parādīt failu

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