Now that we have a sweet MVP-ready architecture, how do we integrate these two libraries for view injection and instance state restoration when dealing with Activities/views? The simple answer to this question is InjectingActivity (class that will be inherited in the code by all Activities/views)
Butterknife is required to bind the activity in the onCreate, where Icepick takes care of restoring the state of data (and saves it with the call in the onSaveInstanceState)
Also, there is a method called getLayoutResId() to avoid having to always type setContentView(…) [not really necessary but I like it]. Also, since this extends the MVPView interface, we also override getContext()
Butterknife at work
The way Butterknife works (for this app, but it has more functionalities you guys can know more about here) is via an annotation we need to put on each Activity’s view
Icepick at work
To have Icepick work properly we need to mark the specific data we want to save the state of with the annotation @State as written below
Next topic will be configuration of Retrofit2
Leave a Comment