Posts

Showing posts with the label mvp

restoring state in a presenter with MVP

restoring state in a presenter with MVP https://medium.com/@cervonefrancesco/model-view-presenter-android-guidelines-94970b430ddf says to restore state in the model instead of the presenter. What if I have a very simple "model", say a binary toggle that updates a textview to be on or off? Creating a model Toggle class that has a single string value seems like overkill. Another option is to pass the bundle from my Activity into a corresponding method in my presenter inside onSaveInstanceState and restore it similarly with onCreate. But the article also says that we should avoid having android dependencies in the presenter . Finally I tried using Icepick but this did not work: MainActivity.java @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Icepick.restoreInstanceState(this, savedInstanceState); (Button) findViewById(R.id.btn).setOnClickListener(this); presenter.onCreate(); } @Override protected void onSave...