Преглед изворни кода

When starting the app, pass through extras included in the launch intent (#433)

Matt Davies пре 8 година
родитељ
комит
cc393b6cdf

+ 0
- 30
android/app/src/main/java/com/reactnativenavigation/controllers/DeepLinkHandler.java Прегледај датотеку

@@ -1,30 +0,0 @@
1
-package com.reactnativenavigation.controllers;
2
-
3
-import android.content.Intent;
4
-import android.net.Uri;
5
-
6
-import static android.content.Intent.ACTION_VIEW;
7
-
8
-public class DeepLinkHandler {
9
-    private static Uri deepLink;
10
-
11
-    static void saveDeepLinkData(Uri deepLink) {
12
-        DeepLinkHandler.deepLink = deepLink;
13
-    }
14
-
15
-    static boolean hasDeepLinkData() {
16
-        return deepLink != null;
17
-    }
18
-
19
-    static void setDeepLinkData(Intent intent) {
20
-        if (deepLink != null) {
21
-            intent.setData(deepLink);
22
-            intent.setAction(ACTION_VIEW);
23
-            clear();
24
-        }
25
-    }
26
-
27
-    private static void clear() {
28
-        deepLink = null;
29
-    }
30
-}

+ 30
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/IntentDataHandler.java Прегледај датотеку

@@ -0,0 +1,30 @@
1
+package com.reactnativenavigation.controllers;
2
+
3
+import android.content.Intent;
4
+
5
+import static android.content.Intent.ACTION_VIEW;
6
+
7
+public class IntentDataHandler {
8
+    private static Intent intent;
9
+
10
+    static void saveIntentData(Intent intent) {
11
+        IntentDataHandler.intent = intent;
12
+    }
13
+
14
+    static boolean hasIntentData() {
15
+        return intent != null;
16
+    }
17
+
18
+    static void setIntentData(Intent intent) {
19
+        if (IntentDataHandler.intent != null) {
20
+            intent.setData(IntentDataHandler.intent.getData());
21
+            intent.putExtras(IntentDataHandler.intent);
22
+            intent.setAction(ACTION_VIEW);
23
+            clear();
24
+        }
25
+    }
26
+
27
+    private static void clear() {
28
+        intent = null;
29
+    }
30
+}

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java Прегледај датотеку

@@ -95,8 +95,8 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
95 95
     }
96 96
 
97 97
     private void setDeepLinkData() {
98
-        if (DeepLinkHandler.hasDeepLinkData()) {
99
-            DeepLinkHandler.setDeepLinkData(getIntent());
98
+        if (IntentDataHandler.hasIntentData()) {
99
+            IntentDataHandler.setIntentData(getIntent());
100 100
         }
101 101
     }
102 102
 

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java Прегледај датотеку

@@ -36,7 +36,7 @@ public class NavigationCommandsHandler {
36 36
         } else {
37 37
             intent = new Intent(NavigationApplication.instance, NavigationActivity.class);
38 38
         }
39
-        DeepLinkHandler.setDeepLinkData(intent);
39
+        IntentDataHandler.setIntentData(intent);
40 40
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
41 41
         intent.putExtra(ACTIVITY_PARAMS_BUNDLE, params);
42 42
         NavigationApplication.instance.startActivity(intent);

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/controllers/SplashActivity.java Прегледај датотеку

@@ -16,7 +16,7 @@ public abstract class SplashActivity extends AppCompatActivity {
16 16
     protected void onCreate(@Nullable Bundle savedInstanceState) {
17 17
         super.onCreate(savedInstanceState);
18 18
         setSplashLayout();
19
-        DeepLinkHandler.saveDeepLinkData(getIntent().getData());
19
+        IntentDataHandler.saveIntentData(getIntent());
20 20
     }
21 21
 
22 22
     @Override