use of com.thebluealliance.androidclient.eventbus.LiveEventUpdateEvent in project the-blue-alliance-android by the-blue-alliance.
the class EventHelper method renderEventListForDistrict.
public static void renderEventListForDistrict(Context context, List<Event> events, List<Object> output) {
Collections.sort(events, new EventSortByDateComparator());
String lastHeader = null, currentHeader;
for (Event event : events) {
currentHeader = weekLabelFromNum(event.getYear(), event.getWeek());
if (!currentHeader.equals(lastHeader)) {
String headerTitle = context.getString(R.string.week_events_header, currentHeader);
output.add(new ListSectionHeaderViewModel(headerTitle));
}
output.add(event.renderToViewModel(context, Event.RENDER_BASIC));
if (event.isHappeningNow()) {
// send out that there are live matches happening for other things to pick up
TbaLogger.d("Sending live event broadcast: " + event.getKey());
EventBus.getDefault().post(new LiveEventUpdateEvent(event));
}
lastHeader = currentHeader;
}
}
use of com.thebluealliance.androidclient.eventbus.LiveEventUpdateEvent in project the-blue-alliance-android by the-blue-alliance.
the class EventHelper method renderEventListWithComparator.
private static void renderEventListWithComparator(Context context, List<Event> events, List<Object> output, Comparator<Event> comparator) {
Collections.sort(events, comparator);
EventType lastType = null, currentType;
String lastDistrict = "", currentDistrict;
for (Event event : events) {
currentType = event.getEventTypeEnum();
currentDistrict = event.getDistrictKey() != null ? event.getDistrictKey() : "";
if (currentType != lastType || (currentType == EventType.DISTRICT && !currentDistrict.equals(lastDistrict))) {
String headerTitle;
if (currentType == EventType.DISTRICT) {
headerTitle = context.getString(R.string.district_events_header, event.getEventDistrictString());
} else {
headerTitle = context.getString(currentType.getCategoryName());
}
output.add(new ListSectionHeaderViewModel(headerTitle));
}
output.add(event.renderToViewModel(context, Event.RENDER_BASIC));
if (event.isHappeningNow()) {
// send out that there are live matches happening for other things to pick up
TbaLogger.d("Sending live event broadcast: " + event.getKey());
EventBus.getDefault().post(new LiveEventUpdateEvent(event));
}
lastType = currentType;
lastDistrict = currentDistrict;
}
}
Aggregations