use of com.thebluealliance.androidclient.models.Team in project the-blue-alliance-android by the-blue-alliance.
the class TeamInfoSubscriber method parseData.
@Override
public void parseData() {
mDataToBind = new TeamInfoBinder.Model();
Map<MediaType, String> socialMediaByType = Utilities.getMapForPlatform(MediaType.class, String.class);
Team team = mAPIData.team;
List<Media> socialMedia = mAPIData.socialMedia;
mDataToBind.teamKey = team.getKey();
mDataToBind.fullName = team.getName();
mDataToBind.nickname = team.getNickname();
mDataToBind.teamNumber = team.getTeamNumber();
mDataToBind.location = team.getLocation();
if (team.getWebsite() != null) {
mDataToBind.website = team.getWebsite();
} else {
mDataToBind.website = "";
}
if (team.getMotto() != null) {
mDataToBind.motto = team.getMotto();
} else {
mDataToBind.motto = "";
}
// Separate social medias by type
mDataToBind.socialMedia = socialMediaByType;
for (int i = 0; socialMedia != null && i < socialMedia.size(); i++) {
Media media = socialMedia.get(i);
MediaType mediaType = MediaType.fromString(media.getType());
socialMediaByType.put(mediaType, media.getForeignKey());
}
// CMP Pit Location Stuff
mDataToBind.showPitLocation = PitLocationHelper.shouldShowPitLocation(mAppConfig);
mDataToBind.pitLocation = PitLocationHelper.getPitLocation(mContext, team.getKey());
}
use of com.thebluealliance.androidclient.models.Team in project the-blue-alliance-android by the-blue-alliance.
the class TeamListRecyclerSubscriber method parseData.
@Override
public void parseData() {
mDataToBind.clear();
Collections.sort(mAPIData, mComparator);
for (int i = 0; i < mAPIData.size(); i++) {
Team team = mAPIData.get(i);
if (team == null) {
continue;
}
TeamViewModel item = team.renderToViewModel(mContext, mRenderMode);
if (item == null) {
continue;
}
mDataToBind.add(item);
}
}
use of com.thebluealliance.androidclient.models.Team in project the-blue-alliance-android by the-blue-alliance.
the class TeamListSubscriber method parseData.
@Override
public void parseData() {
mDataToBind.clear();
Collections.sort(mAPIData, mComparator);
for (int i = 0; i < mAPIData.size(); i++) {
Team team = mAPIData.get(i);
if (team == null) {
continue;
}
ListItem item = mRenderer.renderFromModel(team, mRenderMode);
if (item == null) {
continue;
}
mDataToBind.add(item);
}
}
use of com.thebluealliance.androidclient.models.Team 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.Team in project the-blue-alliance-android by the-blue-alliance.
the class RankingsListSubscriber method parseData.
@Override
public void parseData() {
mDataToBind.clear();
if (mAPIData == null || mAPIData.getRankings() == null || mAPIData.getRankings().isEmpty()) {
return;
}
List<IRankingItem> rankings = mAPIData.getRankings();
List<IRankingSortOrder> sortOrders = mAPIData.getSortOrderInfo();
List<IRankingSortOrder> extraStats = mAPIData.getExtraStatsInfo();
IRankingSortOrder firstSortInfo = sortOrders.remove(0);
for (int i = 0; i < rankings.size(); i++) {
IRankingItem row = rankings.get(i);
/* Assume that the list of lists has rank first and team # second, always */
String teamKey = row.getTeamKey();
String rankingString;
String rankingSummary;
String record;
@Nullable ITeamRecord teamRecord = row.getRecord();
if (teamRecord != null) {
record = "(" + RankingItem.TeamRecord.buildRecordString(teamRecord) + ")";
} else {
record = "";
}
// Remove the first sort item so we don't show duplicates
Double firstSort = row.getSortOrders().remove(0);
rankingSummary = mResources.getString(R.string.rank_item_summary, firstSortInfo.getName(), formatSortOrder(firstSortInfo, firstSort));
rankingString = buildRankingString(row, sortOrders, extraStats, mResources, BOLD_TITLES | LINE_BREAKS);
Team team = mDb.getTeamsTable().get(teamKey);
String nickname;
if (team != null) {
nickname = team.getNickname();
} else {
nickname = "Team " + teamKey.substring(3);
}
mDataToBind.add(new TeamRankingViewModel(teamKey, nickname, // team number
teamKey.substring(3), // rank
row.getRank(), record, rankingSummary, rankingString));
}
mEventBus.post(new EventRankingsEvent(generateTopRanksString(mAPIData)));
}
Aggregations