android-arch-sample
android-arch-sample copied to clipboard
Null presenter
Hi,
In this code (from https://github.com/remind101/android-arch-sample/blob/master/app/src/main/java/com/remind101/archexample/MainActivity.java), the saved instance state may be not null (back navigation), and PresenterManager.getInstance().restorePresenter()
may return null (the cache use an expirationValue).
In this case, after this code, the presenter is null
and the app will certainly crash.
if (savedInstanceState == null) {
presenter = new MainPresenter();
} else {
presenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
}
Should the code not be more something like this or am I missing something?
if (savedInstanceState != null) {
presenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
}
if (presenter == null) {
presenter = new MainPresenter();
}