private String calculateKillsPerShot() { final double shotsFired = weapon.getShotsFired(); if (shotsFired == 0) { return "0"; } return NumberFormatter.format(weapon.getKills() / shotsFired); }
private void populateStatistics(View view) { setText(view, R.id.value_kills, NumberFormatter.format(weapon.getKills())); setText(view, R.id.value_headshots, NumberFormatter.format(weapon.getHeadshotCount())); setText(view, R.id.value_shots_fired, NumberFormatter.format(weapon.getShotsFired())); setText(view, R.id.value_accuracy, NumberFormatter.format(weapon.getAccuracy() * 100) + "%"); setText(view, R.id.value_time_equipped, DateTimeUtils.toLiteral(weapon.getTimeEquipped())); setText(view, R.id.value_kills_per_shot, calculateKillsPerShot()); switch (weaponCategory) { case GADGETS: setVisibility(view, R.id.wrap_shots_fired, View.VISIBLE); setVisibility(view, R.id.wrap_accuracy, View.VISIBLE); break; case GRENADE: setVisibility(view, R.id.wrap_shots_fired, View.VISIBLE); setVisibility(view, R.id.wrap_accuracy, View.VISIBLE); break; case ASSAULT_RIFLE: case CARBINE: case SNIPER: case SHOTGUN: case HANDGUN: case DMR: case LMG: setVisibility(view, R.id.wrap_headshots, View.VISIBLE); setVisibility(view, R.id.wrap_shots_fired, View.VISIBLE); setVisibility(view, R.id.wrap_accuracy, View.VISIBLE); break; default: break; } }