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,8 +1,11 @@
1 1
 package com.reactnativenavigation;
2 2
 
3 3
 import android.app.Application;
4
+import android.content.Intent;
5
+import android.os.Bundle;
4 6
 import android.os.Handler;
5 7
 import android.support.annotation.Nullable;
8
+import android.support.v4.app.ActivityOptionsCompat;
6 9
 
7 10
 import com.facebook.react.ReactApplication;
8 11
 import com.facebook.react.ReactNativeHost;
@@ -34,6 +37,20 @@ public abstract class NavigationApplication extends Application implements React
34 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 54
     public void startReactContextOnceInBackgroundAndExecuteJS() {
38 55
         reactGateway.startReactContextOnceInBackgroundAndExecuteJS();
39 56
     }

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

@@ -41,6 +41,7 @@ public class NavigationCommandsHandler {
41 41
         IntentDataHandler.onStartApp(intent);
42 42
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
43 43
         intent.putExtra(ACTIVITY_PARAMS_BUNDLE, params);
44
+        intent.putExtra("animationType", params.getString("animationType"));
44 45
         NavigationApplication.instance.startActivity(intent);
45 46
     }
46 47