Commit 55d2d009 authored by rakam's avatar rakam

get players url from api

parent 81f8881f
......@@ -96,15 +96,19 @@ 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);
playerB1 = new PlayerInfo(idPlayerB1, PlayerInfo.MAN, nameB1, teamB);
String photoUrlA1 = Utils.getStringFromJson(jsonMatch, "UrlA_1");
String photoUrlB1 = Utils.getStringFromJson(jsonMatch, "UrlB_1");
playerA1 = new PlayerInfo(idPlayerA1, PlayerInfo.MAN, nameA1, photoUrlA1, teamA);
playerB1 = new PlayerInfo(idPlayerB1, PlayerInfo.MAN, nameB1, photoUrlB1, 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);
playerB2 = new PlayerInfo(idPlayerB2, PlayerInfo.MAN, nameB2, teamB);
String photoUrlA2 = Utils.getStringFromJson(jsonMatch, "UrlA_2");
String photoUrlB2 = Utils.getStringFromJson(jsonMatch, "UrlB_2");
playerA2 = new PlayerInfo(idPlayerA2, PlayerInfo.MAN, nameA2, photoUrlA2, teamA);
playerB2 = new PlayerInfo(idPlayerB2, PlayerInfo.MAN, nameB2, photoUrlB2, teamB);
} else {
playerA2 = null;
playerB2 = null;
......
......@@ -28,6 +28,7 @@ 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;
import fr.istic.masteru.android.utils.Utils;
public class SelectPlayersFragment extends SetupFragment {
......@@ -154,8 +155,9 @@ public class SelectPlayersFragment extends SetupFragment {
int playerId = o.get("IdPlayer").getAsInt();
String name = o.get("Name").getAsString();
String firstName = o.get("FirstName").getAsString();
String photoUrl = Utils.getStringFromJson(o, "Url");
int gender = o.get("Sex").getAsString().equals("M") ? PlayerInfo.MAN : PlayerInfo.WOMAN;
PlayerInfo playerInfo = new PlayerInfo(playerId, gender, firstName + " " + name, team);
PlayerInfo playerInfo = new PlayerInfo(playerId, gender, firstName + " " + name, photoUrl, team);
players.add(playerInfo);
}
adapter.notifyDataSetChanged();
......
......@@ -7,17 +7,17 @@ public class PlayerInfo implements Serializable {
public static final int MAN = 1;
public static final int WOMAN = 2;
private static final String rootPhotoUrl = "https://dl.dropboxusercontent.com/u/20851137/photos/";
private int id;
private int gender;
private String name;
private String photoUrl;
private TeamInfo team;
public PlayerInfo(int id, int gender, String name, TeamInfo team) {
public PlayerInfo(int id, int gender, String name, String photoUrl, TeamInfo team) {
this.id = id;
this.gender = gender;
this.name = name;
this.photoUrl = photoUrl;
this.team = team;
}
......@@ -46,6 +46,10 @@ public class PlayerInfo implements Serializable {
}
public String getPhotoUrl() {
return rootPhotoUrl + id + ".jpg";
return photoUrl;
}
public void setPhotoUrl(String photoUrl) {
this.photoUrl = photoUrl;
}
}
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