22
33import android .content .Intent ;
44import android .net .Uri ;
5+ import android .os .Bundle ;
6+ import android .widget .SearchView ;
57
68import com .RNFetchBlob .Utils .RNFBCookieJar ;
9+ import com .facebook .react .LifecycleState ;
710import com .facebook .react .bridge .Callback ;
11+ import com .facebook .react .bridge .LifecycleEventListener ;
812import com .facebook .react .bridge .Promise ;
913import com .facebook .react .bridge .ReactApplicationContext ;
1014import com .facebook .react .bridge .ReactContextBaseJavaModule ;
@@ -25,10 +29,12 @@ public class RNFetchBlob extends ReactContextBaseJavaModule {
2529 static ThreadPoolExecutor threadPool = new ThreadPoolExecutor (5 , 10 , 5000 , TimeUnit .MILLISECONDS , taskQueue );
2630 static LinkedBlockingQueue <Runnable > fsTaskQueue = new LinkedBlockingQueue <>();
2731 static ThreadPoolExecutor fsThreadPool = new ThreadPoolExecutor (2 , 10 , 5000 , TimeUnit .MILLISECONDS , taskQueue );
32+ static public boolean ActionViewVisible = false ;
2833
2934 public RNFetchBlob (ReactApplicationContext reactContext ) {
3035
3136 super (reactContext );
37+
3238 RCTContext = reactContext ;
3339 }
3440
@@ -54,14 +60,33 @@ public void run() {
5460 }
5561
5662 @ ReactMethod
57- public void actionViewIntent (String path , String mime , Promise promise ) {
63+ public void actionViewIntent (String path , String mime , final Promise promise ) {
5864 try {
5965 Intent intent = new Intent (Intent .ACTION_VIEW )
6066 .setDataAndType (Uri .parse ("file://" + path ), mime );
6167 intent .setFlags (Intent .FLAG_ACTIVITY_NEW_TASK );
62-
6368 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 );
6590 } catch (Exception ex ) {
6691 promise .reject (ex .getLocalizedMessage ());
6792 }
0 commit comments