Commit 027f28d4 authored by rakam's avatar rakam

New stats (FE, UE, WS, WP)

parent bb9f2326
......@@ -51,8 +51,6 @@ public class HomeActivity extends Activity {
@Override
protected void onPostExecute(final Automate automate) {
super.onPostExecute(automate);
int a = 98;
int b = 98;
//todo New API
// Ion.with(HomeActivity.this)
// .load("GET", API_URLS.INFO_MATCH + automate.getIdMatch())
......
......@@ -70,8 +70,11 @@ public abstract class MatchActivity extends Activity {
protected Button fsfButton;
protected View leftButtons, rightButtons;
protected SecureDelayButton leftPointButton, rightPointButton;
protected SecureDelayButton leftPointButton, rightPointButton; // "Normal" point are considered as Forced Error
protected SecureDelayButton leftAceButton, rightAceButton;
protected SecureDelayButton leftWinnerServeButton, rightWinnerServeButton;
protected SecureDelayButton leftWinnerPointButton, rightWinnerPointButton;
protected SecureDelayButton leftUnforcedErrorButton, rightUnforcedErrorButton;
protected List<SecureDelayButton> animatedLeftButtons = new ArrayList<>();
protected List<SecureDelayButton> animatedRightButtons = new ArrayList<>();
......@@ -114,13 +117,25 @@ public abstract class MatchActivity extends Activity {
leftAceButton = (SecureDelayButton) findViewById(R.id.aceLeft);
leftPointButton = (SecureDelayButton) findViewById(R.id.pointLeft);
leftWinnerServeButton = (SecureDelayButton) findViewById(R.id.winnerServeLeft);
leftWinnerPointButton = (SecureDelayButton) findViewById(R.id.winnerPointLeft);
leftUnforcedErrorButton = (SecureDelayButton) findViewById(R.id.unforcedErrorLeft);
animatedLeftButtons.add(leftAceButton);
animatedLeftButtons.add(leftPointButton);
animatedLeftButtons.add(leftWinnerServeButton);
animatedLeftButtons.add(leftWinnerPointButton);
animatedLeftButtons.add(leftUnforcedErrorButton);
rightAceButton = (SecureDelayButton) findViewById(R.id.aceRight);
rightPointButton = (SecureDelayButton) findViewById(R.id.pointRight);
rightWinnerServeButton = (SecureDelayButton) findViewById(R.id.winnerServeRight);
rightWinnerPointButton = (SecureDelayButton) findViewById(R.id.winnerPointRight);
rightUnforcedErrorButton = (SecureDelayButton) findViewById(R.id.unforcedErrorRight);
animatedRightButtons.add(rightAceButton);
animatedRightButtons.add(rightPointButton);
animatedRightButtons.add(rightWinnerServeButton);
animatedRightButtons.add(rightWinnerPointButton);
animatedRightButtons.add(rightUnforcedErrorButton);
fsfButton.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -391,7 +406,7 @@ public abstract class MatchActivity extends Activity {
leftPointButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.NONE, fsfButton.isSelected(), leftPlayer)));
updateUI(automate.point(new Stats(Stats.Type.FE, fsfButton.isSelected(), leftPlayer)));
}
});
leftAceButton.setOnClickListener(new View.OnClickListener() {
......@@ -400,11 +415,29 @@ public abstract class MatchActivity extends Activity {
updateUI(automate.point(new Stats(Stats.Type.ACE, fsfButton.isSelected(), leftPlayer)));
}
});
leftWinnerServeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.WS, fsfButton.isSelected(), leftPlayer)));
}
});
leftWinnerPointButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.WP, fsfButton.isSelected(), leftPlayer)));
}
});
leftUnforcedErrorButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.UE, fsfButton.isSelected(), leftPlayer)));
}
});
rightPointButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.NONE, fsfButton.isSelected(), rightPlayer)));
updateUI(automate.point(new Stats(Stats.Type.FE, fsfButton.isSelected(), rightPlayer)));
}
});
rightAceButton.setOnClickListener(new View.OnClickListener() {
......@@ -413,6 +446,24 @@ public abstract class MatchActivity extends Activity {
updateUI(automate.point(new Stats(Stats.Type.ACE, fsfButton.isSelected(), rightPlayer)));
}
});
rightWinnerServeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.WS, fsfButton.isSelected(), rightPlayer)));
}
});
rightWinnerPointButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.WP, fsfButton.isSelected(), rightPlayer)));
}
});
rightUnforcedErrorButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.UE, fsfButton.isSelected(), rightPlayer)));
}
});
}
@Override
......
......@@ -9,6 +9,8 @@ import android.os.Bundle;
import android.view.WindowManager;
import com.google.gson.JsonObject;
import com.koushikdutta.async.future.FutureCallback;
import com.koushikdutta.ion.Ion;
import java.util.ArrayList;
import java.util.List;
......@@ -29,6 +31,7 @@ import fr.istic.masteru.android.listeners.OnRefereeingTypeChangeListener;
import fr.istic.masteru.android.listeners.OnSelectedCourtChangeListener;
import fr.istic.masteru.android.model.Match;
import fr.istic.masteru.android.model.PlayerInfo;
import fr.istic.masteru.android.utils.API_URLS;
import fr.istic.masteru.android.utils.Constants;
import fr.istic.masteru.android.utils.PrefsUtils;
import fr.istic.masteru.android.utils.Utils;
......@@ -137,64 +140,42 @@ public class MatchSetupActivity extends Activity implements OnMatchSelectedListe
param.addProperty("playerBEq2Id", playerB2.getId());
}
// Ion.with(this)
// .load("PUT", API_URLS.UPDATE_MATCH(match.getId()))
// .setTimeout(1000 * 6)
// .setJsonObjectBody(param)
// .asJsonObject()
// .setCallback(new FutureCallback<JsonObject>() {
// @Override
// public void onCompleted(Exception e, JsonObject result) {
// if (e != null || result != null && result.get("code").getAsInt() != 0) {
// startMatch(dialogToClose);
// } else {
// dialogToClose.cancel();
// if (refereeingType == Constants.SIMPLE) {
// Intent matchActivityIntent = new Intent(MatchSetupActivity.this, SingleMatchActivity.class);
// matchActivityIntent.putExtra(MatchActivity.MATCH, match);
// matchActivityIntent.putExtra(MatchActivity.SIDE_LEFT_A, side == Constants.A_IS_LEFT);
// matchActivityIntent.putExtra(MatchActivity.SERVICE, firstServiceCountryCode.equals(match.getTeamA()) ? 0 : 1);
// matchActivityIntent.putExtra(MatchActivity.PLAYER_A1, playerA1);
// matchActivityIntent.putExtra(MatchActivity.PLAYER_B1, playerB1);
// startActivity(matchActivityIntent);
// } else {
// Intent matchActivityIntent = new Intent(MatchSetupActivity.this, DoubleMatchActivity.class);
// matchActivityIntent.putExtra(MatchActivity.MATCH, match);
// matchActivityIntent.putExtra(MatchActivity.SIDE_LEFT_A, side == Constants.A_IS_LEFT);
// matchActivityIntent.putExtra(MatchActivity.SERVICE, firstServiceCountryCode.equals(match.getTeamA()) ? 0 : 1);
// matchActivityIntent.putExtra(DoubleMatchActivity.REFEREEING_TYPE, refereeingType);
// matchActivityIntent.putExtra(MatchActivity.PLAYER_A1, playerA1);
// matchActivityIntent.putExtra(MatchActivity.PLAYER_A2, playerA2);
// matchActivityIntent.putExtra(MatchActivity.PLAYER_B1, playerB1);
// matchActivityIntent.putExtra(MatchActivity.PLAYER_B2, playerB2);
// startActivity(matchActivityIntent);
// }
// finish();
// }
// }
// });
dialogToClose.cancel();
if (refereeingType == Constants.SIMPLE) {
Intent matchActivityIntent = new Intent(MatchSetupActivity.this, SingleMatchActivity.class);
matchActivityIntent.putExtra(MatchActivity.MATCH, match);
matchActivityIntent.putExtra(MatchActivity.SIDE_LEFT_A, side == Constants.A_IS_LEFT);
matchActivityIntent.putExtra(MatchActivity.SERVICE, firstServiceCountryCode.equals(match.getTeamA()) ? 0 : 1);
matchActivityIntent.putExtra(MatchActivity.PLAYER_A1, playerA1);
matchActivityIntent.putExtra(MatchActivity.PLAYER_B1, playerB1);
startActivity(matchActivityIntent);
} else {
Intent matchActivityIntent = new Intent(MatchSetupActivity.this, DoubleMatchActivity.class);
matchActivityIntent.putExtra(MatchActivity.MATCH, match);
matchActivityIntent.putExtra(MatchActivity.SIDE_LEFT_A, side == Constants.A_IS_LEFT);
matchActivityIntent.putExtra(MatchActivity.SERVICE, firstServiceCountryCode.equals(match.getTeamA()) ? 0 : 1);
matchActivityIntent.putExtra(DoubleMatchActivity.REFEREEING_TYPE, refereeingType);
matchActivityIntent.putExtra(MatchActivity.PLAYER_A1, playerA1);
matchActivityIntent.putExtra(MatchActivity.PLAYER_A2, playerA2);
matchActivityIntent.putExtra(MatchActivity.PLAYER_B1, playerB1);
matchActivityIntent.putExtra(MatchActivity.PLAYER_B2, playerB2);
startActivity(matchActivityIntent);
}
finish();
Ion.with(this)
.load("PUT", API_URLS.UPDATE_MATCH(match.getId()))
.setTimeout(1000 * 6)
.setJsonObjectBody(param)
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
if (e != null || result != null && result.get("code").getAsInt() != 0) {
startMatch(dialogToClose);
} else {
dialogToClose.cancel();
if (refereeingType == Constants.SIMPLE) {
Intent matchActivityIntent = new Intent(MatchSetupActivity.this, SingleMatchActivity.class);
matchActivityIntent.putExtra(MatchActivity.MATCH, match);
matchActivityIntent.putExtra(MatchActivity.SIDE_LEFT_A, side == Constants.A_IS_LEFT);
matchActivityIntent.putExtra(MatchActivity.SERVICE, firstServiceCountryCode.equals(match.getTeamA()) ? 0 : 1);
matchActivityIntent.putExtra(MatchActivity.PLAYER_A1, playerA1);
matchActivityIntent.putExtra(MatchActivity.PLAYER_B1, playerB1);
startActivity(matchActivityIntent);
} else {
Intent matchActivityIntent = new Intent(MatchSetupActivity.this, DoubleMatchActivity.class);
matchActivityIntent.putExtra(MatchActivity.MATCH, match);
matchActivityIntent.putExtra(MatchActivity.SIDE_LEFT_A, side == Constants.A_IS_LEFT);
matchActivityIntent.putExtra(MatchActivity.SERVICE, firstServiceCountryCode.equals(match.getTeamA()) ? 0 : 1);
matchActivityIntent.putExtra(DoubleMatchActivity.REFEREEING_TYPE, refereeingType);
matchActivityIntent.putExtra(MatchActivity.PLAYER_A1, playerA1);
matchActivityIntent.putExtra(MatchActivity.PLAYER_A2, playerA2);
matchActivityIntent.putExtra(MatchActivity.PLAYER_B1, playerB1);
matchActivityIntent.putExtra(MatchActivity.PLAYER_B2, playerB2);
startActivity(matchActivityIntent);
}
finish();
}
}
});
}
@Override
......
......@@ -2,7 +2,15 @@ package fr.istic.masteru.android.automate;
public class Stats {
public static enum Type {NONE, ACE, DF}
public static enum Type {
NONE,
ACE,
WS, // Winner Serve
WP, // Winner point
DF, // Double Fault
UE, // Unforcer Error
FE, // Forced Error
}
private Type type;
private boolean fsf;
......
......@@ -230,6 +230,7 @@
style="@style/StatsButton"/>
<fr.istic.masteru.android.views.SecureDelayButton
android:id="@+id/winnerServeLeft"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="30"
......@@ -245,6 +246,7 @@
android:layout_weight="30">
<fr.istic.masteru.android.views.SecureDelayButton
android:id="@+id/winnerPointLeft"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="30"
......@@ -252,6 +254,7 @@
style="@style/StatsButton"/>
<fr.istic.masteru.android.views.SecureDelayButton
android:id="@+id/unforcedErrorLeft"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="30"
......@@ -263,9 +266,10 @@
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="30"
android:text="@string/FAUTE_PROVOQUEE_ADV"
android:text=""
style="@style/StatsButton"
android:textSize="20sp"/>
android:textSize="20sp"
android:visibility="invisible"/>
</LinearLayout>
</LinearLayout>
......@@ -289,6 +293,7 @@
android:layout_weight="30">
<fr.istic.masteru.android.views.SecureDelayButton
android:id="@+id/winnerServeRight"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="30"
......@@ -323,11 +328,13 @@
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="30"
android:text="@string/FAUTE_PROVOQUEE_ADV"
android:text=""
style="@style/StatsButton"
android:textSize="20sp"/>
android:textSize="20sp"
android:visibility="invisible"/>
<fr.istic.masteru.android.views.SecureDelayButton
android:id="@+id/unforcedErrorRight"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="30"
......@@ -336,6 +343,7 @@
android:textSize="20sp"/>
<fr.istic.masteru.android.views.SecureDelayButton
android:id="@+id/winnerPointRight"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="30"
......
......@@ -5,5 +5,5 @@
<dimen name="matchscore_player_names_padding_right">5dp</dimen>
<dimen name="matchscore_line_margin">2dp</dimen>
<dimen name="matchscore_score_padding_rightleft">6dp</dimen>
<dimen name="stats_button_margin">2dp</dimen>
<dimen name="stats_button_margin">4dp</dimen>
</resources>
......@@ -33,9 +33,9 @@
<string name="test">Faute <sup>1er</sup> Service</string>
<string name="ace">ACE</string>
<string name="POINT">POINT</string>
<string name="FIRST_SERVE_FAULT">FIRST SERVE FAULT</string>
<string name="FIRST_SERVE_FAULT">FAUTE AU PREMIER SERVICE</string>
<string name="FAUTE_PROVOQUEE_ADV">FAUTE PROVOQUEE\nDE L\'ADVERSAIRE</string>
<string name="FAUTE_DIRECT_ADV">FAUTE\nDIRECTE \nDE L\'ADVERSAIRE</string>
<string name="FAUTE_DIRECT_ADV">POINT SUR FAUTE\nDIRECTE DE L\'ADVERSAIRE</string>
<string name="COUP_GAGNANT">COUP GAGNANT</string>
<string name="SERVICE_GAGNANT">SERVICE GAGNANT</string>
......
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