Nice article. Waiting for the next.
Rainer Lang
1

Hi Rainer Lang!

You are right, the strings must come from the resources, but for this article I wanted to do the example as simple as possible. Anyway I can recommend you two ways of doing it:

  • Send the stringId from your strings as a parameter on the setTitle method:
public interface View {
void setTitle(@StringRes stringId);
}
view.setTitle(R.string.address_edit);
  • Create two different methods to set the titles:
public interface View { 
void setEditAddressTitle();
void setAddAddressTitle();
}

These are two possible solutions, and I’m sure you could find more. But what it is really important is to avoid sending the context to the Presenter since we want to UnitTest it and it is always easier when there are no dependencies to the Android Framework.

About using a Presenter with a ViewPager and Fragments, the strategy should be the same, each Fragment will have its own Presenter.

Thanks for your feedback and I hope I have been able to help you!

A single golf clap? Or a long standing ovation?

By clapping more or less, you can signal to us which stories really stand out.