...
 
Commits (2)
......@@ -122,8 +122,21 @@ public class MainActivity extends AppCompatActivity implements AddPlayerDialog.A
}
private void showPlayers() {
mPlayerOne.setText(mPlayers.get(0).getName());
mPlayerTwo.setText(mPlayers.get(1).getName());
// Get players
Player player1 = mPlayers.get(0);
Player player2 = mPlayers.get(1);
// Set Names
mPlayerOne.setText(player1.getName());
mPlayerTwo.setText(player2.getName());
// Resolve Colors (Using deprecated method as min SDK is API 21)
int x = getResources().getColor(R.color.colorX);
int o = getResources().getColor(R.color.colorO);
// Set player name to color
mPlayerOne.setTextColor(player1.getMark() == Mark.X ? x : o);
mPlayerTwo.setTextColor(player2.getMark() == Mark.X ? x : o);
}
@OnClick({R.id.cell_A1, R.id.cell_A2, R.id.cell_A3,
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
......@@ -16,6 +15,7 @@
<TextView
android:id="@+id/name_player_1"
style="@style/PlayerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
......@@ -37,6 +37,7 @@
<TextView
android:id="@+id/name_player_2"
style="@style/PlayerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
......
......@@ -4,4 +4,7 @@
<color name="colorPrimaryDark">#ba000d</color>
<color name="colorAccent">#2196f3</color>
<color name="colorCell">#eceff1</color>
<color name="colorX">@color/colorPrimary</color>
<color name="colorO">@color/colorAccent</color>
</resources>
......@@ -36,4 +36,8 @@
<item name="android:textAllCaps">true</item>
</style>
<style name="PlayerName">
<item name="android:textSize">18sp</item>
</style>
</resources>