mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 20:31:02 -05:00
Simplify presenter delegate
This commit is contained in:
parent
ecfe72bcad
commit
2f6d163a7a
1 changed files with 3 additions and 8 deletions
|
@ -10,7 +10,6 @@ public class NucleusConductorDelegate<P extends Presenter> {
|
||||||
|
|
||||||
@Nullable private P presenter;
|
@Nullable private P presenter;
|
||||||
@Nullable private Bundle bundle;
|
@Nullable private Bundle bundle;
|
||||||
private boolean presenterHasView = false;
|
|
||||||
|
|
||||||
private PresenterFactory<P> factory;
|
private PresenterFactory<P> factory;
|
||||||
|
|
||||||
|
@ -22,8 +21,8 @@ public class NucleusConductorDelegate<P extends Presenter> {
|
||||||
if (presenter == null) {
|
if (presenter == null) {
|
||||||
presenter = factory.createPresenter();
|
presenter = factory.createPresenter();
|
||||||
presenter.create(bundle);
|
presenter.create(bundle);
|
||||||
}
|
|
||||||
bundle = null;
|
bundle = null;
|
||||||
|
}
|
||||||
return presenter;
|
return presenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,24 +36,20 @@ public class NucleusConductorDelegate<P extends Presenter> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void onRestoreInstanceState(Bundle presenterState) {
|
void onRestoreInstanceState(Bundle presenterState) {
|
||||||
if (presenter != null)
|
|
||||||
throw new IllegalArgumentException("onRestoreInstanceState() should be called before onResume()");
|
|
||||||
bundle = presenterState;
|
bundle = presenterState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onTakeView(Object view) {
|
void onTakeView(Object view) {
|
||||||
getPresenter();
|
getPresenter();
|
||||||
if (presenter != null && !presenterHasView) {
|
if (presenter != null) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
presenter.takeView(view);
|
presenter.takeView(view);
|
||||||
presenterHasView = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onDropView() {
|
void onDropView() {
|
||||||
if (presenter != null && presenterHasView) {
|
if (presenter != null) {
|
||||||
presenter.dropView();
|
presenter.dropView();
|
||||||
presenterHasView = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue