Commit 22565ea0 authored by rakam's avatar rakam
Browse files

New API (StartMatch)

parent 9c8ed921
...@@ -124,29 +124,29 @@ public class MatchSetupActivity extends Activity implements OnMatchSelectedListe ...@@ -124,29 +124,29 @@ public class MatchSetupActivity extends Activity implements OnMatchSelectedListe
private void startMatch(final ProgressDialog dialogToClose) { private void startMatch(final ProgressDialog dialogToClose) {
final JsonObject param = new JsonObject(); final JsonObject param = new JsonObject();
param.addProperty("idMatch", match.getId()); param.addProperty("action", "START");
param.addProperty("idCourt", idCourt); param.addProperty("court", idCourt);
param.addProperty("startDate", Util.getCurrentDateInMySQLFormat()); param.addProperty("startDate", Util.getCurrentDateInMySQLFormat());
param.addProperty("service", firstServiceCountryCode.equals(match.getTeamA()) ? 0 : 1); param.addProperty("service", firstServiceCountryCode.equals(match.getTeamA()) ? 0 : 1);
param.addProperty("idJoueurA_Eq1", playerA1.getId()); param.addProperty("playerAEq1Id", playerA1.getId());
param.addProperty("idJoueurA_Eq2", playerB1.getId()); param.addProperty("playerAEq2Id", playerB1.getId());
if (refereeingType == Constants.SIMPLE) { if (refereeingType == Constants.SIMPLE) {
param.addProperty("idJoueurB_Eq1", 0); param.addProperty("playerBEq1Id", 0);
param.addProperty("idJoueurB_Eq2", 0); param.addProperty("playerBEq2Id", 0);
} else { } else {
param.addProperty("idJoueurB_Eq1", playerA2.getId()); param.addProperty("playerBEq1Id", playerA2.getId());
param.addProperty("idJoueurB_Eq2", playerB2.getId()); param.addProperty("playerBEq2Id", playerB2.getId());
} }
Ion.with(this) Ion.with(this)
.load("POST", API_URLS.START_MATCH) .load("PUT", API_URLS.START_MATCH(match.getId()))
.setTimeout(1000 * 10) .setTimeout(1000 * 6)
.setJsonObjectBody(param) .setJsonObjectBody(param)
.asJsonObject() .asJsonObject()
.setCallback(new FutureCallback<JsonObject>() { .setCallback(new FutureCallback<JsonObject>() {
@Override @Override
public void onCompleted(Exception e, JsonObject result) { public void onCompleted(Exception e, JsonObject result) {
if (e != null || result == null || result.get("code").getAsInt() != 0) { if (e != null || result != null && result.get("code").getAsInt() != 0) {
startMatch(dialogToClose); startMatch(dialogToClose);
} else { } else {
dialogToClose.cancel(); dialogToClose.cancel();
......
...@@ -7,7 +7,6 @@ public class API_URLS { ...@@ -7,7 +7,6 @@ public class API_URLS {
public static final String SCORE_UPDATE = BASE_URL + "/score/update"; public static final String SCORE_UPDATE = BASE_URL + "/score/update";
public static final String SET_SCORE_UPDATE = BASE_URL + "/score/majSet"; public static final String SET_SCORE_UPDATE = BASE_URL + "/score/majSet";
public static final String SCORE_BACK = BASE_URL + "/score/supprPoint"; public static final String SCORE_BACK = BASE_URL + "/score/supprPoint";
public static final String START_MATCH = BASE_URL + "/match/debut";
public static final String MATCH_WINNER = BASE_URL + "/match/finMatch"; public static final String MATCH_WINNER = BASE_URL + "/match/finMatch";
public static final String MATCHS = BASE_URL + "/matches"; public static final String MATCHS = BASE_URL + "/matches";
public static final String INFO_MATCH = BASE_URL + "/match/info/"; // + idMatch public static final String INFO_MATCH = BASE_URL + "/match/info/"; // + idMatch
...@@ -16,4 +15,8 @@ public class API_URLS { ...@@ -16,4 +15,8 @@ public class API_URLS {
return BASE_URL + "/teams/" + teamId + "/players?gender=" + (gender == null ? "X" : gender); return BASE_URL + "/teams/" + teamId + "/players?gender=" + (gender == null ? "X" : gender);
} }
public static String START_MATCH(int matchId) {
return BASE_URL + "/matches/" + matchId;
}
} }
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