Commit 6556e273 authored by rakam's avatar rakam
Browse files

Updates UPDATE_SCORE url

parent acd04a69
...@@ -19,8 +19,8 @@ public class API_URLS { ...@@ -19,8 +19,8 @@ public class API_URLS {
return BASE_URL + "/matches/" + matchId; return BASE_URL + "/matches/" + matchId;
} }
public static String UPDATE_SCORE(int matchId) { public static String UPDATE_SCORE(int matchId, int pointId) {
return BASE_URL + "/matches/" + matchId + "/score"; return BASE_URL + "/matches/" + matchId + "/score/" + pointId;
} }
} }
...@@ -61,6 +61,14 @@ public class ScoreSyncManager { ...@@ -61,6 +61,14 @@ public class ScoreSyncManager {
addScore(score, true); addScore(score, true);
} }
/**
* Add a score to synchronize
* If canBeBack is set to false, the score will not be considered as a step backward (but as a
* another try to synchronize an old score).
*
* @param score
* @param canBeBack true if the score can be a step backward, false otherwise.
*/
private void addScore(Score score, boolean canBeBack) { private void addScore(Score score, boolean canBeBack) {
if (score.getId() < scoreIdMax && canBeBack) { if (score.getId() < scoreIdMax && canBeBack) {
back(score.getId()); back(score.getId());
...@@ -139,7 +147,6 @@ public class ScoreSyncManager { ...@@ -139,7 +147,6 @@ public class ScoreSyncManager {
*/ */
private void synchronizeScore(final float key, final Score score) { private void synchronizeScore(final float key, final Score score) {
JsonObject param = new JsonObject(); JsonObject param = new JsonObject();
param.addProperty("pointId", score.getId());
param.addProperty("scoreA", score.getScoreA()); param.addProperty("scoreA", score.getScoreA());
param.addProperty("scoreB", score.getScoreB()); param.addProperty("scoreB", score.getScoreB());
param.addProperty("setNum", score.getNumSet() + 1); param.addProperty("setNum", score.getNumSet() + 1);
...@@ -150,7 +157,7 @@ public class ScoreSyncManager { ...@@ -150,7 +157,7 @@ public class ScoreSyncManager {
param.addProperty("server", score.getService()); param.addProperty("server", score.getService());
Ion.with(context) Ion.with(context)
.load("POST", API_URLS.UPDATE_SCORE(idMatch)) .load("POST", API_URLS.UPDATE_SCORE(idMatch, score.getId()))
.setTimeout(TIMEOUT_MS) .setTimeout(TIMEOUT_MS)
.setJsonObjectBody(param) .setJsonObjectBody(param)
.asJsonObject() .asJsonObject()
......
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