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));
}
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;
}
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);
}
}
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;
}
Aggregations