Search in sources :

Example 26 with Event

use of com.thebluealliance.androidclient.models.Event in project the-blue-alliance-android by the-blue-alliance.

the class WeekEventsExtractorTest method testWeekEventsExtractor.

@Test
public void testWeekEventsExtractor() {
    List<Event> events = mExtractor.call(mEvents);
    assertNotNull(events);
    assertEquals(events.size(), 21);
    for (int i = 0; i < events.size(); i++) {
        Event event = events.get(i);
        assertEquals(event.getWeek(), (Integer) mWeek);
    }
}
Also used : Event(com.thebluealliance.androidclient.models.Event) Test(org.junit.Test)

Example 27 with Event

use of com.thebluealliance.androidclient.models.Event in project the-blue-alliance-android by the-blue-alliance.

the class TeamAtDistrictBreakdownSubscriber method parseData.

@Override
public synchronized void parseData() {
    mDataToBind.clear();
    List<IDistrictEventPoints> eventBreakdowns = mAPIData.getEventPoints();
    if (eventBreakdowns == null) {
        return;
    }
    for (IDistrictEventPoints eventData : eventBreakdowns) {
        Event event = mDb.getEventsTable().get(eventData.getEventKey());
        DistrictPointBreakdown breakdown = (DistrictPointBreakdown) eventData;
        ListGroup eventGroup = new ListGroup(event == null ? eventData.getEventKey() : event.getName());
        if (breakdown.getQualPoints() > -1) {
            eventGroup.children.add(breakdown.renderQualPoints(mResources));
        }
        if (breakdown.getElimPoints() > -1) {
            eventGroup.children.add(breakdown.renderElimPoints(mResources));
        }
        if (breakdown.getAlliancePoints() > -1) {
            eventGroup.children.add(breakdown.renderAlliancePoints(mResources));
        }
        if (breakdown.getAwardPoints() > -1) {
            eventGroup.children.add(breakdown.renderAwardPoints(mResources));
        }
        if (breakdown.getTotal() > -1) {
            eventGroup.children.add(breakdown.renderTotalPoints(mResources));
        }
        mDataToBind.add(eventGroup);
    }
}
Also used : IDistrictEventPoints(com.thebluealliance.api.model.IDistrictEventPoints) ListGroup(com.thebluealliance.androidclient.listitems.ListGroup) Event(com.thebluealliance.androidclient.models.Event) DistrictPointBreakdown(com.thebluealliance.androidclient.models.DistrictPointBreakdown)

Example 28 with Event

use of com.thebluealliance.androidclient.models.Event in project the-blue-alliance-android by the-blue-alliance.

the class TeamAtDistrictSummarySubscriber method renderEventPoints.

private static LabelValueDetailListItem renderEventPoints(String teamKey, IDistrictEventPoints points, EventsTable eventsTable, Resources resources) {
    Event event = eventsTable.get(points.getEventKey());
    String event1Name = event != null ? event.getShortName() : points.getEventKey();
    return new LabelValueDetailListItem(event1Name, String.format(resources.getString(R.string.district_points_format), points.getTotal()), EventTeamHelper.generateKey(points.getEventKey(), teamKey));
}
Also used : ActionBarTitleEvent(com.thebluealliance.androidclient.eventbus.ActionBarTitleEvent) Event(com.thebluealliance.androidclient.models.Event) LabelValueDetailListItem(com.thebluealliance.androidclient.listitems.LabelValueDetailListItem)

Example 29 with Event

use of com.thebluealliance.androidclient.models.Event in project the-blue-alliance-android by the-blue-alliance.

the class TeamAtEventSummarySubscriber method parseData.

@Override
public synchronized void parseData() {
    mDataToBind.clear();
    Match nextMatch = null, lastMatch = null;
    @Nullable TeamAtEventStatus status = mAPIData.status;
    @Nullable ITeamAtEventAlliance allianceData = status != null ? status.getAlliance() : null;
    @Nullable ITeamAtEventQual qualData = status != null ? status.getQual() : null;
    @Nullable ITeamAtEventPlayoff playoffData = status != null ? status.getPlayoff() : null;
    Event event = mAPIData.event;
    Date now = new Date();
    if (event == null) {
        return;
    }
    Team team = mAPIData.team;
    if (team == null) {
        return;
    }
    int year = event.getYear();
    boolean activeEvent = event.isHappeningNow();
    String playoffStatusString = status != null ? status.getPlayoffStatusStr() : "";
    String allianceStatusString = status != null ? status.getAllianceStatusStr() : "";
    String overallStatusString;
    if (status != null) {
        overallStatusString = status.getOverallStatusStr();
    } else if (now.before(event.getStartDate())) {
        overallStatusString = mResources.getString(R.string.team_at_event_future_event);
    } else {
        overallStatusString = "";
    }
    String qualRecordString;
    @Nullable ITeamRecord qualRecord = null;
    if (qualData != null && qualData.getRanking() != null && qualData.getRanking().getRecord() != null) {
        qualRecord = qualData.getRanking().getRecord();
    }
    if (qualRecord != null) {
        qualRecordString = RankingItem.TeamRecord.buildRecordString(qualRecord);
    } else {
        qualRecordString = "";
    }
    if (activeEvent && mIsMatchListLoaded) {
        Collections.sort(mMatches, new MatchSortByPlayOrderComparator());
        nextMatch = MatchHelper.getNextMatchPlayed(mMatches);
        lastMatch = MatchHelper.getLastMatchPlayed(mMatches);
    }
    int rank = 0;
    String rankingString = "";
    LabelValueViewModel rankBreakdownItem = null;
    @Nullable IRankingItem rankData = qualData != null ? qualData.getRanking() : null;
    @Nullable List<IRankingSortOrder> sortOrders = qualData != null ? qualData.getSortOrderInfo() : null;
    if (rankData != null && sortOrders != null) {
        rank = rankData.getRank();
        rankingString = buildRankingString(rankData, sortOrders, null, mResources, NONE);
        rankBreakdownItem = new LabelValueViewModel(mResources.getString(R.string.team_at_event_rank_breakdown), rankingString);
    }
    // Basic information about the team
    mDataToBind.add(new SimpleTeamViewModel(team.getKey(), team.getNickname(), team.getLocation(), year));
    // Rank
    if (rank > 0) {
        mDataToBind.add(new LabelValueViewModel(mResources.getString(R.string.team_at_event_rank), rank + Utilities.getOrdinalFor(rank)));
    }
    // Number of awards, only if nonzero
    if (mIsAwardListLoaded && mAwards.size() > 0) {
        String awardsString;
        if (mAwards.size() == 1) {
            awardsString = mResources.getString(R.string.team_at_event_awards_format_one);
        } else {
            awardsString = mResources.getString(R.string.team_at_event_awards_format, mAwards.size());
        }
        mDataToBind.add(new LabelValueViewModel(mResources.getString(R.string.awards_header), awardsString));
    }
    // Pit Location Stuff
    if (PitLocationHelper.shouldShowPitLocationAtEvent(mAppConfig, mEventKey)) {
        PitLocationHelper.TeamPitLocation location = PitLocationHelper.getPitLocation(mContext, mTeamKey);
        if (location != null) {
            mDataToBind.add(new LabelValueViewModel(mResources.getString(R.string.pit_location), location.getAddressString()));
        }
    }
    /* Team Qual Record
         * Don't show for 2015 events, because no wins and such */
    if (year != 2015 && !RankingItem.TeamRecord.isEmpty(qualRecord)) {
        mDataToBind.add(new LabelValueViewModel(mResources.getString(R.string.team_at_event_qual_record), qualRecordString));
    }
    // Alliance
    if (allianceData != null) {
        mDataToBind.add(new LabelValueViewModel(mResources.getString(R.string.team_at_event_alliance), Html.fromHtml(allianceStatusString)));
    }
    // Alliance Status
    mDataToBind.add(new LabelValueViewModel(mResources.getString(R.string.team_at_event_status), Html.fromHtml(playoffData != null ? playoffStatusString : overallStatusString)));
    // Ranking Breakdown
    if (rankingString != null && !rankingString.isEmpty()) {
        mDataToBind.add(rankBreakdownItem);
    }
    if (lastMatch != null) {
        mDataToBind.add(new LabeledMatchViewModel(mResources.getString(R.string.title_last_match), mMatchRenderer.renderFromModel(lastMatch, MatchRenderer.RENDER_DEFAULT)));
    }
    if (nextMatch != null) {
        mDataToBind.add(new LabeledMatchViewModel(mResources.getString(R.string.title_next_match), mMatchRenderer.renderFromModel(nextMatch, MatchRenderer.RENDER_DEFAULT)));
    }
}
Also used : PitLocationHelper(com.thebluealliance.androidclient.helpers.PitLocationHelper) ITeamRecord(com.thebluealliance.api.model.ITeamRecord) ITeamAtEventPlayoff(com.thebluealliance.api.model.ITeamAtEventPlayoff) IRankingSortOrder(com.thebluealliance.api.model.IRankingSortOrder) RankingFormatter.buildRankingString(com.thebluealliance.androidclient.helpers.RankingFormatter.buildRankingString) LabeledMatchViewModel(com.thebluealliance.androidclient.viewmodels.LabeledMatchViewModel) ITeamAtEventAlliance(com.thebluealliance.api.model.ITeamAtEventAlliance) Date(java.util.Date) Match(com.thebluealliance.androidclient.models.Match) LabelValueViewModel(com.thebluealliance.androidclient.viewmodels.LabelValueViewModel) SimpleTeamViewModel(com.thebluealliance.androidclient.viewmodels.SimpleTeamViewModel) IRankingItem(com.thebluealliance.api.model.IRankingItem) TeamAtEventStatus(com.thebluealliance.androidclient.models.TeamAtEventStatus) ITeamAtEventQual(com.thebluealliance.api.model.ITeamAtEventQual) EventAwardsEvent(com.thebluealliance.androidclient.eventbus.EventAwardsEvent) Event(com.thebluealliance.androidclient.models.Event) EventMatchesEvent(com.thebluealliance.androidclient.eventbus.EventMatchesEvent) Team(com.thebluealliance.androidclient.models.Team) MatchSortByPlayOrderComparator(com.thebluealliance.androidclient.comparators.MatchSortByPlayOrderComparator) Nullable(javax.annotation.Nullable)

Example 30 with Event

use of com.thebluealliance.androidclient.models.Event in project the-blue-alliance-android by the-blue-alliance.

the class EventTabSubscriber method parseData.

@Override
public void parseData() {
    mDataToBind.clear();
    Collections.sort(mAPIData, mEventComparator);
    LinkedHashMap<String, EventWeekTab> eventTabs = new LinkedHashMap<>();
    for (Event event : mAPIData) {
        int eventWeek = event.getWeek() != null ? event.getWeek() : -1;
        String label = EventHelper.generateLabelForEvent(event);
        if (!eventTabs.containsKey(label)) {
            eventTabs.put(label, new EventWeekTab(label, eventWeek));
        }
        EventWeekTab tab = eventTabs.get(label);
        if (tab == null) {
            throw new RuntimeException("Expected to find event tab, but can't!");
        }
        tab.addEventKey(event.getKey());
    }
    for (Map.Entry<String, EventWeekTab> tab : eventTabs.entrySet()) {
        mDataToBind.add(tab.getValue());
    }
}
Also used : EventWeekTab(com.thebluealliance.androidclient.models.EventWeekTab) Event(com.thebluealliance.androidclient.models.Event) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Event (com.thebluealliance.androidclient.models.Event)35 Test (org.junit.Test)8 Team (com.thebluealliance.androidclient.models.Team)6 ArrayList (java.util.ArrayList)5 District (com.thebluealliance.androidclient.models.District)4 Date (java.util.Date)4 JsonObject (com.google.gson.JsonObject)3 TeamAvatarUpdateEvent (com.thebluealliance.androidclient.eventbus.TeamAvatarUpdateEvent)3 Match (com.thebluealliance.androidclient.models.Match)3 EventRenderer (com.thebluealliance.androidclient.renderers.EventRenderer)3 Before (org.junit.Before)3 Cursor (android.database.Cursor)2 Nullable (androidx.annotation.Nullable)2 WorkerThread (androidx.annotation.WorkerThread)2 JsonElement (com.google.gson.JsonElement)2 MatchSortByPlayOrderComparator (com.thebluealliance.androidclient.comparators.MatchSortByPlayOrderComparator)2 EventMatchesEvent (com.thebluealliance.androidclient.eventbus.EventMatchesEvent)2 LiveEventUpdateEvent (com.thebluealliance.androidclient.eventbus.LiveEventUpdateEvent)2 ListGroup (com.thebluealliance.androidclient.listitems.ListGroup)2 DistrictPointBreakdown (com.thebluealliance.androidclient.models.DistrictPointBreakdown)2