[Android] Fix crash on device rotate#97
Conversation
|
For more info, I found the fix here: http://stackoverflow.com/a/27937906 |
|
This isn't fully fixed since my rotate events aren't firing, but it doesn't crash either. I'll work with it a bit more to see if I can get it working. EDIT: Turns out it's working fine, I was just having an issue with one of my modules. The PR still fixes the crashing. |
|
Last two commits fix the menu icon state when |
|
|
||
| @SuppressWarnings({"ConstantConditions"}) | ||
| public void setNavUpButton(Screen screen) { | ||
| public void setNavUpButton(Screen screen, boolean isBack) { |
There was a problem hiding this comment.
@jskuby Why is this change necessary? Sending boolean params to functions that change what the behaviour of the function is quit an anti pattern.
There was a problem hiding this comment.
This was a quick update so it can be called from onConfigurationChanged since my menu icon was losing its state on rotation.
How should we go about handling this? Separate functions for styling and setting the state?
There was a problem hiding this comment.
@jskuby Can we move the setNavUpButton call to StyleHelper.updateStyles? If so, seems like we determine if the back button needs to be displayed or not buy calling getScreenStackSize() which is already public. Am I right?
In RnnToolbar we can grab a the BaseReactActivity instance by calling getContext().
I should really kill StylesHelper and move the logic to RnnToolbar. I'll do it after we finish with your PR's to avoid conflicts.
wdyt?
There was a problem hiding this comment.
I took a look and that all seems good @guyca. I probably won't have time to work on this until tomorrow, but I'll see what I can do to move this along.
|
@guyca After moving the |
|
Thanks @jskuby! I'll check it out, hopefully later today |
… into android_rotation_fix # Conflicts: # android/app/src/main/java/com/reactnativenavigation/activities/BottomTabActivity.java
|
Any ETA on the merge? |
|
@jskuby What issues were you having with rotation events not firing? I've pulled this change into my fork, and I'm trying to use react-native-orientation to lock my app in portrait. I'm not seeing react-native-orientation pick up the rotation events. |
|
^ For anyone experiencing the issues I described above, I figured it out. ^ The issue is the hierarchy of class extensions. React Native's I ended up adding the listener needed for the orientation module to my fork directly in Thanks @jskuby for the original code that got me started on figuring out what in the hell is going on. |
|
Hi, |
|
what is the solution ? |
|
@dg92 For now, I suggest you lock you app to portrait mode by adding Navigation.startSingleScreenApp({
screen: {
screen: 'core.LoginScreen',
title: 'Login'
},
portraitOnlyMode: true
}) |
|
@guyca no its not working for me. |
|
@dg92 |
|
@guyca using "react-native-navigation": "^2.0.0-experimental.105", and checking on android 4.4.4 |
|
@dg92 |
|
@ronaldheft My scenario : whole app is portrait using rnn and one of the screens is landscape. so I am using react-native-orientation. My code for landscape screen For me, whole app restarts on doing this |
This PR fixes crashes when rotating, at least on the project I'm working on. This is related to and fixes issue #94.