janishar / android-mvvm-architecture

This repository contains a detailed sample app that implements MVVM architecture using Dagger2, Room, RxJava2, FastAndroidNetworking and PlaceholderView
https://janisharali.com
Apache License 2.0
2.96k stars 934 forks source link

ViewModel having different injection approach #15

Closed devAseemSharma closed 6 years ago

devAseemSharma commented 6 years ago

I have observed that in some classes like SplashActivity and LoginActivity ViewModel is directly been injected without using ViewModelProviderFactory.class. But in MainActivity class ViewModel is not directly injected, it is instantiated using ViewModelProviderFactory.class I do not get the purpose these two approach.

I believe this is done due to the fact that Login and Splash screen do not support saving state of the view when screen is rotated, but MainActivity does. Is it true?

amitshekhariitbhu commented 6 years ago

Yes you are correct

devAseemSharma commented 6 years ago

Thanks