Hey guys, Say I have one Activity with a RecyclerV...
# android-architecture
o
Hey guys, Say I have one Activity with a RecyclerView. You can choose items on the RecyclerView. It is important that if the user minimizes the app and gets back to it after hours he still will see the selected items on the RecyclerView. The Activity is forced to be in portrait mode only, set from the manifest using:
Copy code
android:screenOrientation="portrait"
Do I have any good reason to make a ViewModel for this Activity? I know that users can’t rotate the screen. What I am asking, is that in this scenario, do the ViewModel have “higher survival rate” than the Activity?
s
This contains the answer to your non-Kotlin-specific question 😉 https://developer.android.com/topic/libraries/architecture/saving-states
o
@satyan Cheers mate 😄 🍻
t
You need to save state across process death. ViewModel itself won't help with that and isn't necessary here. There is the new SavedStateContainer or whatever it's called but you can just save to bundle yourself.
a
You should have a view model for a reason of presentation logic separation and testability, or do you mean Presenter vs ViewModel?