-
Notifications
You must be signed in to change notification settings - Fork 207
Custom Presenter constuructor
Yuri Shmakov edited this page Aug 15, 2017
·
2 revisions
DetailsActivity.java:
public class DetailsActivity extends MvpAppCompatActivity implements DetailsView {
@InjectPresenter
DetailsPresenter mDetailsPresenter;
@ProvidePresenter
DetailsPresenter provideDetailsPresenter() {
return new DetailsPresenter(getIntent().getLongExtra("extraDetailsId", 0));
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
}
@Override
public void showDetails(String details) {
Log.i(DetailsActivity.class.getSimpleName(), details);
}
}
DetailsPresenter.java:
@InjectViewState
public class DetailsPresenter extends MvpPresenter<DetailsView> {
public DetailsPresenter(long newsId) {
loadNews(newsId);
}
private void loadNews(long newsId) {
getViewState().showDetails("Details of \"" + newsId + "\"");
}
}
DetailsView.java:
public interface DetailsView extends MvpView {
void showDetails(String details);
}
- Home
- Causes of Moxy
- Getting started
- How to's
- Components
- Multiple modules
- Moxy & Kotlin
- Android Studio Templates
- FAQ
- Changelog