Skip to content

Commit

Permalink
fix: Add null check before sorting events (#1494)
Browse files Browse the repository at this point in the history
* Added null check before sorting

* Used return statement on null
  • Loading branch information
ravi-kishan authored and Masquerade0097 committed Feb 14, 2019
1 parent c4e1f76 commit 42c3e7f
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,21 @@ public EventsViewModel(EventRepository eventsDataRepository) {

public LiveData<List<Event>> getEvents(int position) {
switch (position) {
case 0: return liveEvents;
case 1: return pastEvents;
case 2: return draftEvents;
default: return events;
case 0:
return liveEvents;
case 1:
return pastEvents;
case 2:
return draftEvents;
default:
return events;
}
}

public void sortBy(int criteria) {
if (events.getValue() == null) {
return;
}
if (criteria == SORTBYNAME)
Collections.sort(events.getValue(), (e1, e2) -> e1.getName().compareToIgnoreCase(e2.getName()));
else {
Expand Down

0 comments on commit 42c3e7f

Please sign in to comment.