Search in sources :

Example 1 with IDistrictEventPoints

use of com.thebluealliance.api.model.IDistrictEventPoints in project the-blue-alliance-android by the-blue-alliance.

the class TeamAtDistrictSummarySubscriber method parseData.

@Override
public void parseData() {
    mDataToBind.clear();
    EventsTable eventsTable = mDb.getEventsTable();
    mDataToBind.add(new LabelValueListItem(mResources.getString(R.string.district_point_rank), mAPIData.getRank() + Utilities.getOrdinalFor(mAPIData.getRank())));
    @Nullable IDistrictEventPoints event1Points = getEventPoints(mAPIData, 0);
    if (event1Points != null) {
        mDataToBind.add(renderEventPoints(mAPIData.getTeamKey(), event1Points, eventsTable, mResources));
    }
    @Nullable IDistrictEventPoints event2Points = getEventPoints(mAPIData, 1);
    if (event2Points != null) {
        mDataToBind.add(renderEventPoints(mAPIData.getTeamKey(), event2Points, eventsTable, mResources));
    }
    @Nullable IDistrictEventPoints cmpPoints = getEventPoints(mAPIData, 2);
    if (cmpPoints != null) {
        mDataToBind.add(renderEventPoints(mAPIData.getTeamKey(), cmpPoints, eventsTable, mResources));
    }
    if (mAPIData.getPointTotal() != null) {
        mDataToBind.add(new LabelValueListItem(mResources.getString(R.string.total_district_points), String.format(mResources.getString(R.string.district_points_format), mAPIData.getPointTotal())));
    }
    String actionBarTitle = String.format(mResources.getString(R.string.team_actionbar_title), mTeamKey.substring(3));
    String actionBarSubtitle = String.format("@ %1$s %2$s", mDistrictKey.substring(0, 4), mDistrictKey.substring(4).toUpperCase());
    mEventBus.post(new ActionBarTitleEvent(actionBarTitle, actionBarSubtitle));
}
Also used : LabelValueListItem(com.thebluealliance.androidclient.listitems.LabelValueListItem) IDistrictEventPoints(com.thebluealliance.api.model.IDistrictEventPoints) ActionBarTitleEvent(com.thebluealliance.androidclient.eventbus.ActionBarTitleEvent) EventsTable(com.thebluealliance.androidclient.database.tables.EventsTable) Nullable(javax.annotation.Nullable)

Example 2 with IDistrictEventPoints

use of com.thebluealliance.api.model.IDistrictEventPoints in project the-blue-alliance-android by the-blue-alliance.

the class ModelInflater method inflateDistrictTeam.

public static DistrictRanking inflateDistrictTeam(Cursor data, Gson gson) {
    DistrictRanking districtTeam = new DistrictRanking();
    IDistrictEventPoints[] events = new IDistrictEventPoints[3];
    for (int i = 0; i < data.getColumnCount(); i++) {
        switch(data.getColumnName(i)) {
            case DistrictTeamsTable.KEY:
                districtTeam.setKey(data.getString(i));
                break;
            case DistrictTeamsTable.TEAM_KEY:
                districtTeam.setTeamKey(data.getString(i));
                break;
            case DistrictTeamsTable.DISTRICT_KEY:
                districtTeam.setDistrictKey(data.getString(i));
                break;
            case DistrictTeamsTable.RANK:
                districtTeam.setRank(data.getInt(i));
                break;
            case DistrictTeamsTable.EVENT1_POINTS:
                events[0] = gson.fromJson(data.getString(i), IDistrictEventPoints.class);
                break;
            case DistrictTeamsTable.EVENT2_POINTS:
                events[1] = gson.fromJson(data.getString(i), IDistrictEventPoints.class);
                break;
            case DistrictTeamsTable.CMP_POINTS:
                events[2] = gson.fromJson(data.getString(i), IDistrictEventPoints.class);
                break;
            case DistrictTeamsTable.ROOKIE_POINTS:
                districtTeam.setRookieBonus(data.getInt(i));
                break;
            case DistrictTeamsTable.TOTAL_POINTS:
                districtTeam.setPointTotal(data.getInt(i));
                break;
            case DistrictTeamsTable.LAST_MODIFIED:
                districtTeam.setLastModified(data.getLong(i));
                break;
            default:
        }
    }
    List<IDistrictEventPoints> eventPoints = new ArrayList<>();
    for (IDistrictEventPoints event : events) {
        if (event == null)
            break;
        eventPoints.add(event);
    }
    districtTeam.setEventPoints(eventPoints);
    return districtTeam;
}
Also used : IDistrictEventPoints(com.thebluealliance.api.model.IDistrictEventPoints) ArrayList(java.util.ArrayList) DistrictRanking(com.thebluealliance.androidclient.models.DistrictRanking)

Example 3 with IDistrictEventPoints

use of com.thebluealliance.api.model.IDistrictEventPoints 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 4 with IDistrictEventPoints

use of com.thebluealliance.api.model.IDistrictEventPoints in project the-blue-alliance-android by the-blue-alliance.

the class DistrictRanking method getParams.

@Override
public ContentValues getParams(Gson gson) {
    ContentValues params = new ContentValues();
    @Nullable IDistrictEventPoints event1 = eventPoints != null && eventPoints.size() >= 1 ? eventPoints.get(0) : null;
    @Nullable IDistrictEventPoints event2 = eventPoints != null && eventPoints.size() >= 2 ? eventPoints.get(1) : null;
    @Nullable IDistrictEventPoints event3 = eventPoints != null && eventPoints.size() >= 3 ? eventPoints.get(2) : null;
    params.put(DistrictTeamsTable.KEY, getKey());
    params.put(DistrictTeamsTable.TEAM_KEY, getTeamKey());
    params.put(DistrictTeamsTable.DISTRICT_KEY, getDistrictKey());
    params.put(DistrictTeamsTable.RANK, getRank());
    params.put(DistrictTeamsTable.EVENT1_KEY, event1 != null ? event1.getEventKey() : "");
    params.put(DistrictTeamsTable.EVENT1_POINTS, gson.toJson(event1, IDistrictEventPoints.class));
    params.put(DistrictTeamsTable.EVENT2_KEY, event2 != null ? event2.getEventKey() : "");
    params.put(DistrictTeamsTable.EVENT2_POINTS, gson.toJson(event2, IDistrictEventPoints.class));
    params.put(DistrictTeamsTable.CMP_KEY, event3 != null ? event3.getEventKey() : "");
    params.put(DistrictTeamsTable.CMP_POINTS, gson.toJson(event3, IDistrictEventPoints.class));
    params.put(DistrictTeamsTable.ROOKIE_POINTS, getRookieBonus());
    params.put(DistrictTeamsTable.TOTAL_POINTS, getPointTotal());
    params.put(DistrictTeamsTable.LAST_MODIFIED, getLastModified());
    return params;
}
Also used : ContentValues(android.content.ContentValues) IDistrictEventPoints(com.thebluealliance.api.model.IDistrictEventPoints) Nullable(javax.annotation.Nullable)

Aggregations

IDistrictEventPoints (com.thebluealliance.api.model.IDistrictEventPoints)4 Nullable (javax.annotation.Nullable)2 ContentValues (android.content.ContentValues)1 EventsTable (com.thebluealliance.androidclient.database.tables.EventsTable)1 ActionBarTitleEvent (com.thebluealliance.androidclient.eventbus.ActionBarTitleEvent)1 LabelValueListItem (com.thebluealliance.androidclient.listitems.LabelValueListItem)1 ListGroup (com.thebluealliance.androidclient.listitems.ListGroup)1 DistrictPointBreakdown (com.thebluealliance.androidclient.models.DistrictPointBreakdown)1 DistrictRanking (com.thebluealliance.androidclient.models.DistrictRanking)1 Event (com.thebluealliance.androidclient.models.Event)1 ArrayList (java.util.ArrayList)1