Search in sources :

Example 1 with ListGroup

use of com.thebluealliance.androidclient.listitems.ListGroup in project the-blue-alliance-android by the-blue-alliance.

the class ExpandableListViewAdapter method getGroupView.

@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.expandable_list_group, null);
    }
    ListGroup group = (ListGroup) getGroup(groupPosition);
    ((TextView) convertView.findViewById(R.id.group_name)).setText(group.string);
    return convertView;
}
Also used : ListGroup(com.thebluealliance.androidclient.listitems.ListGroup) TextView(android.widget.TextView)

Example 2 with ListGroup

use of com.thebluealliance.androidclient.listitems.ListGroup 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 3 with ListGroup

use of com.thebluealliance.androidclient.listitems.ListGroup in project the-blue-alliance-android by the-blue-alliance.

the class MatchListSubscriber method parseData.

@Override
public void parseData() {
    mDataToBind.clear();
    mQualMatches.clear();
    mOctoMatches.clear();
    mQuarterMatches.clear();
    mSemiMatches.clear();
    mFinalMatches.clear();
    // wins, losses, ties
    int[] record = { 0, 0, 0 };
    Match nextMatch = null;
    Match lastMatch = null;
    Event event = mDb.getEventsTable().get(mEventKey);
    if (event != null && event.isHappeningNow()) {
        Collections.sort(mAPIData, new MatchSortByPlayOrderComparator());
    } else {
        Collections.sort(mAPIData, new MatchSortByDisplayOrderComparator());
    }
    ListGroup currentGroup = mQualMatches;
    MatchType lastType = null;
    Match previousIteration = null;
    boolean lastMatchPlayed = false;
    int redFinalsWon = 0;
    int blueFinalsWon = 0;
    if (mAPIData.size() > 0) {
        nextMatch = mAPIData.get(0);
    }
    for (int i = 0; i < mAPIData.size(); i++) {
        Match match = mAPIData.get(i);
        MatchType currentType = MatchType.fromShortType(match.getCompLevel());
        if (lastType != currentType) {
            switch(currentType) {
                case QUAL:
                    currentGroup = mQualMatches;
                    break;
                case OCTO:
                    currentGroup = mOctoMatches;
                    break;
                case QUARTER:
                    currentGroup = mQuarterMatches;
                    break;
                case SEMI:
                    currentGroup = mSemiMatches;
                    break;
                case FINAL:
                    currentGroup = mFinalMatches;
                    break;
            }
        }
        currentGroup.children.add(match);
        if (lastMatchPlayed && !match.hasBeenPlayed()) {
            lastMatch = previousIteration;
            nextMatch = match;
        }
        /* Track alliance advancement, indexed by captain team key */
        if (currentType == MatchType.FINAL && match.hasBeenPlayed()) {
            // Need to ensure we can differentiate who won the finals
            if ("red".equals(match.getWinningAlliance())) {
                redFinalsWon++;
            } else if ("blue".equals(match.getWinningAlliance())) {
                blueFinalsWon++;
            }
        }
        /**
         * the only reason this isn't moved to PopulateTeamAtEvent is that if so,
         * we'd have to iterate through every match again to calculate the
         * record, and that's just wasteful
         */
        if (mTeamKey != null) {
            match.addToRecord(mTeamKey, record);
        }
        lastType = currentType;
        previousIteration = match;
        lastMatchPlayed = match.hasBeenPlayed();
    }
    if (lastMatch == null && !mAPIData.isEmpty()) {
        Match last = mAPIData.get(mAPIData.size() - 1);
        if (last.hasBeenPlayed()) {
            lastMatch = last;
        }
    }
    if (nextMatch != null && nextMatch.hasBeenPlayed()) {
        // Avoids bug where matches loop over when all played
        // Because nextMatch is initialized to the first qual match
        // So that it displayed before any have been played
        nextMatch = null;
    }
    if (!mQualMatches.children.isEmpty()) {
        mDataToBind.add(mQualMatches);
    }
    if (!mOctoMatches.children.isEmpty()) {
        mDataToBind.add(mOctoMatches);
    }
    if (!mQuarterMatches.children.isEmpty()) {
        mDataToBind.add(mQuarterMatches);
    }
    if (!mSemiMatches.children.isEmpty()) {
        mDataToBind.add(mSemiMatches);
    }
    if (!mFinalMatches.children.isEmpty()) {
        mDataToBind.add(mFinalMatches);
    }
    mEventBus.post(new LiveEventMatchUpdateEvent(lastMatch, nextMatch));
}
Also used : MatchType(com.thebluealliance.androidclient.types.MatchType) MatchSortByDisplayOrderComparator(com.thebluealliance.androidclient.comparators.MatchSortByDisplayOrderComparator) ListGroup(com.thebluealliance.androidclient.listitems.ListGroup) LiveEventMatchUpdateEvent(com.thebluealliance.androidclient.eventbus.LiveEventMatchUpdateEvent) EventMatchesEvent(com.thebluealliance.androidclient.eventbus.EventMatchesEvent) Event(com.thebluealliance.androidclient.models.Event) MatchSortByPlayOrderComparator(com.thebluealliance.androidclient.comparators.MatchSortByPlayOrderComparator) LiveEventMatchUpdateEvent(com.thebluealliance.androidclient.eventbus.LiveEventMatchUpdateEvent) Match(com.thebluealliance.androidclient.models.Match)

Aggregations

ListGroup (com.thebluealliance.androidclient.listitems.ListGroup)3 Event (com.thebluealliance.androidclient.models.Event)2 TextView (android.widget.TextView)1 MatchSortByDisplayOrderComparator (com.thebluealliance.androidclient.comparators.MatchSortByDisplayOrderComparator)1 MatchSortByPlayOrderComparator (com.thebluealliance.androidclient.comparators.MatchSortByPlayOrderComparator)1 EventMatchesEvent (com.thebluealliance.androidclient.eventbus.EventMatchesEvent)1 LiveEventMatchUpdateEvent (com.thebluealliance.androidclient.eventbus.LiveEventMatchUpdateEvent)1 DistrictPointBreakdown (com.thebluealliance.androidclient.models.DistrictPointBreakdown)1 Match (com.thebluealliance.androidclient.models.Match)1 MatchType (com.thebluealliance.androidclient.types.MatchType)1 IDistrictEventPoints (com.thebluealliance.api.model.IDistrictEventPoints)1