Last active
June 29, 2016 12:18
-
-
Save andrzejchm/8acd8a4f59e6b5156607299596fa74c2 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
public class GoodPresenter extends SimpleDroidMVPPresenter<GoodView,GoodPresentationModel> { | |
public void onShowUsersButtonClicked() { | |
getMvpView().showProgress(); | |
repository.getUsers(new Callback() { | |
public void onSuccess(List<Users> users) { | |
usersListFetched(users); | |
} | |
public void onFailure(Exception e) { | |
usersListFetchError(e); | |
} | |
}) | |
} | |
private void usersListFetched(List<Users> users) { | |
PresentationModel model = getPresentationModel(); | |
model.setUsers(users); | |
if (getMvpView() == null) { | |
return; | |
} | |
if (model.shouldDisplayEmptyState()) { | |
getMvpView().showEmptyState(); | |
} else { | |
getMvpView().showUsersList(model.getAllUsers()); | |
} | |
if(model.hasAnyUserBirthdayToday()) { | |
getMvpView().showBirthdayAlert(model.getUsersWithBirthday()); | |
} | |
} | |
private void usersListFetchError(Exception e) { | |
getPresentationModel().setUsersListFetchError(e); | |
if (getMvpView() != null) { | |
getMvpView().showUsersListFetchError(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment