Commit 911ed1a7 authored by rakam's avatar rakam

Improves some details (Court and Team's name in MatchActivity...)

parent 56a88235
......@@ -66,8 +66,8 @@ public class DoubleMatchActivity extends MatchActivity {
playerLeft2Name.setText(playerInfoA2.getName());
playerRight1Name.setText(playerInfoB1.getName());
playerRight2Name.setText(playerInfoB2.getName());
playerLeftNat.setText(playerInfoA1.getNationality());
playerRightNat.setText(playerInfoB1.getNationality());
playerLeftNat.setText(playerInfoA1.getTeam().getName());
playerRightNat.setText(playerInfoB1.getTeam().getName());
Ion.with(DoubleMatchActivity.this).load(playerInfoA1.getPhotoUrl()).asBitmap().setCallback(new FutureCallback<Bitmap>() {
@Override
public void onCompleted(Exception e, Bitmap result) {
......@@ -116,8 +116,8 @@ public class DoubleMatchActivity extends MatchActivity {
playerLeft2Name.setText(playerInfoB2.getName());
playerRight1Name.setText(playerInfoA1.getName());
playerRight2Name.setText(playerInfoA2.getName());
playerLeftNat.setText(playerInfoB1.getNationality());
playerRightNat.setText(playerInfoA1.getNationality());
playerLeftNat.setText(playerInfoB1.getTeam().getName());
playerRightNat.setText(playerInfoA1.getTeam().getName());
Ion.with(DoubleMatchActivity.this).load(playerInfoA1.getPhotoUrl()).asBitmap().setCallback(new FutureCallback<Bitmap>() {
@Override
public void onCompleted(Exception e, Bitmap result) {
......
......@@ -96,19 +96,20 @@ public class HomeActivity extends Activity {
int idPlayerB1 = jsonMatch.getAsJsonPrimitive("IdPlayerB_1").getAsInt();
String nameA1 = Utils.getStringFromJson(jsonMatch, "Player_A1");
String nameB1 = Utils.getStringFromJson(jsonMatch, "Player_B1");
playerA1 = new PlayerInfo(idPlayerA1, PlayerInfo.MAN, nameA1, teamA.getISO());
playerB1 = new PlayerInfo(idPlayerB1, PlayerInfo.MAN, nameB1, teamB.getISO());
playerA1 = new PlayerInfo(idPlayerA1, PlayerInfo.MAN, nameA1, teamA);
playerB1 = new PlayerInfo(idPlayerB1, PlayerInfo.MAN, nameB1, teamB);
if (category.contains("D")) {
int idPlayerA2 = jsonMatch.getAsJsonPrimitive("IdPlayerA_2").getAsInt();
int idPlayerB2 = jsonMatch.getAsJsonPrimitive("IdPlayerB_2").getAsInt();
String nameA2 = Utils.getStringFromJson(jsonMatch, "Player_A2");
String nameB2 = Utils.getStringFromJson(jsonMatch, "Player_B2");
playerA2 = new PlayerInfo(idPlayerA2, PlayerInfo.MAN, nameA2, teamA.getISO());
playerB2 = new PlayerInfo(idPlayerB2, PlayerInfo.MAN, nameB2, teamB.getISO());
playerA2 = new PlayerInfo(idPlayerA2, PlayerInfo.MAN, nameA2, teamA);
playerB2 = new PlayerInfo(idPlayerB2, PlayerInfo.MAN, nameB2, teamB);
} else {
playerA2 = null;
playerB2 = null;
}
final int court = jsonMatch.get("Court").getAsInt();
final MatchInfo match = new MatchInfo(automate.getIdMatch(), teamA, teamB, category, tableau);
resumeMatchButton.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -117,6 +118,7 @@ public class HomeActivity extends Activity {
Intent intent = new Intent(HomeActivity.this, DoubleMatchActivity.class);
intent.putExtra(MatchActivity.RESUME_MATCH, true);
intent.putExtra(MatchActivity.MATCH, match);
intent.putExtra(MatchActivity.COURT_NUM, court);
intent.putExtra(MatchActivity.PLAYER_A1, playerA1);
intent.putExtra(MatchActivity.PLAYER_A2, playerA2);
intent.putExtra(MatchActivity.PLAYER_B1, playerB1);
......@@ -126,6 +128,7 @@ public class HomeActivity extends Activity {
Intent intent = new Intent(HomeActivity.this, SingleMatchActivity.class);
intent.putExtra(MatchActivity.RESUME_MATCH, true);
intent.putExtra(MatchActivity.MATCH, match);
intent.putExtra(MatchActivity.COURT_NUM, court);
intent.putExtra(MatchActivity.PLAYER_A1, playerA1);
intent.putExtra(MatchActivity.PLAYER_B1, playerB1);
startActivity(intent);
......
......@@ -45,6 +45,7 @@ public abstract class MatchActivity extends Activity {
public static final String MATCH = "MATCH";
public static final String SIDE_LEFT_A = "SIDE_LEFT_A";
public static final String SERVICE = "SERVICE";
public static final String COURT_NUM = "COURT_NUM";
public static final String PLAYER_A1 = "PLAYER_A1";
public static final String PLAYER_A2 = "PLAYER_A2";
public static final String PLAYER_B1 = "PLAYER_B1";
......@@ -164,7 +165,16 @@ public abstract class MatchActivity extends Activity {
}
});
((TextView) findViewById(R.id.categorie)).setText(Utils.getCategorieName(match.getCategory()));
TextView categorieTV = ((TextView) findViewById(R.id.categorie));
if (match.getCategory().equals("SM")) {
int num = match.getId() % 7;
categorieTV.setText(Utils.getCategorieName(match.getCategory()) + " n°" + num);
} else if (match.getCategory().equals("SW")) {
int num = (match.getId() - 2) % 7;
categorieTV.setText(Utils.getCategorieName(match.getCategory()) + " n°" + num);
} else {
categorieTV.setText(Utils.getCategorieName(match.getCategory()));
}
findViewById(R.id.optionsButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
......@@ -182,6 +192,8 @@ public abstract class MatchActivity extends Activity {
}
});
int court = getIntent().getIntExtra(COURT_NUM, -1);
((TextView) findViewById(R.id.court)).setText(Utils.getCourtName(court));
boolean resumeMatch = getIntent().getBooleanExtra(RESUME_MATCH, false);
if (resumeMatch) {
automate = FileManager.importAutomate(this);
......
......@@ -156,6 +156,7 @@ public class MatchSetupActivity extends Activity implements OnMatchSelectedListe
if (refereeingType == Constants.SIMPLE) {
Intent matchActivityIntent = new Intent(MatchSetupActivity.this, SingleMatchActivity.class);
matchActivityIntent.putExtra(MatchActivity.MATCH, match);
matchActivityIntent.putExtra(MatchActivity.COURT_NUM, idCourt);
matchActivityIntent.putExtra(MatchActivity.SIDE_LEFT_A, side == Constants.A_IS_LEFT);
matchActivityIntent.putExtra(MatchActivity.SERVICE, firstServerTeam.getISO().equals(match.getTeamA().getISO()) ? 0 : 1);
matchActivityIntent.putExtra(MatchActivity.PLAYER_A1, playerA1);
......@@ -164,6 +165,7 @@ public class MatchSetupActivity extends Activity implements OnMatchSelectedListe
} else {
Intent matchActivityIntent = new Intent(MatchSetupActivity.this, DoubleMatchActivity.class);
matchActivityIntent.putExtra(MatchActivity.MATCH, match);
matchActivityIntent.putExtra(MatchActivity.COURT_NUM, idCourt);
matchActivityIntent.putExtra(MatchActivity.SIDE_LEFT_A, side == Constants.A_IS_LEFT);
matchActivityIntent.putExtra(MatchActivity.SERVICE, firstServerTeam.getISO().equals(match.getTeamA().getISO()) ? 0 : 1);
matchActivityIntent.putExtra(DoubleMatchActivity.REFEREEING_TYPE, refereeingType);
......
......@@ -57,8 +57,8 @@ public class SingleMatchActivity extends MatchActivity {
scorePlayerB = (TextView) findViewById(R.id.scoreRight);
playerLeft1Name.setText(playerInfoA1.getName());
playerRight1Name.setText(playerInfoB1.getName());
playerLeftNat.setText(playerInfoA1.getNationality());
playerRightNat.setText(playerInfoB1.getNationality());
playerLeftNat.setText(playerInfoA1.getTeam().getName());
playerRightNat.setText(playerInfoB1.getTeam().getName());
Ion.with(SingleMatchActivity.this).load(playerInfoA1.getPhotoUrl()).asBitmap().setCallback(new FutureCallback<Bitmap>() {
@Override
public void onCompleted(Exception e, Bitmap result) {
......@@ -87,8 +87,8 @@ public class SingleMatchActivity extends MatchActivity {
scorePlayerB = (TextView) findViewById(R.id.scoreLeft);
playerLeft1Name.setText(playerInfoB1.getName());
playerRight1Name.setText(playerInfoA1.getName());
playerLeftNat.setText(playerInfoB1.getNationality());
playerRightNat.setText(playerInfoA1.getNationality());
playerLeftNat.setText(playerInfoB1.getTeam().getName());
playerRightNat.setText(playerInfoA1.getTeam().getName());
Ion.with(SingleMatchActivity.this).load(playerInfoA1.getPhotoUrl())
.asBitmap()
.setCallback(new FutureCallback<Bitmap>() {
......
......@@ -10,7 +10,6 @@ import android.widget.ListView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.koushikdutta.async.future.FutureCallback;
import com.koushikdutta.ion.Ion;
......@@ -110,8 +109,6 @@ public class SelectMatchFragment extends SetupFragment implements OnMatchSelecte
TeamInfo teamB = new TeamInfo(isoB, teamNameB, flagB);
String category = o.get("Category").getAsString();
String tableau = o.get("Tableau").getAsString();
JsonElement courtElement = o.get("Court");
int court = courtElement.isJsonNull() ? -1 : courtElement.getAsInt();
matches.add(new MatchInfo(idMatch, teamA, teamB, category, tableau));
}
if (matches.size() == 0) {
......
......@@ -26,6 +26,7 @@ import fr.istic.masteru.android.adapters.PlayerAdapter;
import fr.istic.masteru.android.listeners.OnPlayerSelectedListener;
import fr.istic.masteru.android.model.MatchInfo;
import fr.istic.masteru.android.model.PlayerInfo;
import fr.istic.masteru.android.model.TeamInfo;
import fr.istic.masteru.android.utils.API_URLS;
public class SelectPlayersFragment extends SetupFragment {
......@@ -113,8 +114,8 @@ public class SelectPlayersFragment extends SetupFragment {
playerAList.setAdapter(playerAdapterA);
playerBList.setAdapter(playerAdapterB);
loadPlayers(TEAM_A);
loadPlayers(TEAM_B);
loadPlayers(match.getTeamA(), playersA, playerAdapterA);
loadPlayers(match.getTeamB(), playersB, playerAdapterB);
return root;
}
......@@ -130,11 +131,10 @@ public class SelectPlayersFragment extends SetupFragment {
}
}
private void loadPlayers(final int team) {
final String countryCode = team == TEAM_A ? match.getTeamA().getISO() : match.getTeamB().getISO();
private void loadPlayers(final TeamInfo team, final List<PlayerInfo> players, final PlayerAdapter adapter) {
String gender = match.getCategory().contains("M") ? "M" : match.getCategory().contains("W") ? "W" : "X";
String url = API_URLS.TEAM_PLAYERS(countryCode, gender);
String url = API_URLS.TEAM_PLAYERS(team.getISO(), gender);
Log.d("URL", url);
Ion.with(matchSetupActivity)
.load("GET", url)
......@@ -144,7 +144,7 @@ public class SelectPlayersFragment extends SetupFragment {
@Override
public void onCompleted(Exception e, JsonObject result) {
if (e != null || result != null && result.get("code").getAsInt() != 0) {
loadPlayers(team);
loadPlayers(team, players, adapter);
return;
}
progressBar.setVisibility(View.GONE);
......@@ -155,16 +155,10 @@ public class SelectPlayersFragment extends SetupFragment {
String name = o.get("Name").getAsString();
String firstName = o.get("FirstName").getAsString();
int gender = o.get("Sex").getAsString().equals("M") ? PlayerInfo.MAN : PlayerInfo.WOMAN;
PlayerInfo playerInfo = new PlayerInfo(playerId, gender, firstName + " " + name, countryCode);
if (team == TEAM_A)
playersA.add(playerInfo);
else
playersB.add(playerInfo);
PlayerInfo playerInfo = new PlayerInfo(playerId, gender, firstName + " " + name, team);
players.add(playerInfo);
}
if (team == TEAM_A)
playerAdapterA.notifyDataSetChanged();
else
playerAdapterB.notifyDataSetChanged();
adapter.notifyDataSetChanged();
}
});
}
......
......@@ -12,13 +12,13 @@ public class PlayerInfo implements Serializable {
private int id;
private int gender;
private String name;
private String nationality;
private TeamInfo team;
public PlayerInfo(int id, int gender, String name, String nationality) {
public PlayerInfo(int id, int gender, String name, TeamInfo team) {
this.id = id;
this.gender = gender;
this.name = name;
this.nationality = nationality;
this.team = team;
}
public int getGender() {
......@@ -41,8 +41,8 @@ public class PlayerInfo implements Serializable {
return name;
}
public String getNationality() {
return nationality;
public TeamInfo getTeam() {
return team;
}
public String getPhotoUrl() {
......
......@@ -74,6 +74,14 @@ public class Utils {
return null;
}
public static String getCourtName(int id) {
if (id == 1) {
return "Court central";
} else {
return "Court " + id;
}
}
public static Bitmap getPersonBitmap(Context context) {
if (person == null) {
person = BitmapFactory.decodeResource(context.getResources(), R.drawable.person);
......
......@@ -5,15 +5,25 @@
android:layout_height="match_parent"
android:background="#eee">
<TextView
android:id="@+id/categorie"
<fr.istic.masteru.android.views.RobotoTextView
android:id="@+id/court"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="4dp"
android:textSize="15sp"
android:text="Court 2"
android:textStyle="italic"/>
<fr.istic.masteru.android.views.RobotoTextView
android:id="@+id/categorie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/court"
android:layout_centerHorizontal="true"
android:text="MEN'S DOUBLE 1/2 "
android:textSize="18sp"
android:textStyle="bold"/>
android:textSize="15sp"
android:textStyle="italic"/>
<ImageView
android:id="@+id/playerLeft1Photo"
......@@ -52,12 +62,14 @@
android:textSize="20sp"
android:textStyle="bold"/>
<TextView
<fr.istic.masteru.android.views.RobotoTextView
android:id="@+id/playerLeftNatTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/playerLeft2NameTV"
android:layout_toRightOf="@id/playerLeft2Photo"
android:textStyle="italic"
android:textSize="15sp"
android:text="(SU)"/>
<ImageView
......@@ -98,12 +110,14 @@
android:textSize="20sp"
android:textStyle="bold"/>
<TextView
<fr.istic.masteru.android.views.RobotoTextView
android:id="@+id/playerRightNatTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/playerRight2NameTV"
android:layout_toLeftOf="@id/playerRight2Photo"
android:textStyle="italic"
android:textSize="15sp"
android:text="(FR)"/>
<TextView
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment