Search in sources :

Example 1 with MatchupsTip

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;
}
Also used : Player(fr.neamar.lolgamedata.pojo.Player) ArrayList(java.util.ArrayList) MatchupsTip(fr.neamar.lolgamedata.tips.MatchupsTip) Tip(fr.neamar.lolgamedata.tips.Tip) Team(fr.neamar.lolgamedata.pojo.Team) MatchupsTip(fr.neamar.lolgamedata.tips.MatchupsTip)

Example 2 with MatchupsTip

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);
    }
}
Also used : LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) MatchupsTip(fr.neamar.lolgamedata.tips.MatchupsTip) ImageView(android.widget.ImageView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View)

Aggregations

MatchupsTip (fr.neamar.lolgamedata.tips.MatchupsTip)2 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Player (fr.neamar.lolgamedata.pojo.Player)1 Team (fr.neamar.lolgamedata.pojo.Team)1 Tip (fr.neamar.lolgamedata.tips.Tip)1 ArrayList (java.util.ArrayList)1