use of com.thebluealliance.androidclient.models.Match in project the-blue-alliance-android by the-blue-alliance.
the class ScoreNotification method parseMessageData.
@Override
public void parseMessageData() throws JsonParseException {
JsonObject jsonData = JSONHelper.getasJsonObject(messageData);
if (!jsonData.has("match")) {
throw new JsonParseException("Notification data does not contain 'match");
}
JsonObject match = jsonData.get("match").getAsJsonObject();
this.match = mGson.fromJson(match, Match.class);
this.matchKey = this.match.getKey();
this.eventKey = MatchHelper.getEventKeyFromMatchKey(matchKey);
if (!jsonData.has("event_name")) {
throw new JsonParseException("Notification data does not contain 'event_name");
}
eventName = jsonData.get("event_name").getAsString();
}
use of com.thebluealliance.androidclient.models.Match in project the-blue-alliance-android by the-blue-alliance.
the class ModelInflater method inflateMatch.
/**
* Inflate a match model from a single row of a cursor returned by a database query.
*
* @param data Cursor of data. Ensure that it's not null and is pointing to a valid row
* @return Match model containing the fields as defined in the cursor
*/
public static Match inflateMatch(Cursor data, Gson gson) {
Match match = new Match();
for (int i = 0; i < data.getColumnCount(); i++) {
switch(data.getColumnName(i)) {
case MatchesTable.KEY:
match.setKey(data.getString(i));
match.setCompLevel(MatchType.fromKey(match.getKey()).getCompLevel());
break;
case MatchesTable.TIME:
match.setTime(data.getLong(i));
break;
case MatchesTable.ALLIANCES:
match.setAlliances(gson.fromJson(data.getString(i), MatchAlliancesContainer.class));
break;
case MatchesTable.WINNER:
match.setWinningAlliance(data.getString(i));
break;
case MatchesTable.VIDEOS:
match.setVideos(gson.fromJson(data.getString(i), new TypeToken<List<Match.MatchVideo>>() {
}.getType()));
break;
case MatchesTable.MATCHNUM:
match.setMatchNumber(data.getInt(i));
break;
case MatchesTable.SETNUM:
match.setSetNumber(data.getInt(i));
break;
case MatchesTable.BREAKDOWN:
match.setScoreBreakdown(data.getString(i));
break;
case MatchesTable.LAST_MODIFIED:
match.setLastModified(data.getLong(i));
break;
case MatchesTable.EVENT:
match.setEventKey(data.getString(i));
break;
default:
}
}
return match;
}
use of com.thebluealliance.androidclient.models.Match 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.models.Match in project the-blue-alliance-android by the-blue-alliance.
the class ScoreNotificationTest method testDbWrite.
@Test
public void testDbWrite() {
mNotification.parseMessageData();
mNotification.updateDataLocally();
Match match = mNotification.getMatch();
verify(mWriter).write(eq(match), anyLong());
}
use of com.thebluealliance.androidclient.models.Match in project the-blue-alliance-android by the-blue-alliance.
the class MatchHelperTest method markMatchesPlayed.
private static void markMatchesPlayed(List<Match> matches, int start, int end) {
for (int i = start; i < matches.size() && i < end; i++) {
Match match = matches.get(i);
when(match.hasBeenPlayed()).thenReturn(true);
}
}
Aggregations