protected void onCreate(@Nullable Bundle savedInstanceState) {
mFragments.attachHost(null /*parent*/);
super.onCreate(savedInstanceState);
NonConfigurationInstances nc =
(NonConfigurationInstances) getLastNonConfigurationInstance();
if (nc != null) {
mViewModelStore = nc.viewModelStore; //HERE IS THE ISSUE
}
I found in Android code why the ViewModelProvider should be called after the super.onCreate
the mViewModelStore is the issue
it is com.sun so it should be avoided if possible :D
Yeap
@EActivity
and @EFragment
...
@Bean
works as expected. I'm not really fan of creating more and more annotations
but this is how AA plugin system is designed to work ;)
Just a question, as dev :), would you prefer to have to learn and use those 3 new Annotations?, or simply insert the plugin on your Graddle, and everything keeps working (with the new enhancements).
So that your @EBean
which implement ViewModel
when they are injected normally with Bean
they simply, "work", no extra change?
@EViewModel
and @ViewModel
BTW, but I'm not pleased with it, hehehe. cause right now @EViewModel
is placed over @EBean
, and basically, you could try to inject it with @Bean
, and then nothing works.
@EBean
@EViewModel
public class MainViewModel extends ViewModel implements LifecycleObserver {
private static final long PERIODIC_UPDATES_TIME = 5 * 60 * 1000L;
@RootView
MainViewPresenter presenter;
@Bean
ArchivesManager archivesManager;
.....
This is how it is done right now.. then you should inject with@ViewModel
MainViewModel viewModel;