2
2
3
3
import android .content .Intent ;
4
4
import android .net .Uri ;
5
+ import android .os .Bundle ;
6
+ import android .widget .SearchView ;
5
7
6
8
import com .RNFetchBlob .Utils .RNFBCookieJar ;
9
+ import com .facebook .react .LifecycleState ;
7
10
import com .facebook .react .bridge .Callback ;
11
+ import com .facebook .react .bridge .LifecycleEventListener ;
8
12
import com .facebook .react .bridge .Promise ;
9
13
import com .facebook .react .bridge .ReactApplicationContext ;
10
14
import com .facebook .react .bridge .ReactContextBaseJavaModule ;
@@ -25,10 +29,12 @@ public class RNFetchBlob extends ReactContextBaseJavaModule {
25
29
static ThreadPoolExecutor threadPool = new ThreadPoolExecutor (5 , 10 , 5000 , TimeUnit .MILLISECONDS , taskQueue );
26
30
static LinkedBlockingQueue <Runnable > fsTaskQueue = new LinkedBlockingQueue <>();
27
31
static ThreadPoolExecutor fsThreadPool = new ThreadPoolExecutor (2 , 10 , 5000 , TimeUnit .MILLISECONDS , taskQueue );
32
+ static public boolean ActionViewVisible = false ;
28
33
29
34
public RNFetchBlob (ReactApplicationContext reactContext ) {
30
35
31
36
super (reactContext );
37
+
32
38
RCTContext = reactContext ;
33
39
}
34
40
@@ -54,14 +60,33 @@ public void run() {
54
60
}
55
61
56
62
@ ReactMethod
57
- public void actionViewIntent (String path , String mime , Promise promise ) {
63
+ public void actionViewIntent (String path , String mime , final Promise promise ) {
58
64
try {
59
65
Intent intent = new Intent (Intent .ACTION_VIEW )
60
66
.setDataAndType (Uri .parse ("file://" + path ), mime );
61
67
intent .setFlags (Intent .FLAG_ACTIVITY_NEW_TASK );
62
-
63
68
this .getReactApplicationContext ().startActivity (intent );
64
- promise .resolve (null );
69
+ ActionViewVisible = true ;
70
+ final boolean triggered = false ;
71
+ final LifecycleEventListener listener = new LifecycleEventListener () {
72
+ @ Override
73
+ public void onHostResume () {
74
+ if (triggered )
75
+ promise .resolve (null );
76
+ RCTContext .removeLifecycleEventListener (this );
77
+ }
78
+
79
+ @ Override
80
+ public void onHostPause () {
81
+
82
+ }
83
+
84
+ @ Override
85
+ public void onHostDestroy () {
86
+
87
+ }
88
+ };
89
+ RCTContext .addLifecycleEventListener (listener );
65
90
} catch (Exception ex ) {
66
91
promise .reject (ex .getLocalizedMessage ());
67
92
}
0 commit comments