-
Notifications
You must be signed in to change notification settings - Fork 7
Questions and Answers
Reamp provides a couple of handy classes such as ReampAppCompatActivity
, ReampFragment
(from the support library) to use as a base class for your Activities and Fragments, but you don't have to extend them if you don't want to. In general, your activity, fragment, or custom view should implement ReampView
interface and connect itself to a presenter through MvpDelegate
class, just like ReampAppCompatActivity
, ReampFragment
do.
Yes, Reamp does not track changes to your stateModel
object. You should call sendStateModel()
manually to notify the view that the state has been changed. Also, you can design your StateModel
class to automatically call sendStateModel()
when you change a StateModel field. Or invent your own way, it's up to you.
When you connect your view to a presenter through MvpDelegate.connect()
. If you use ReampAppCompatActivity
or ReampFragment
it is called within onStart()
We try to keep presenters aside from view's responsibilities. If you want to show a message then just create a constant for the message inside a StateModel
class and let your view decide what string resource it wants to show for this message.
class MyState extends SerializableStateModel {
public enum Message {
OK(R.string.ok),
CANCEL(R.string.cancel),
ERROR(R.string.error);
public final int resId;
Message(int resId) {
this.resId = resId;
}
}
public Message message;
}
// MyPresenter
getStateModel().message = MyState.Message.OK;
sendStateModel();
// MyActivity
public void onStateChanged(MyState stateModel) {
messageView.setText(stateModel.message.resId);
}