Search in sources :

Example 1 with LiveEventUpdateEvent

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;
    }
}
Also used : ListSectionHeaderViewModel(com.thebluealliance.androidclient.viewmodels.ListSectionHeaderViewModel) LiveEventUpdateEvent(com.thebluealliance.androidclient.eventbus.LiveEventUpdateEvent) Event(com.thebluealliance.androidclient.models.Event) LiveEventUpdateEvent(com.thebluealliance.androidclient.eventbus.LiveEventUpdateEvent) EventSortByDateComparator(com.thebluealliance.androidclient.comparators.EventSortByDateComparator)

Example 2 with LiveEventUpdateEvent

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;
    }
}
Also used : EventType(com.thebluealliance.androidclient.types.EventType) ListSectionHeaderViewModel(com.thebluealliance.androidclient.viewmodels.ListSectionHeaderViewModel) LiveEventUpdateEvent(com.thebluealliance.androidclient.eventbus.LiveEventUpdateEvent) Event(com.thebluealliance.androidclient.models.Event) LiveEventUpdateEvent(com.thebluealliance.androidclient.eventbus.LiveEventUpdateEvent)

Aggregations

LiveEventUpdateEvent (com.thebluealliance.androidclient.eventbus.LiveEventUpdateEvent)2 Event (com.thebluealliance.androidclient.models.Event)2 ListSectionHeaderViewModel (com.thebluealliance.androidclient.viewmodels.ListSectionHeaderViewModel)2 EventSortByDateComparator (com.thebluealliance.androidclient.comparators.EventSortByDateComparator)1 EventType (com.thebluealliance.androidclient.types.EventType)1