use of fr.neamar.lolgamedata.tips.MatchupsTip in project teamward-client by Neamar.
the class MatchupsBuilder method getTips.
@Override
public ArrayList<Tip> getTips(Game game, Context context) {
ArrayList<Tip> tips = new ArrayList<>();
if (game.teams.size() != 2) {
return tips;
}
// Do not display on ARAM
if (game.mapId == 12) {
return tips;
}
Team playerTeam = game.getPlayerOwnTeam();
Team otherTeam = game.teams.get(0) == playerTeam ? game.teams.get(1) : game.teams.get(0);
ArrayList<MatchupsTip.Matchup> matchups = new ArrayList<>();
for (Player player : playerTeam.players) {
if (!player.champion.role.equals(ChampionInGame.UNKNOWN_ROLE)) {
// Does the other team have someone with this role too?
Player otherPlayer = getPlayerWithRole(otherTeam, player.champion.role);
if (otherPlayer != null) {
MatchupsTip.Matchup matchup = new MatchupsTip.Matchup(player, otherPlayer);
matchups.add(matchup);
}
}
}
if (matchups.size() > 0) {
MatchupsTip tip = new MatchupsTip(game, matchups);
tips.add(tip);
}
return tips;
}
use of fr.neamar.lolgamedata.tips.MatchupsTip in project teamward-client by Neamar.
the class MatchupsTipHolder method bind.
public void bind(Tip tip) {
MatchupsTip matchupsTip = (MatchupsTip) tip;
matchupsLayout.removeAllViews();
LayoutInflater inflater = LayoutInflater.from(matchupsLayout.getContext());
for (MatchupsTip.Matchup matchup : matchupsTip.matchups) {
View view = inflater.inflate(R.layout.item_tip_matchups_matchup, matchupsLayout, false);
ImageView ownChampionImageView = (ImageView) view.findViewById(R.id.ownChampion);
ImageLoader.getInstance().displayImage(matchup.ownPlayer.champion.imageUrl, ownChampionImageView);
ownChampionImageView.setContentDescription(matchup.ownPlayer.champion.name);
ImageView enemyChampionImageView = (ImageView) view.findViewById(R.id.enemyChampion);
ImageLoader.getInstance().displayImage(matchup.enemyPlayer.champion.imageUrl, enemyChampionImageView);
enemyChampionImageView.setContentDescription(matchup.enemyPlayer.champion.name);
TextView matchupTextView = (TextView) view.findViewById(R.id.matchupStats);
if (matchup.ownPlayer.champion.winRate >= 0) {
matchupTextView.setText(String.format(Locale.getDefault(), "%d%%", matchup.ownPlayer.champion.winRate));
if (matchup.ownPlayer.champion.winRate > 50) {
matchupTextView.setTextColor(matchupsLayout.getContext().getResources().getColor(R.color.colorGoodMatchup));
} else if (matchup.ownPlayer.champion.winRate < 50) {
matchupTextView.setTextColor(matchupsLayout.getContext().getResources().getColor(R.color.colorBadMatchup));
}
} else {
matchupTextView.setText("?");
matchupTextView.setTextColor(matchupsLayout.getContext().getResources().getColor(R.color.colorUnknownMatchup));
}
matchupsLayout.addView(view);
}
}
Aggregations