use of com.skocken.presentation.presenter.BasePresenter in project Presentation by StanKocken.
the class BaseActivity method onActivityResult.
@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);
}
}
use of com.skocken.presentation.presenter.BasePresenter in project Presentation by StanKocken.
the class BaseActivity method initPresenter.
void initPresenter(Bundle savedInstanceState) {
BasePresenter presenter = newPresenter();
setPresenter(presenter);
if (presenter != null) {
// because the first onCreate won't be call otherwise (creation too late)
presenter.onCreate(savedInstanceState);
}
}
use of com.skocken.presentation.presenter.BasePresenter in project Presentation by StanKocken.
the class BaseAppCompatActivity method onBackPressed.
@Override
public void onBackPressed() {
BasePresenter presenter = getPresenter();
if (presenter != null && presenter.onBackPressed()) {
return;
}
super.onBackPressed();
}
use of com.skocken.presentation.presenter.BasePresenter in project Presentation by StanKocken.
the class BaseActivityTest method testShouldWeakReferenceOnPresenter.
@Test
public void testShouldWeakReferenceOnPresenter() {
BasePresenter basePresenter = new BasePresenter(null, null) {
};
final WeakReference<BasePresenter> weakReferencePresenter = new WeakReference<>(basePresenter);
BaseActivity baseActivity = new TestBaseActivity() {
@Override
protected BasePresenter newPresenter() {
return weakReferencePresenter.get();
}
};
baseActivity.onCreate(null);
assertEquals(basePresenter, baseActivity.getPresenter());
basePresenter = null;
for (int i = 0; i < 10 && weakReferencePresenter.get() != null; i++) {
System.gc();
}
assertNull(basePresenter);
assertNull(weakReferencePresenter.get());
assertNull(baseActivity.getPresenter());
}
use of com.skocken.presentation.presenter.BasePresenter in project Presentation by StanKocken.
the class BaseActivityTest method testShouldCallOnActivityResult.
@Test
public void testShouldCallOnActivityResult() {
BaseActivity baseActivity = new TestBaseActivity();
baseActivity.onCreate(null);
BasePresenter presenter = baseActivity.getPresenter();
int requestCode = 432;
int resultCode = 542;
Intent intent = Mockito.mock(Intent.class);
verify(presenter, times(0)).onActivityResult(requestCode, resultCode, intent);
baseActivity.onActivityResult(requestCode, resultCode, intent);
verify(presenter, times(1)).onActivityResult(requestCode, resultCode, intent);
}
Aggregations