use of com.thebluealliance.androidclient.viewmodels.TeamRankingViewModel 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)));
}
use of com.thebluealliance.androidclient.viewmodels.TeamRankingViewModel in project the-blue-alliance-android by the-blue-alliance.
the class EventRankingsFragment method initializeAdapterCreator.
@Override
public void initializeAdapterCreator(SmartAdapter.MultiAdaptersCreator creator) {
creator.map(TeamRankingViewModel.class, TeamRankingItemView.class);
creator.listener((actionId, item, position, view) -> {
if (actionId == Interactions.TEAM_RANKING_CLICKED && item instanceof TeamRankingViewModel) {
TeamRankingViewModel ranking = (TeamRankingViewModel) item;
startActivity(TeamAtEventActivity.newInstance(getContext(), mEventKey, ranking.getTeamKey()));
/* Track the call */
AnalyticsHelper.sendClickUpdate(getActivity(), "team@event_click", "EventRankingsFragment", mEventKey);
} else if (actionId == Interactions.EXPAND_TEAM_RANKING && view instanceof TeamRankingItemView) {
TeamRankingItemView itemView = (TeamRankingItemView) view;
itemView.toggleRankingsExpanded();
}
});
}
Aggregations