Commit 79346b2e authored by rakam's avatar rakam
Browse files

New API (Abandon)

parent 387c0a14
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.istic.masteru.android"> package="fr.istic.masteru.android">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application <application
android:allowBackup="true" android:allowBackup="true"
...@@ -16,30 +16,30 @@ ...@@ -16,30 +16,30 @@
android:screenOrientation="sensorLandscape" android:screenOrientation="sensorLandscape"
android:windowSoftInputMode="stateHidden|adjustResize"> android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
android:name=".activities.MatchSetupActivity" android:name=".activities.MatchSetupActivity"
android:screenOrientation="sensorLandscape" android:screenOrientation="sensorLandscape"
android:theme="@android:style/Theme.Holo.Light.NoActionBar" /> android:theme="@android:style/Theme.Holo.Light.NoActionBar"/>
<activity <activity
android:name=".activities.MainActivity" android:name=".activities.MainActivity"
android:screenOrientation="sensorLandscape" android:screenOrientation="sensorLandscape"
android:theme="@android:style/Theme.Holo.Light.NoActionBar" /> android:theme="@android:style/Theme.Holo.Light.NoActionBar"/>
<activity <activity
android:name=".activities.SingleMatchActivity" android:name=".activities.SingleMatchActivity"
android:screenOrientation="sensorLandscape" android:screenOrientation="sensorLandscape"
android:theme="@android:style/Theme.Holo.Light.NoActionBar" /> android:theme="@android:style/Theme.Holo.Light.NoActionBar"/>
<activity <activity
android:name=".activities.DoubleMatchActivity" android:name=".activities.DoubleMatchActivity"
android:screenOrientation="sensorLandscape" android:screenOrientation="sensorLandscape"
android:theme="@android:style/Theme.Holo.Light.NoActionBar" /> android:theme="@android:style/Theme.Holo.Light.NoActionBar"/>
</application> </application>
......
...@@ -139,7 +139,7 @@ public class MatchSetupActivity extends Activity implements OnMatchSelectedListe ...@@ -139,7 +139,7 @@ public class MatchSetupActivity extends Activity implements OnMatchSelectedListe
} }
Ion.with(this) Ion.with(this)
.load("PUT", API_URLS.START_MATCH(match.getId())) .load("PUT", API_URLS.UPDATE_MATCH(match.getId()))
.setTimeout(1000 * 6) .setTimeout(1000 * 6)
.setJsonObjectBody(param) .setJsonObjectBody(param)
.asJsonObject() .asJsonObject()
......
...@@ -15,7 +15,7 @@ public class API_URLS { ...@@ -15,7 +15,7 @@ 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) { public static String UPDATE_MATCH(int matchId) {
return BASE_URL + "/matches/" + matchId; return BASE_URL + "/matches/" + matchId;
} }
......
...@@ -62,7 +62,7 @@ public class ScoreSyncManager { ...@@ -62,7 +62,7 @@ public class ScoreSyncManager {
syncQueue.put((float) score.getId(), score); syncQueue.put((float) score.getId(), score);
scoreIdMax = score.getId(); scoreIdMax = score.getId();
} else { } else {
WinnerToSync winnerToSync = new WinnerToSync(score.getVainqueur() == 0 ? "A" : "B"); WinnerToSync winnerToSync = new WinnerToSync(score.getVainqueur() == 0 ? "A" : "B", false);
syncQueue.put(score.getId() + 0.2f, winnerToSync); syncQueue.put(score.getId() + 0.2f, winnerToSync);
} }
if (score.getPreviousSet() != null) { if (score.getPreviousSet() != null) {
...@@ -78,7 +78,7 @@ public class ScoreSyncManager { ...@@ -78,7 +78,7 @@ public class ScoreSyncManager {
} }
public void abandon(int winner) { public void abandon(int winner) {
WinnerToSync winnerToSync = new WinnerToSync(winner == 0 ? "A" : "B"); WinnerToSync winnerToSync = new WinnerToSync(winner == 0 ? "A" : "B", true);
syncQueue.put(scoreIdMax + 0.9f, winnerToSync); syncQueue.put(scoreIdMax + 0.9f, winnerToSync);
if (!isSyncing()) { if (!isSyncing()) {
syncNextElement(); syncNextElement();
...@@ -320,12 +320,12 @@ public class ScoreSyncManager { ...@@ -320,12 +320,12 @@ public class ScoreSyncManager {
*/ */
private void syncWinner(final float key, WinnerToSync winnerToSync) { private void syncWinner(final float key, WinnerToSync winnerToSync) {
JsonObject param = new JsonObject(); JsonObject param = new JsonObject();
param.addProperty("idMatch", idMatch); param.addProperty("action", winnerToSync.isAbandon() ? "ABANDON" : "END");
param.addProperty("gagnant", winnerToSync.getWinner()); param.addProperty("winner", winnerToSync.getWinner());
param.addProperty("dateFin", Util.getCurrentDateInMySQLFormat()); param.addProperty("endDate", Util.getCurrentDateInMySQLFormat());
Ion.with(context) Ion.with(context)
.load("POST", API_URLS.MATCH_WINNER) .load("PUT", API_URLS.UPDATE_MATCH(idMatch))
.setTimeout(TIMEOUT_MS) .setTimeout(TIMEOUT_MS)
.setJsonObjectBody(param) .setJsonObjectBody(param)
.asJsonObject() .asJsonObject()
...@@ -416,14 +416,20 @@ public class ScoreSyncManager { ...@@ -416,14 +416,20 @@ public class ScoreSyncManager {
static class WinnerToSync { static class WinnerToSync {
private String winner; private String winner;
private boolean abandon;
WinnerToSync(String winner) { WinnerToSync(String winner, boolean abandon) {
this.winner = winner; this.winner = winner;
this.abandon = abandon;
} }
public String getWinner() { public String getWinner() {
return winner; return winner;
} }
public boolean isAbandon() {
return abandon;
}
} }
static class BackToSync { static class BackToSync {
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" <set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator"> android:interpolator="@android:anim/decelerate_interpolator">
<translate <translate
android:duration="800" android:duration="800"
android:fromXDelta="-20%p" android:fromXDelta="-20%p"
android:fromYDelta="0%" android:fromYDelta="0%"
android:toXDelta="0%" android:toXDelta="0%"
android:toYDelta="0%" /> android:toYDelta="0%"/>
<alpha <alpha
android:duration="@integer/slide_duration" android:duration="@integer/slide_duration"
android:fromAlpha="0" android:fromAlpha="0"
android:toAlpha="1" /> android:toAlpha="1"/>
</set> </set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" <set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator"> android:interpolator="@android:anim/decelerate_interpolator">
<translate <translate
android:duration="800" android:duration="800"
android:fromXDelta="20%p" android:fromXDelta="20%p"
android:fromYDelta="0%" android:fromYDelta="0%"
android:toXDelta="0%" android:toXDelta="0%"
android:toYDelta="0%" /> android:toYDelta="0%"/>
<alpha <alpha
android:duration="@integer/slide_duration" android:duration="@integer/slide_duration"
android:fromAlpha="0" android:fromAlpha="0"
android:toAlpha="1" /> android:toAlpha="1"/>
</set> </set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" <set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"> android:interpolator="@android:anim/accelerate_interpolator">
<translate <translate
android:duration="800" android:duration="800"
android:fromXDelta="0%" android:fromXDelta="0%"
android:fromYDelta="0%" android:fromYDelta="0%"
android:toXDelta="-20%p" android:toXDelta="-20%p"
android:toYDelta="0%" /> android:toYDelta="0%"/>
<alpha <alpha
android:duration="@integer/slide_duration" android:duration="@integer/slide_duration"
android:fromAlpha="1" android:fromAlpha="1"
android:toAlpha="0" /> android:toAlpha="0"/>
</set> </set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" <set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"> android:interpolator="@android:anim/accelerate_interpolator">
<translate <translate
android:duration="800" android:duration="800"
android:fromXDelta="0%" android:fromXDelta="0%"
android:fromYDelta="0%" android:fromYDelta="0%"
android:toXDelta="20%p" android:toXDelta="20%p"
android:toYDelta="0%" /> android:toYDelta="0%"/>
<alpha <alpha
android:duration="@integer/slide_duration" android:duration="@integer/slide_duration"
android:fromAlpha="1" android:fromAlpha="1"
android:toAlpha="0" /> android:toAlpha="0"/>
</set> </set>
\ No newline at end of file
...@@ -3,17 +3,17 @@ ...@@ -3,17 +3,17 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"> <set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500" android:duration="500"
android:propertyName="translationX" android:propertyName="translationX"
android:valueFrom="1000" android:valueFrom="1000"
android:valueTo="0" android:valueTo="0"
android:valueType="floatType" /> android:valueType="floatType"/>
<objectAnimator <objectAnimator
android:duration="500" android:duration="500"
android:propertyName="alpha" android:propertyName="alpha"
android:valueFrom="0.0" android:valueFrom="0.0"
android:valueTo="1.0" android:valueTo="1.0"
android:valueType="floatType" /> android:valueType="floatType"/>
</set> </set>
\ No newline at end of file
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"> <set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500" android:duration="500"
android:propertyName="translationX" android:propertyName="translationX"
android:valueFrom="-1000" android:valueFrom="-1000"
android:valueTo="0" android:valueTo="0"
android:valueType="floatType" /> android:valueType="floatType"/>
<objectAnimator <objectAnimator
android:duration="500" android:duration="500"
android:propertyName="alpha" android:propertyName="alpha"
android:valueFrom="0.0" android:valueFrom="0.0"
android:valueTo="1.0" android:valueTo="1.0"
android:valueType="floatType" /> android:valueType="floatType"/>
</set> </set>
\ No newline at end of file
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"> <set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500" android:duration="500"
android:propertyName="translationX" android:propertyName="translationX"
android:valueFrom="0" android:valueFrom="0"
android:valueTo="-1000" android:valueTo="-1000"
android:valueType="floatType" /> android:valueType="floatType"/>
<objectAnimator <objectAnimator
android:duration="500" android:duration="500"
android:propertyName="alpha" android:propertyName="alpha"
android:valueFrom="1.0" android:valueFrom="1.0"
android:valueTo="0" android:valueTo="0"
android:valueType="floatType" /> android:valueType="floatType"/>
</set> </set>
\ No newline at end of file
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"> <set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500" android:duration="500"
android:propertyName="translationX" android:propertyName="translationX"
android:valueFrom="0" android:valueFrom="0"
android:valueTo="1000" android:valueTo="1000"
android:valueType="floatType" /> android:valueType="floatType"/>
<objectAnimator <objectAnimator
android:duration="500" android:duration="500"
android:propertyName="alpha" android:propertyName="alpha"
android:valueFrom="1.0" android:valueFrom="1.0"
android:valueTo="0" android:valueTo="0"
android:valueType="floatType" /> android:valueType="floatType"/>
</set> </set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/darker_grey" android:state_selected="true" /> <item android:drawable="@color/darker_grey" android:state_selected="true"/>
<item android:drawable="@color/darker_grey" android:state_checked="true" /> <item android:drawable="@color/darker_grey" android:state_checked="true"/>
<item android:drawable="@color/darker_grey" android:state_pressed="true" /> <item android:drawable="@color/darker_grey" android:state_pressed="true"/>
<item android:drawable="@color/dark_grey" /> <item android:drawable="@color/dark_grey"/>
</selector> </selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/grey_button" android:state_selected="true" /> <item android:drawable="@color/grey_button" android:state_selected="true"/>
<item android:drawable="@color/grey_button" android:state_checked="true" /> <item android:drawable="@color/grey_button" android:state_checked="true"/>
<item android:drawable="@color/grey_button" android:state_pressed="true" /> <item android:drawable="@color/grey_button" android:state_pressed="true"/>
<item android:drawable="@color/light_grey_button" /> <item android:drawable="@color/light_grey_button"/>
</selector> </selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/left_button_pressed" android:state_selected="true" /> <item android:drawable="@drawable/left_button_pressed" android:state_selected="true"/>
<item android:drawable="@drawable/left_button_pressed" android:state_checked="true" /> <item android:drawable="@drawable/left_button_pressed" android:state_checked="true"/>
<item android:drawable="@drawable/left_button_pressed" android:state_pressed="true" /> <item android:drawable="@drawable/left_button_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/left_button_pressed" android:state_enabled="false" /> <item android:drawable="@drawable/left_button_pressed" android:state_enabled="false"/>
<item android:drawable="@drawable/left_button_normal" /> <item android:drawable="@drawable/left_button_normal"/>
</selector> </selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/blue_accent" /> <solid android:color="@color/blue_accent"/>
<corners <corners
android:bottomRightRadius="7dp" android:bottomRightRadius="7dp"
android:topRightRadius="7dp" /> android:topRightRadius="7dp"/>
</shape> </shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#bbbbbb" /> <solid android:color="#bbbbbb"/>
<corners <corners
android:bottomRightRadius="7dp" android:bottomRightRadius="7dp"
android:topRightRadius="7dp" /> android:topRightRadius="7dp"/>
</shape> </shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/right_button_pressed" android:state_selected="true" /> <item android:drawable="@drawable/right_button_pressed" android:state_selected="true"/>
<item android:drawable="@drawable/right_button_pressed" android:state_checked="true" /> <item android:drawable="@drawable/right_button_pressed" android:state_checked="true"/>
<item android:drawable="@drawable/right_button_pressed" android:state_pressed="true" /> <item android:drawable="@drawable/right_button_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/right_button_pressed" android:state_enabled="false" /> <item android:drawable="@drawable/right_button_pressed" android:state_enabled="false"/>
<item android:drawable="@drawable/right_button_normal" /> <item android:drawable="@drawable/right_button_normal"/>
</selector> </selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/blue_accent" /> <solid android:color="@color/blue_accent"/>
<corners <corners
android:bottomLeftRadius="7dp" android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp" /> android:topLeftRadius="7dp"/>
</shape> </shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#bbbbbb" /> <solid android:color="#bbbbbb"/>
<corners <corners
android:bottomLeftRadius="7dp" android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp" /> android:topLeftRadius="7dp"/>
</shape> </shape>
\ No newline at end of file
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