Commit ddc53b7e authored by rakam's avatar rakam

UI switchSide/switchService

parent 77526980
......@@ -149,7 +149,7 @@ public abstract class MatchActivity extends Activity {
@Override
public void onClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(MatchActivity.this);
String[] options = {"Abandon"};
String[] options = {"Abandon", "Inverser le côté des joueurs", "Inverser les serveurs"};
builder.setItems(options, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
......@@ -176,13 +176,13 @@ public abstract class MatchActivity extends Activity {
setPlayerALeft();
else
setPlayerARight();
updateScore(new Point(initScore, null));
updateScore(new Point(initScore, null), true);
fadeIn(null);
backButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
updateUI(automate.back());
updateUI(automate.back(), true);
}
});
}
......@@ -251,13 +251,23 @@ public abstract class MatchActivity extends Activity {
builder.setCancelable(true);
builder.show();
break;
case 1: {
Point p = automate.switchSide();
updateUI(p, false);
break;
}
case 2: {
Point p = automate.switchService();
updateUI(p, false);
break;
}
default:
break;
}
}
protected void updateUI(final Point point) {
protected void updateUI(final Point point, final boolean sync) {
fsfButton.setSelected(false);
Score score = point.getScore();
if (score.isSideLeftA() != isPlayerALeft && score.getVainqueur() == -1) {
......@@ -267,7 +277,7 @@ public abstract class MatchActivity extends Activity {
.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
updateScoreAndSide(point);
updateScoreAndSide(point, sync);
}
})
.show();
......@@ -278,19 +288,19 @@ public abstract class MatchActivity extends Activity {
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
updateScore(automate.back());
updateScore(automate.back(), sync);
}
});
builder.setPositiveButton("Confirmer", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
updateScore(point);
updateScore(point, sync);
}
});
builder.setCancelable(false);
builder.show();
} else {
updateScore(point);
updateScore(point, sync);
}
}
......@@ -299,7 +309,7 @@ public abstract class MatchActivity extends Activity {
*
* @param point
*/
private void updateScore(Point point) {
private void updateScore(Point point, boolean sync) {
Score score = point.getScore();
if (score.getPreviousSet() != null) {
matchScoreView.setScore(score.getPreviousSet().getSetA(), score.getPreviousSet().getSetB(),
......@@ -343,7 +353,8 @@ public abstract class MatchActivity extends Activity {
matchScoreView.setScore(score.getGamesA(), score.getGamesB(), score.getNumSet(), score.getScoreA(), score.getScoreB());
}
syncManager.addPoint(point);
if (sync)
syncManager.addPoint(point);
}
/**
......@@ -351,7 +362,7 @@ public abstract class MatchActivity extends Activity {
*
* @param point
*/
private void updateScoreAndSide(final Point point) {
private void updateScoreAndSide(final Point point, final boolean sync) {
fadeOut(new Runnable() {
@Override
public void run() {
......@@ -361,7 +372,7 @@ public abstract class MatchActivity extends Activity {
} else {
setPlayerARight();
}
updateScore(point);
updateScore(point, sync);
fadeIn(null);
}
......@@ -406,62 +417,62 @@ public abstract class MatchActivity extends Activity {
leftPointButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.FE, fsfButton.isSelected(), leftPlayer)));
updateUI(automate.point(new Stats(Stats.Type.FE, fsfButton.isSelected(), leftPlayer)), true);
}
});
leftAceButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.ACE, fsfButton.isSelected(), leftPlayer)));
updateUI(automate.point(new Stats(Stats.Type.ACE, fsfButton.isSelected(), leftPlayer)), true);
}
});
leftWinnerServeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.WS, fsfButton.isSelected(), leftPlayer)));
updateUI(automate.point(new Stats(Stats.Type.WS, fsfButton.isSelected(), leftPlayer)), true);
}
});
leftWinnerPointButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.WP, fsfButton.isSelected(), leftPlayer)));
updateUI(automate.point(new Stats(Stats.Type.WP, fsfButton.isSelected(), leftPlayer)), true);
}
});
leftUnforcedErrorButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.UE, fsfButton.isSelected(), leftPlayer)));
updateUI(automate.point(new Stats(Stats.Type.UE, fsfButton.isSelected(), leftPlayer)), true);
}
});
rightPointButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.FE, fsfButton.isSelected(), rightPlayer)));
updateUI(automate.point(new Stats(Stats.Type.FE, fsfButton.isSelected(), rightPlayer)), true);
}
});
rightAceButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.ACE, fsfButton.isSelected(), rightPlayer)));
updateUI(automate.point(new Stats(Stats.Type.ACE, fsfButton.isSelected(), rightPlayer)), true);
}
});
rightWinnerServeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.WS, fsfButton.isSelected(), rightPlayer)));
updateUI(automate.point(new Stats(Stats.Type.WS, fsfButton.isSelected(), rightPlayer)), true);
}
});
rightWinnerPointButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.WP, fsfButton.isSelected(), rightPlayer)));
updateUI(automate.point(new Stats(Stats.Type.WP, fsfButton.isSelected(), rightPlayer)), true);
}
});
rightUnforcedErrorButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateUI(automate.point(new Stats(Stats.Type.UE, fsfButton.isSelected(), rightPlayer)));
updateUI(automate.point(new Stats(Stats.Type.UE, fsfButton.isSelected(), rightPlayer)), true);
}
});
}
......
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