diff options
author | lado <herrlado@gmail.com> | 2013-02-12 22:27:52 +0100 |
---|---|---|
committer | lado <herrlado@gmail.com> | 2013-02-12 22:27:52 +0100 |
commit | 573bc7e78fde413ba5dad4c9277f6af05e21135b (patch) | |
tree | a270afa8867e032a4eba245067c1da8818eeeeb7 /vdrmanager | |
parent | 839123c1c543ea877f8c522f7b9744f47f4a2128 (diff) | |
download | vdr-manager-573bc7e78fde413ba5dad4c9277f6af05e21135b.tar.gz vdr-manager-573bc7e78fde413ba5dad4c9277f6af05e21135b.tar.bz2 |
Feature #1074
Diffstat (limited to 'vdrmanager')
-rw-r--r-- | vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java index 8b77fa6..052192f 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java @@ -1,6 +1,8 @@ package de.bjusystems.vdrmanager.gui; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import android.content.Context; @@ -61,6 +63,51 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements items.add(object); super.add(object); } + + + void sort(int sortBy){ + + ArrayList<EventListItem> events = new ArrayList<EventListItem>(items); + + if(sortBy == BaseEventListActivity.MENU_GROUP_ALPHABET){ + + Collections.sort(events, new Comparator<EventListItem>() { + @Override + public int compare(EventListItem lhs, EventListItem rhs) { + if(lhs == null || lhs.getTitle() == null){ + return 1; + } + if(rhs == null || rhs.getTitle() == null){ + return 0; + } + return lhs.getTitle().compareTo(rhs.getTitle()); + } + }); + + } else if(sortBy == BaseEventListActivity.MENU_GROUP_TIME) { + + Collections.sort(events, new Comparator<EventListItem>() { + @Override + public int compare(EventListItem lhs, EventListItem rhs) { + if(lhs == null || lhs.getStart() == null){ + return 1; + } + if(rhs == null || rhs.getStart() == null){ + return 0; + } + return lhs.getStart().compareTo(rhs.getStart()); + } + }); + + } + + clear(); + for(EventListItem eli : events){ + add(eli); + } + + notifyDataSetChanged(); + } @Override public int getItemViewType(int position) { |