Commit 84e911c3 authored by rakam's avatar rakam

Resume match with new api

parent 22a78ddd
......@@ -6,6 +6,7 @@ import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.google.gson.JsonObject;
import com.koushikdutta.async.future.FutureCallback;
......@@ -23,6 +24,8 @@ import fr.istic.masteru.android.utils.Utils;
public class HomeActivity extends Activity {
private Button resumeMatchButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -34,7 +37,8 @@ public class HomeActivity extends Activity {
startActivity(intent);
}
});
findViewById(R.id.resumeMatchButton).setEnabled(false);
resumeMatchButton = (Button) findViewById(R.id.resumeMatchButton);
resumeMatchButton.setEnabled(false);
checkForSavedAutomate();
final ProgressDialog dialog = new ProgressDialog(this);
dialog.setMessage("Authentification...");
......@@ -70,18 +74,26 @@ public class HomeActivity extends Activity {
return;
}
JsonObject jsonMatch = result.getAsJsonObject("match");
String status = jsonMatch.get("Statut").getAsString();
if (!status.equals("PROGRESS"))
return;
String isoA = jsonMatch.get("Team_A").getAsString();
String isoB = jsonMatch.get("Team_B").getAsString();
// todo get flag and full team names
TeamInfo teamA = new TeamInfo(isoA, isoA, null);
TeamInfo teamB = new TeamInfo(isoB, isoB, null);
String teamNameA = jsonMatch.get("NameTeam_A").getAsString();
String teamNameB = jsonMatch.get("NameTeam_B").getAsString();
String flagA = jsonMatch.get("UrlTeam_A").getAsString();
String flagB = jsonMatch.get("UrlTeam_B").getAsString();
TeamInfo teamA = new TeamInfo(isoA, teamNameA, flagA);
TeamInfo teamB = new TeamInfo(isoB, teamNameB, flagB);
final String category = jsonMatch.getAsJsonPrimitive("Category").getAsString();
String tableau = jsonMatch.getAsJsonPrimitive("Tableau").getAsString();
final PlayerInfo playerA1, playerA2, playerB1, playerB2;
String nameA = jsonMatch.getAsJsonPrimitive("Name_CompletA").getAsString();
String nameB = jsonMatch.getAsJsonPrimitive("Name_CompletB").getAsString();
String nameA = jsonMatch.getAsJsonPrimitive("NamePlayers_A").getAsString();
String nameB = jsonMatch.getAsJsonPrimitive("NamePlayers_B").getAsString();
if (category.contains("D")) {
int idPlayerA1 = jsonMatch.getAsJsonPrimitive("IdPlayerA_1").getAsInt();
int idPlayerA2 = jsonMatch.getAsJsonPrimitive("IdPlayerA_2").getAsInt();
......@@ -96,15 +108,15 @@ public class HomeActivity extends Activity {
playerB1 = new PlayerInfo(idPlayerB1, PlayerInfo.MAN, nameB1, teamB.getISO());
playerB2 = new PlayerInfo(idPlayerB2, PlayerInfo.MAN, nameB2, teamB.getISO());
} else {
int idPlayerA = jsonMatch.getAsJsonPrimitive("IdPlayerA").getAsInt();
int idPlayerB = jsonMatch.getAsJsonPrimitive("IdPlayerB").getAsInt();
int idPlayerA = jsonMatch.getAsJsonPrimitive("IdPlayerA_1").getAsInt();
int idPlayerB = jsonMatch.getAsJsonPrimitive("IdPlayerB_1").getAsInt();
playerA1 = new PlayerInfo(idPlayerA, PlayerInfo.MAN, nameA, teamA.getISO());
playerB1 = new PlayerInfo(idPlayerB, PlayerInfo.MAN, nameB, teamB.getISO());
playerA2 = null;
playerB2 = null;
}
final MatchInfo match = new MatchInfo(automate.getIdMatch(), teamA, teamB, category, tableau);
findViewById(R.id.resumeMatchButton).setOnClickListener(new View.OnClickListener() {
resumeMatchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (category.contains("D")) {
......@@ -126,7 +138,8 @@ public class HomeActivity extends Activity {
}
}
});
findViewById(R.id.resumeMatchButton).setEnabled(true);
resumeMatchButton.setText("Reprendre le match " + teamNameA + " vs " + teamNameB + " (" + Utils.getCategorieName(category) + ")");
resumeMatchButton.setEnabled(true);
}
});
}
......
......@@ -181,7 +181,7 @@
android:padding="22dp"
android:layout_margin="6dp"
android:text="@string/FIRST_SERVE_FAULT"
android:textColor="#444"
android:textColor="@color/ac_button_color"
android:textStyle="bold"/>
<View
......@@ -380,7 +380,7 @@
android:background="@drawable/dark_button"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text=Back to previous point"
android:text=Retour au point précédent"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"/>
......
......@@ -8,7 +8,7 @@
<style name="StatsButton">
<item name="android:layout_margin">@dimen/stats_button_margin</item>
<item name="android:background">@drawable/ac_button_background</item>
<item name="android:textColor">#444</item>
<item name="android:textColor">@color/ac_button_color</item>
<item name="android:textSize">30sp</item>
<item name="android:textStyle">bold</item>
</style>
......
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