-
-
Save nbarishok/7b11cc4abd42a22dcd40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WeatherCommunicationBus implements WeatherView, WeatherPresenter { | |
private WeatherPresenter mPresenter; | |
private WeatherView mView; | |
public WeatherCommunicationBus(WeatherPresenter presenter) { | |
mPresenter = presenter; | |
mPresenter.attachView(this); | |
} | |
@Override | |
public void showLoading() { | |
if (mView != null) { mView.showLoading(); } | |
} | |
@Override | |
public void hideLoading() { | |
if (mView != null) { mView.hideLoading(); } | |
} | |
@Override | |
public void setData(WeatherViewModel data) { | |
if (mView != null) { mView.setData(data); } | |
} | |
@Override | |
public void showContent() { | |
if (mView != null) { mView.showContent(); } | |
} | |
@Override | |
public void showError(WeatherError error) { | |
if (mView != null) { mView.showError(error); } | |
} | |
// presenter | |
@Override | |
public void loadWeather() { | |
mPresenter.loadWeather(); | |
} | |
@Override | |
public void attachView(WeatherView view) { | |
mView = view; | |
} | |
@Override | |
public void detachView() { | |
mView = null; | |
} | |
@Override | |
public void onCreate(@Nullable Bundle arguments, @Nullable Bundle savedInstanceState) { | |
mPresenter.onCreate(arguments, savedInstanceState); | |
} | |
@Override | |
public void onSaveInstanceState(Bundle bundle) { | |
mPresenter.onSaveInstanceState(bundle); | |
} | |
@Override | |
public void onDestroy() { | |
mPresenter.detachView(); | |
mPresenter.onDestroy(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment