Browse Source

start activity with fade animation when animationType: 'fade' is passed (#1197)

Gevorg Gasparyan 7 years ago
parent
commit
01c62214f3

+ 17
- 0
android/app/src/main/java/com/reactnativenavigation/NavigationApplication.java View File

1
 package com.reactnativenavigation;
1
 package com.reactnativenavigation;
2
 
2
 
3
 import android.app.Application;
3
 import android.app.Application;
4
+import android.content.Intent;
5
+import android.os.Bundle;
4
 import android.os.Handler;
6
 import android.os.Handler;
5
 import android.support.annotation.Nullable;
7
 import android.support.annotation.Nullable;
8
+import android.support.v4.app.ActivityOptionsCompat;
6
 
9
 
7
 import com.facebook.react.ReactApplication;
10
 import com.facebook.react.ReactApplication;
8
 import com.facebook.react.ReactNativeHost;
11
 import com.facebook.react.ReactNativeHost;
34
         activityCallbacks = new ActivityCallbacks();
37
         activityCallbacks = new ActivityCallbacks();
35
     }
38
     }
36
 
39
 
40
+    @Override
41
+    public void startActivity(Intent intent) {
42
+        String animationType = intent.getStringExtra("animationType");
43
+        if (animationType != null && animationType.equals("fade")) {
44
+            Bundle bundle = ActivityOptionsCompat.makeCustomAnimation(getApplicationContext(),
45
+                    android.R.anim.fade_in,
46
+                    android.R.anim.fade_out
47
+            ).toBundle();
48
+            super.startActivity(intent, bundle);
49
+        } else {
50
+            super.startActivity(intent);
51
+        }
52
+    }
53
+
37
     public void startReactContextOnceInBackgroundAndExecuteJS() {
54
     public void startReactContextOnceInBackgroundAndExecuteJS() {
38
         reactGateway.startReactContextOnceInBackgroundAndExecuteJS();
55
         reactGateway.startReactContextOnceInBackgroundAndExecuteJS();
39
     }
56
     }

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java View File

41
         IntentDataHandler.onStartApp(intent);
41
         IntentDataHandler.onStartApp(intent);
42
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
42
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
43
         intent.putExtra(ACTIVITY_PARAMS_BUNDLE, params);
43
         intent.putExtra(ACTIVITY_PARAMS_BUNDLE, params);
44
+        intent.putExtra("animationType", params.getString("animationType"));
44
         NavigationApplication.instance.startActivity(intent);
45
         NavigationApplication.instance.startActivity(intent);
45
     }
46
     }
46
 
47