rex-weather
rex-weather copied to clipboard
does not handle configuration change
You should add retained fragments (see http://www.androiddesignpatterns.com/2013/04/retaining-objects-across-config-changes.html) or http://developer.android.com/reference/android/content/AsyncTaskLoader.html to retain the REST calls when the activity is restarted on device rotation. Right now, on orientation change, you get an error "sendUserActionEvent() mView == null" and you would notice it much more if you tried it with a bigger dataset than just the current weather.
By the way, because the landscape layout is unusable, you obviously only tested it in portait mode.
You're right, I didn't consider configuration changes in this example. I should probably have locked the screen orientation to portrait.
Doing a setRetainInstance(true)
in WeatherFragment
would be the preferred solution here, since we're using RxJava as a replacement for AsyncTask.
I'll see if I can push a fix out this weekend.
thanks btw, locking the orientation is called "last resort" at http://developer.android.com/guide/topics/manifest/activity-element.html#config
I was not too concerned with the usability of this app to be honest. This is most definitely not a production-ready app. Thanks for caring enough to open an issue though. I'll try to find some time this weekend to fix this.
@ber4444 locking the screen orientation is not considered a last resort, what is considered a last resort is handling the configurations changes manually by declaring the android:configChanges
for your activity, maybe your were thinking about android:screenOrientation
still have some caveats but as @vyshane mentioned this is not a production app.