ソースを参照

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 年 前
コミット
6c734f107d
共有1 個のファイルを変更した10 個の追加2 個の削除を含む
  1. 10
    2
      android/app/src/main/java/com/reactnativenavigation/react/NavigationReactGateway.java

+ 10
- 2
android/app/src/main/java/com/reactnativenavigation/react/NavigationReactGateway.java ファイルの表示

@@ -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