use of fr.neamar.lolgamedata.pojo.Team in project teamward-client by Neamar.
the class PerformanceActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_performance);
final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
assert getSupportActionBar() != null;
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Game game = (Game) getIntent().getSerializableExtra("game");
player = (Player) getIntent().getSerializableExtra("player");
// Doing this in two steps, got some crash reports on the Store and trying to understand
// what can be Null: player.summoner, or summoner.name.
Summoner summoner = player.summoner;
// HERO
setTitle(summoner.name);
// CHAMPION MASTERY
View masteryHolder = findViewById(R.id.masteryHolder);
ImageView championMasteryImage = (ImageView) findViewById(R.id.championMasteryImage);
TextView championMasteryText = (TextView) findViewById(R.id.championMasteryText);
TextView championPointsText = (TextView) findViewById(R.id.championPointsText);
@DrawableRes int championMasteryResource = CHAMPION_MASTERIES_RESOURCES[player.champion.mastery];
if (championMasteryResource == 0) {
masteryHolder.setVisibility(View.GONE);
} else {
championMasteryImage.setImageResource(CHAMPION_MASTERIES_RESOURCES[player.champion.mastery]);
championMasteryText.setText(String.format(getString(R.string.champion_mastery_lvl), player.champion.mastery));
if (player.champion.mastery >= 5) {
championPointsText.setText(String.format(getString(R.string.champion_points), NumberFormat.getInstance().format(player.champion.points)));
} else {
championPointsText.setVisibility(View.GONE);
}
masteryHolder.setVisibility(View.VISIBLE);
}
// RANKED INFORMATION
View rankingHolder = findViewById(R.id.rankingHolder);
ImageView rankingTierImage = (ImageView) rankingHolder.findViewById(R.id.rankingTierImage);
TextView rankingText = (TextView) rankingHolder.findViewById(R.id.rankingText);
TextView rankingQueue = (TextView) rankingHolder.findViewById(R.id.rankingQueue);
if (player.rank.tier.isEmpty() || !RANKING_TIER_RESOURCES.containsKey(player.rank.tier.toLowerCase(Locale.ROOT))) {
rankingHolder.setVisibility(View.GONE);
} else {
rankingTierImage.setImageResource(RANKING_TIER_RESOURCES.get(player.rank.tier.toLowerCase(Locale.ROOT)));
rankingText.setText(String.format(getString(R.string.ranking), player.rank.tier.toUpperCase(Locale.ROOT), player.rank.division));
rankingHolder.setVisibility(View.VISIBLE);
rankingQueue.setText(getQueueName(player.rank.queue));
}
rankingHolder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://" + player.region + ".op.gg/summoner/userName=" + URLEncoder.encode(player.summoner.name, "UTF-8")));
startActivity(browserIntent);
Tracker.trackClickOnOpGG(PerformanceActivity.this, player);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ActivityNotFoundException e) {
Toast.makeText(PerformanceActivity.this, R.string.unable_to_open_browser, Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
});
// LAST SEASON RANKED INFORMATION
View lastSeasonRankHolder = findViewById(R.id.lastSeasonRankHolder);
ImageView lastRankingTierImage = (ImageView) lastSeasonRankHolder.findViewById(R.id.rankingTierImage);
TextView lastRankingText = (TextView) lastSeasonRankHolder.findViewById(R.id.rankingText);
// Do not display unranked, null, or any rank similar to current rank
if (player.rank.oldTier.isEmpty() || player.rank.oldTier.equals(player.rank.tier) || !RANKING_TIER_RESOURCES.containsKey(player.rank.oldTier.toLowerCase(Locale.ROOT))) {
lastSeasonRankHolder.setVisibility(View.GONE);
} else {
lastRankingTierImage.setImageResource(RANKING_TIER_RESOURCES.get(player.rank.oldTier.toLowerCase(Locale.ROOT)));
lastRankingText.setText(String.format(getString(R.string.ranking_last_season), player.rank.oldTier.toUpperCase(Locale.ROOT)));
lastSeasonRankHolder.setVisibility(View.VISIBLE);
}
// MATCHUP INFORMATION
View matchupHolder = findViewById(R.id.matchupHolder);
ImageView ownChampion = (ImageView) findViewById(R.id.ownChampion);
ImageView enemyChampion = (ImageView) findViewById(R.id.enemyChampion);
TextView matchupTextView = (TextView) findViewById(R.id.matchupStats);
final Team playerTeam = game.getTeamForPlayer(player);
Player oppositePlayer = null;
if (game.teams.size() > 1) {
Team otherTeam = game.teams.get(0) == playerTeam ? game.teams.get(1) : game.teams.get(0);
for (Player tplayer : otherTeam.players) {
if (player.champion.role.equals(tplayer.champion.role)) {
oppositePlayer = tplayer;
break;
}
}
}
if (playerTeam == null || player.champion.role.equals(ChampionInGame.UNKNOWN_ROLE) || oppositePlayer == null) {
matchupHolder.setVisibility(View.GONE);
} else {
ImageLoader.getInstance().displayImage(player.champion.imageUrl, ownChampion);
ImageLoader.getInstance().displayImage(oppositePlayer.champion.imageUrl, enemyChampion);
if (player.champion.winRate >= 0) {
matchupTextView.setText(String.format(Locale.getDefault(), "%d%%", player.champion.winRate));
if (player.champion.winRate > 50) {
matchupTextView.setTextColor(getResources().getColor(R.color.colorGoodMatchup));
} else if (player.champion.winRate < 50) {
matchupTextView.setTextColor(getResources().getColor(R.color.colorBadMatchup));
}
} else {
matchupTextView.setText("?");
matchupTextView.setTextColor(getResources().getColor(R.color.colorUnknownMatchup));
}
}
matchupHolder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(player.champion.ggUrl));
try {
startActivity(browserIntent);
} catch (ActivityNotFoundException e) {
Toast.makeText(PerformanceActivity.this, R.string.unable_to_open_browser, Toast.LENGTH_SHORT).show();
}
Tracker.trackClickOnGG(PerformanceActivity.this, player.champion.name, player.champion.id, "player_details");
}
});
// MAIN CHAMPIONS
if (player.mainChampions.size() == 0) {
findViewById(R.id.mainsHolder).setVisibility(View.GONE);
} else {
ChampionPortraitView main1 = ((ChampionPortraitView) findViewById(R.id.main1));
ChampionPortraitView main2 = ((ChampionPortraitView) findViewById(R.id.main2));
ChampionPortraitView main3 = ((ChampionPortraitView) findViewById(R.id.main3));
main1.setChampion(player.mainChampions.get(0));
if (player.mainChampions.size() == 3) {
main2.setChampion(player.mainChampions.get(1));
main3.setChampion(player.mainChampions.get(2));
} else if (player.mainChampions.size() == 2) {
main2.setChampion(player.mainChampions.get(1));
main3.setVisibility(View.GONE);
} else {
main2.setVisibility(View.GONE);
main3.setVisibility(View.GONE);
}
}
// RECENT MATCHES
TextView recentMatchesText = (TextView) findViewById(R.id.recentMatchesTitle);
recentMatchesText.setText(String.format(getString(R.string.recent_matches), player.champion.name));
findViewById(R.id.aggregate).setVisibility(View.GONE);
downloadPerformance();
// TEAMWARD USER
if (player.teamwardUser) {
findViewById(R.id.teamwardUser).setVisibility(View.VISIBLE);
}
}
use of fr.neamar.lolgamedata.pojo.Team in project teamward-client by Neamar.
the class FullAPDTeamTipBuilder method getTips.
@Override
public ArrayList<Tip> getTips(Game game, Context context) {
ArrayList<Tip> tips = new ArrayList<>();
// Full AP
for (Team team : game.teams) {
Boolean fullAP = true;
for (Player player : team.players) {
if (!player.champion.isAp()) {
fullAP = false;
break;
}
}
if (fullAP) {
String description = context.getString(R.string.full_ap);
description = String.format(description, team.getName(context));
tips.add(new PlayerStandardTip(game, null, MAGIC_MANTLE_URL, context.getString(R.string.such_ability), description));
}
}
// Full AD
for (Team team : game.teams) {
Boolean fullAD = true;
for (Player player : team.players) {
if (!player.champion.isAd() && !player.champion.role.equals("SUPPORT")) {
fullAD = false;
break;
}
}
if (fullAD) {
String description = context.getString(R.string.full_ad);
description = String.format(description, team.getName(context));
tips.add(new PlayerStandardTip(game, null, CLOTH_ARMOR, context.getString(R.string.much_damage), description));
}
}
return tips;
}
use of fr.neamar.lolgamedata.pojo.Team 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.pojo.Team in project teamward-client by Neamar.
the class OtpTipBuilder method getTips.
@Override
public ArrayList<Tip> getTips(Game game, Context context) {
ArrayList<Tip> tips = new ArrayList<>();
for (Team team : game.teams) {
for (Player player : team.players) {
if (player.champion.mastery == 7 && player.champion.championRank == 1) {
String descriptionTemplate = context.getString(R.string.main_level_7);
String description = String.format(descriptionTemplate, player.summoner.name, player.champion.name);
tips.add(new PlayerStandardTip(game, player, player.champion.imageUrl, context.getString(R.string.otp), description));
}
}
}
return tips;
}
use of fr.neamar.lolgamedata.pojo.Team in project teamward-client by Neamar.
the class TryHarderTipBuilder method getTips.
@Override
public ArrayList<Tip> getTips(Game game, Context context) {
ArrayList<Tip> tips = new ArrayList<>();
for (Team team : game.teams) {
int minMastery = 7;
for (Player player : team.players) {
minMastery = Math.min(player.champion.mastery, minMastery);
}
if (minMastery >= 4) {
String description = context.getString(R.string.try_harder_desc);
description = String.format(description, team.getName(context), minMastery);
tips.add(new PlayerStandardTip(game, null, PlayerHolder.CHAMPION_MASTERIES_RESOURCES[minMastery], context.getString(R.string.try_harder), description));
}
}
return tips;
}
Aggregations