Skip to content

Null presenter #5

@rackaam

Description

@rackaam

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();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions