use of com.thebluealliance.androidclient.models.DistrictPointBreakdown 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.androidclient.models.DistrictPointBreakdown in project the-blue-alliance-android by the-blue-alliance.
the class DistrictPointsListSubscriber method parseData.
@Override
public void parseData() {
mDataToBind.clear();
JsonObject rankingsData = mAPIData.getAsJsonObject();
if (!rankingsData.has("points")) {
return;
}
JsonObject points = rankingsData.get("points").getAsJsonObject();
String districtKey = "";
Event event = mDb.getEventsTable().get(mEventKey);
if (event != null) {
boolean isDistrict = (event.getDistrict() != null);
((Type) mDataToBind).isDistrict = isDistrict;
if (isDistrict) {
districtKey = event.getDistrict().getKey();
}
}
ArrayList<DistrictPointBreakdown> pointBreakdowns = new ArrayList<>();
for (Map.Entry<String, JsonElement> teamPoints : points.entrySet()) {
Team team = mDb.getTeamsTable().get(teamPoints.getKey());
DistrictPointBreakdown b = mGson.fromJson(teamPoints.getValue(), DistrictPointBreakdown.class);
b.setTeamKey(teamPoints.getKey());
b.setTeamName(team != null ? team.getNickname() : "Team " + teamPoints.getKey().substring(3));
b.setDistrictKey(districtKey);
pointBreakdowns.add(b);
}
Collections.sort(pointBreakdowns, new PointBreakdownComparater());
for (int i = 0; i < pointBreakdowns.size(); i++) {
pointBreakdowns.get(i).setRank(i + 1);
mDataToBind.add(mRenderer.renderFromModel(pointBreakdowns.get(i), null));
}
}
Aggregations