use of com.thebluealliance.androidclient.models.DistrictRanking in project the-blue-alliance-android by the-blue-alliance.
the class DistrictTeamDeserializer method deserialize.
@Override
public DistrictRanking deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
final JsonObject object = json.getAsJsonObject();
final DistrictRanking districtTeam = new DistrictRanking();
if (!isNull(object.get("team_key"))) {
districtTeam.setTeamKey(object.get("team_key").getAsString());
}
if (!isNull(object.get("rank"))) {
districtTeam.setRank(object.get("rank").getAsInt());
}
if (!isNull(object.get("rookie_bonus"))) {
districtTeam.setRookieBonus(object.get("rookie_bonus").getAsInt());
}
if (!isNull(object.get("point_total"))) {
districtTeam.setPointTotal(object.get("point_total").getAsInt());
}
if (!isNull(object.get("event_points"))) {
districtTeam.setEventPoints(context.deserialize(object.get("event_points"), new TypeToken<List<DistrictPointBreakdown>>() {
}.getType()));
}
return districtTeam;
}
use of com.thebluealliance.androidclient.models.DistrictRanking 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.androidclient.models.DistrictRanking in project the-blue-alliance-android by the-blue-alliance.
the class DistrictTeamListWriterTest method testDistrictTeamListWriter.
@Test
public void testDistrictTeamListWriter() {
mWriter.write(mDistrictTeams, 0L);
SQLiteDatabase db = mDb.getWritableDatabase();
for (DistrictRanking districtTeam : mDistrictTeams) {
verify(db).insert(Database.TABLE_DISTRICTTEAMS, null, districtTeam.getParams(mGson));
}
}
use of com.thebluealliance.androidclient.models.DistrictRanking in project the-blue-alliance-android by the-blue-alliance.
the class DistrictTeamsTableTest method testUpdate.
@Test
public void testUpdate() {
DistrictRanking result = DbTableTestDriver.testUpdate(mTable, mDistrictTeams.get(0), dt -> dt.setRank(1124), mGson);
assertNotNull(result);
assertEquals(1124, result.getRank().intValue());
}
use of com.thebluealliance.androidclient.models.DistrictRanking in project the-blue-alliance-android by the-blue-alliance.
the class DistrictTeamExtractorTest method testDistrictTeamExtractor.
@Test
public void testDistrictTeamExtractor() {
DistrictRanking extracted = mExtractor.call(mDistrictTeams);
assertNotNull(extracted);
assertEquals(extracted.getTeamKey(), mSearchTeamKey);
}
Aggregations