Browse Source

Add limited support for animationType on Android

This commit adds support for displaying an activity with no animation
by setting `animationType: none` when calling `startApp`. In the future
we can support more animation types if there's a demand for it.
Guy Carmeli 8 years ago
parent
commit
661fec6b79

+ 7
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java View File

@@ -50,10 +50,17 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
50 50
         RedboxPermission.permissionToShowRedboxIfNeeded(this);
51 51
         activityParams = NavigationCommandsHandler.parseActivityParams(getIntent());
52 52
 
53
+        disableActivityShowAnimationIfNeeded();
53 54
         createLayout();
54 55
         createModalController();
55 56
     }
56 57
 
58
+    private void disableActivityShowAnimationIfNeeded() {
59
+        if (!activityParams.animateShow) {
60
+            overridePendingTransition(0, 0);
61
+        }
62
+    }
63
+
57 64
     private void createModalController() {
58 65
         modalController = new ModalController(this);
59 66
     }

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/params/ActivityParams.java View File

@@ -11,4 +11,5 @@ public class ActivityParams {
11 11
     public ScreenParams screenParams;
12 12
     public List<ScreenParams> tabParams;
13 13
     public SideMenuParams sideMenuParams;
14
+    public boolean animateShow;
14 15
 }

+ 2
- 0
android/app/src/main/java/com/reactnativenavigation/params/parsers/ActivityParamsParser.java View File

@@ -25,6 +25,8 @@ public class ActivityParamsParser extends Parser {
25 25
             result.sideMenuParams = SideMenuParamsParser.parse(params.getBundle("sideMenu"));
26 26
         }
27 27
 
28
+        result.animateShow = params.getBoolean("animateShow", true);
29
+
28 30
         return result;
29 31
     }
30 32
 }

+ 6
- 0
src/deprecated/platformSpecificDeprecated.android.js View File

@@ -29,6 +29,7 @@ function startSingleScreenApp(params) {
29 29
   params.appStyle = convertStyleParams(params.appStyle);
30 30
   params.sideMenu = convertDrawerParamsToSideMenuParams(params.drawer);
31 31
   params.overrideBackPress = screen.overrideBackPress;
32
+  params.animateShow = convertAnimationType(params.animationType);
32 33
 
33 34
   newPlatformSpecific.startApp(params);
34 35
 }
@@ -193,6 +194,7 @@ function startTabBasedApp(params) {
193 194
 
194 195
   params.appStyle = convertStyleParams(params.appStyle);
195 196
   params.sideMenu = convertDrawerParamsToSideMenuParams(params.drawer);
197
+  params.animateShow = convertAnimationType(params.animationType);
196 198
 
197 199
   newPlatformSpecific.startApp(params);
198 200
 }
@@ -210,6 +212,10 @@ function addTabIcon(tab) {
210 212
   }
211 213
 }
212 214
 
215
+function convertAnimationType(animationType) {
216
+  return animationType !== 'none';
217
+}
218
+
213 219
 function navigatorSetButtons(navigator, navigatorEventID, params) {
214 220
   if (params.rightButtons) {
215 221
     params.rightButtons.forEach(function(button) {