use of com.thebluealliance.androidclient.listitems.LabelValueListItem 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.androidclient.listitems.LabelValueListItem in project the-blue-alliance-android by the-blue-alliance.
the class TeamAtDistrictSummarySubscriberTest method testParsedData.
@Test
public void testParsedData() {
List<ListItem> data = DatafeedTestDriver.getParsedData(mSubscriber, mDistrictTeam);
assertEquals(5, data.size());
LabelValueListItem rank = getItemAtPosition(0, data);
LabelValueDetailListItem event1 = getDetailItemAtPoistion(1, data);
LabelValueDetailListItem event2 = getDetailItemAtPoistion(2, data);
LabelValueDetailListItem cmp = getDetailItemAtPoistion(3, data);
LabelValueListItem total = getItemAtPosition(4, data);
String event1Key = EventTeamHelper.generateKey("2015nhnas", "frc1519");
String event2Key = EventTeamHelper.generateKey("2015manda", "frc1519");
String cmpKey = EventTeamHelper.generateKey("2015necmp", "frc1519");
assertEquals(new LabelValueListItem("District Rank", "1st"), rank);
assertEquals(new LabelValueDetailListItem("2015nhnas", "73 Points", event1Key), event1);
assertEquals(new LabelValueDetailListItem("2015manda", "73 Points", event2Key), event2);
assertEquals(new LabelValueDetailListItem("2015necmp", "219 Points", cmpKey), cmp);
assertEquals(new LabelValueListItem("Total Points", "365 Points"), total);
}
use of com.thebluealliance.androidclient.listitems.LabelValueListItem in project the-blue-alliance-android by the-blue-alliance.
the class MatchListAdapter method getChildView.
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
if (groupPosition >= mGroups.size() || childPosition >= mGroups.get(groupPosition).children.size()) {
// Can't render due to bounds errors
return new LabelValueListItem("Match", "Unable to render").getView(mActivity, mInflater, convertView);
}
RenderableModel child = mGroups.get(groupPosition).children.get(childPosition);
if (child instanceof Match) {
((Match) child).setSelectedTeam(mTeamKey);
}
ListItem renderedChild = child.render(mRendererSupplier);
if (renderedChild != null) {
return renderedChild.getView(mActivity, mInflater, convertView);
} else {
return new LabelValueListItem("Match", "Unable to render").getView(mActivity, mInflater, convertView);
}
}
use of com.thebluealliance.androidclient.listitems.LabelValueListItem in project the-blue-alliance-android by the-blue-alliance.
the class EventInsightsRenderer method addQualVsElimInsights.
void addQualVsElimInsights(JsonObject quals, JsonObject elims, @StringRes int[] titles, String[] jsonKeys) {
for (int i = 0; i < jsonKeys.length; i++) {
String qualStat = null, elimStat = null;
if (quals.has(jsonKeys[i]) && quals.get(jsonKeys[i]).isJsonPrimitive()) {
qualStat = df.format(quals.get(jsonKeys[i]).getAsDouble());
}
if (elims.has(jsonKeys[i]) && elims.get(jsonKeys[i]).isJsonPrimitive()) {
elimStat = df.format(elims.get(jsonKeys[i]).getAsDouble());
}
mEventStats.add(new LabelValueListItem(mResources.getString(titles[i]), combineQualAndElimStat(qualStat, elimStat), true));
}
}
use of com.thebluealliance.androidclient.listitems.LabelValueListItem in project the-blue-alliance-android by the-blue-alliance.
the class EventInsightsRenderer method addQualVsElimInsightsWithPercentage.
void addQualVsElimInsightsWithPercentage(JsonObject quals, JsonObject elims, @StringRes int[] titles, String[] jsonKeys) {
String format = mResources.getString(R.string.breakdown_percent_format);
for (int i = 0; i < jsonKeys.length; i++) {
String qualStat = null, elimStat = null;
if (quals.has(jsonKeys[i]) && quals.get(jsonKeys[i]).isJsonArray()) {
JsonArray qualData = quals.get(jsonKeys[i]).getAsJsonArray();
qualStat = String.format(format, qualData.get(0).getAsInt(), qualData.get(1).getAsInt(), qualData.get(2).getAsDouble());
}
if (elims.has(jsonKeys[i]) && elims.get(jsonKeys[i]).isJsonArray()) {
JsonArray elimData = elims.get(jsonKeys[i]).getAsJsonArray();
elimStat = String.format(format, // # success
elimData.get(0).getAsInt(), // # Opportunities
elimData.get(1).getAsInt(), // Completion Percentage
elimData.get(2).getAsDouble());
}
mEventStats.add(new LabelValueListItem(mResources.getString(titles[i]), combineQualAndElimStat(qualStat, elimStat), true));
}
}
Aggregations