use of com.thebluealliance.androidclient.models.Award in project the-blue-alliance-android by the-blue-alliance.
the class AwardsListSubscriber method parseData.
@Override
public void parseData() {
mDataToBind.clear();
Map<String, Team> teams = Utilities.getMapForPlatform(String.class, Team.class);
ArrayList<Award> sortedAwards = new ArrayList<>(mAPIData);
Collections.sort(sortedAwards, AWARD_COMPARATOR);
for (int i = 0; i < sortedAwards.size(); i++) {
Award award = sortedAwards.get(i);
if (award.getRecipientList() == null)
continue;
for (IAwardRecipient winner : award.getRecipientList()) {
if (winner != null && winner.getTeamKey() != null) {
String teamKey = winner.getTeamKey();
Team team = mDb.getTeamsTable().get(teamKey);
teams.put(teamKey, team);
}
}
AwardRenderer.RenderArgs args = new AwardRenderer.RenderArgs(teams, mTeamKey);
mDataToBind.add(mRenderer.renderFromModel(award, args));
}
}
use of com.thebluealliance.androidclient.models.Award in project the-blue-alliance-android by the-blue-alliance.
the class AwardListWriterTest method testAwardListWriter.
@Test
public void testAwardListWriter() {
mWriter.write(mAwards, 0L);
SQLiteDatabase db = mDb.getWritableDatabase();
for (Award award : mAwards) {
verify(db).insert(Database.TABLE_AWARDS, null, award.getParams(mGson));
}
}
use of com.thebluealliance.androidclient.models.Award in project the-blue-alliance-android by the-blue-alliance.
the class AwardsTableTest method testUpdate.
@Test
public void testUpdate() {
Award result = DbTableTestDriver.testUpdate(mTable, mAwards.get(0), award -> award.setName("This is an award"), mGson);
assertNotNull(result);
assertEquals("This is an award", result.getName());
}
use of com.thebluealliance.androidclient.models.Award in project the-blue-alliance-android by the-blue-alliance.
the class TBAApiTest method testParseAwardNoTeam.
@org.junit.Test
public void testParseAwardNoTeam() {
String json = "{\n" + " \"event_key\": \"2010sc\",\n" + " \"name\": \"FIRST Dean's List Finalist Award\",\n" + " \"recipient_list\": [\n" + " {\n" + " \"team_number\": null,\n" + " \"awardee\": \"Brandon Dean\"\n" + " },\n" + " {\n" + " \"team_number\": null,\n" + " \"awardee\": \"Megan Shew\"\n" + " }\n" + " ],\n" + " \"year\": 2010\n" + " }";
Award award = JSONHelper.getGson().fromJson(json, Award.class);
assertEquals(award.getEventKey(), "2010sc");
assertEquals(award.getName(), "FIRST Dean's List Finalist Award");
assertEquals(award.getYear().intValue(), 2010);
/*
JsonArray recips = award.getWinners();
String[] winners = {"Brandon Dean", "Megan Shew"};
assertNotNull(recips);
assertEquals(recips.size(), 2);
for (int i = 0; i < 2; i++) {
assertEquals(winners[i], recips.get(i).getAsJsonObject().get("awardee").getAsString());
}*/
}
use of com.thebluealliance.androidclient.models.Award in project the-blue-alliance-android by the-blue-alliance.
the class AwardsTable method getTeamAtEventAwards.
public List<Award> getTeamAtEventAwards(String teamNumber, String eventKey) {
Cursor cursor = mDb.rawQuery("SELECT * FROM `" + Database.TABLE_AWARDS + "` WHERE `" + EVENTKEY + "` = ? AND `" + WINNERS + "` LIKE '%\"team_key\":\"frc" + teamNumber + "\"%'", new String[] { eventKey });
List<Award> models = new ArrayList<>(cursor == null ? 0 : cursor.getCount());
if (cursor == null || !cursor.moveToFirst()) {
return models;
}
do {
models.add(inflate(cursor));
} while (cursor.moveToNext());
return models;
}
Aggregations