|
@@ -1,26 +1,60 @@
|
1
|
1
|
package com.reactnativenavigation.controllers;
|
2
|
2
|
|
3
|
3
|
import android.content.Intent;
|
|
4
|
+import android.support.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+import com.reactnativenavigation.NavigationApplication;
|
4
|
7
|
|
5
|
8
|
import static android.content.Intent.ACTION_VIEW;
|
6
|
9
|
|
7
|
|
-public class IntentDataHandler {
|
|
10
|
+class IntentDataHandler {
|
8
|
11
|
private static Intent intent;
|
9
|
12
|
|
|
13
|
+ static void onStartApp(Intent intent) {
|
|
14
|
+ setIntentData(intent);
|
|
15
|
+ }
|
|
16
|
+
|
|
17
|
+ static void onResume(Intent intent) {
|
|
18
|
+ if (hasIntentData()) {
|
|
19
|
+ setIntentData(intent);
|
|
20
|
+ } else {
|
|
21
|
+ saveIntentData(intent);
|
|
22
|
+ }
|
|
23
|
+ }
|
|
24
|
+
|
10
|
25
|
static void saveIntentData(Intent intent) {
|
11
|
26
|
IntentDataHandler.intent = intent;
|
12
|
27
|
}
|
13
|
28
|
|
14
|
|
- static boolean hasIntentData() {
|
|
29
|
+ static void onPostResume(Intent intent) {
|
|
30
|
+ if (hasIntentData()) {
|
|
31
|
+ fakeOnNewIntentForLinkingModule(intent);
|
|
32
|
+ clear();
|
|
33
|
+ }
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+ static void onPause(@Nullable Intent intent) {
|
|
37
|
+ if (intent != null) {
|
|
38
|
+ intent.setData(null);
|
|
39
|
+ }
|
|
40
|
+ clear();
|
|
41
|
+ }
|
|
42
|
+
|
|
43
|
+ private static void fakeOnNewIntentForLinkingModule(Intent intent) {
|
|
44
|
+ if (intent != null) {
|
|
45
|
+ NavigationApplication.instance.getReactGateway().onNewIntent(intent);
|
|
46
|
+ }
|
|
47
|
+ }
|
|
48
|
+
|
|
49
|
+ private static boolean hasIntentData() {
|
15
|
50
|
return intent != null;
|
16
|
51
|
}
|
17
|
52
|
|
18
|
|
- static void setIntentData(Intent intent) {
|
19
|
|
- if (IntentDataHandler.intent != null) {
|
|
53
|
+ private static void setIntentData(@Nullable Intent intent) {
|
|
54
|
+ if (intent != null && IntentDataHandler.intent != null) {
|
20
|
55
|
intent.setData(IntentDataHandler.intent.getData());
|
21
|
56
|
intent.putExtras(IntentDataHandler.intent);
|
22
|
57
|
intent.setAction(ACTION_VIEW);
|
23
|
|
- clear();
|
24
|
58
|
}
|
25
|
59
|
}
|
26
|
60
|
|