void initPresenter(Bundle savedInstanceState) { BasePresenter presenter = newPresenter(); mWeakReferencePresenter = new WeakReference<>(presenter); if (presenter != null) { // because the first onCreate won't be call otherwise (creation too late) presenter.onCreate(savedInstanceState); } }
@Override public void onBackPressed() { BasePresenter presenter = getPresenter(); if (presenter != null && presenter.onBackPressed()) { return; } super.onBackPressed(); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); BasePresenter presenter = getPresenter(); if (presenter != null) { presenter.onActivityResult(requestCode, resultCode, data); } }
@Override public boolean onCreateOptionsMenu(Menu menu) { BasePresenter presenter = getPresenter(); if (presenter != null) { presenter.onCreateOptionsMenu(menu, getMenuInflater()); return true; } return super.onCreateOptionsMenu(menu); }
@Override public boolean onOptionsItemSelected(MenuItem item) { BasePresenter presenter = getPresenter(); if (presenter != null) { boolean handle = presenter.onOptionsItemSelected(item); if (handle) { return true; } } return super.onOptionsItemSelected(item); }