Skip to content

Instantly share code, notes, and snippets.

@dazza5000
Last active November 16, 2016 22:22
Show Gist options
  • Save dazza5000/14d78ed1c8de8339ee24e7d23d919447 to your computer and use it in GitHub Desktop.
Save dazza5000/14d78ed1c8de8339ee24e7d23d919447 to your computer and use it in GitHub Desktop.
Events Presenter Implementation
public class EventsPresenter implements EventsContract.Presenter {
private EventsRepository repository;
private EventsContract.View view;
....
public EventsPresenter(EventsRepository repository, EventsContract.View view) {
this.view = view;
this.repository = repository;
}
@Override
public void loadEvents() {
repository.getEvents(new EventsDataSource.LoadEventsCallback() {
@Override
public void onEventsLoaded(List<Event> events) {
//Filter events
//Sort events
...
if (currentEvents.size() > 0 ) {
view.showEvents(currentEvents);
} else {
view.showNoEventsView();
}
}
@Override
public void onError(String error) {
Log.e("OOPS", "We have an errorrrrr");
}
.....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment