Commit 16966801 authored by rakam's avatar rakam
Browse files

New API (SelectMatchFragment)

parent 672d6b67
......@@ -2,7 +2,6 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Resume.iml" filepath="$PROJECT_DIR$/Resume.iml" />
<module fileurl="file://$PROJECT_DIR$/android.iml" filepath="$PROJECT_DIR$/android.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
......
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
......@@ -7,7 +7,7 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<output url="file://$MODULE_DIR$/build/classes/main" />
<output-test url="file://$MODULE_DIR$/build/classes/test" />
<exclude-output />
......
......@@ -9,6 +9,7 @@
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
......@@ -24,6 +25,7 @@
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
......@@ -84,10 +86,10 @@
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" name="ion-1.4.1" level="project" />
<orderEntry type="library" exported="" name="androidasync-1.4.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
<orderEntry type="library" exported="" name="ion-2.0.5" level="project" />
<orderEntry type="library" exported="" name="gson-2.3" level="project" />
<orderEntry type="library" exported="" name="androidasync-2.0.5" level="project" />
</component>
</module>
......@@ -21,6 +21,6 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.koushikdutta.ion:ion:1.+'
compile 'com.koushikdutta.ion:ion:2.+'
compile "com.android.support:support-v4:21.0.+"
}
......@@ -31,7 +31,7 @@ public class HomeActivity extends Activity {
}
});
findViewById(R.id.resumeMatchButton).setEnabled(false);
checkForSavedAutomate();
//checkForSavedAutomate();
}
private void checkForSavedAutomate() {
......
......@@ -65,7 +65,7 @@ public abstract class MatchActivity extends Activity {
serviceRight = (ImageView) findViewById(R.id.serviceRight);
gameTime = (TextView) findViewById(R.id.gameTime);
backButton = (Button) findViewById(R.id.back);
((TextView) findViewById(R.id.categorie)).setText(Util.getCategorieName(match.getCategorie()));
((TextView) findViewById(R.id.categorie)).setText(Util.getCategorieName(match.getCategory()));
findViewById(R.id.optionsButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
......
......@@ -127,7 +127,7 @@ public class MatchSetupActivity extends Activity implements OnMatchSelectedListe
param.addProperty("idMatch", match.getId());
param.addProperty("idCourt", idCourt);
param.addProperty("startDate", Util.getCurrentDateInMySQLFormat());
param.addProperty("service", firstServiceCountryCode.equals(match.getPaysA()) ? 0 : 1);
param.addProperty("service", firstServiceCountryCode.equals(match.getTeamA()) ? 0 : 1);
param.addProperty("idJoueurA_Eq1", playerA1.getId());
param.addProperty("idJoueurA_Eq2", playerB1.getId());
if (refereeingType == Constants.SIMPLE) {
......@@ -154,7 +154,7 @@ public class MatchSetupActivity extends Activity implements OnMatchSelectedListe
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.getPaysA()) ? 0 : 1);
matchActivityIntent.putExtra(MatchActivity.SERVICE, firstServiceCountryCode.equals(match.getTeamA()) ? 0 : 1);
matchActivityIntent.putExtra(MatchActivity.PLAYER_A1, playerA1);
matchActivityIntent.putExtra(MatchActivity.PLAYER_B1, playerB1);
startActivity(matchActivityIntent);
......@@ -162,7 +162,7 @@ public class MatchSetupActivity extends Activity implements OnMatchSelectedListe
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.getPaysA()) ? 0 : 1);
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);
......@@ -181,10 +181,10 @@ public class MatchSetupActivity extends Activity implements OnMatchSelectedListe
public void onMatchSelected(Match match) {
this.match = match;
resultFragment.setMatchInfos(match);
if (match != null && match.getCategorie().contains("D")
if (match != null && match.getCategory().contains("D")
&& !flow.get(1).equals(RefereeingTypeFragment.class.getName())) {
flow.add(1, RefereeingTypeFragment.class.getName());
} else if (match != null && !match.getCategorie().contains("D") &&
} else if (match != null && !match.getCategory().contains("D") &&
flow.get(1).equals(RefereeingTypeFragment.class.getName())) {
flow.remove(1);
}
......
......@@ -45,12 +45,12 @@ public class SingleMatchActivity extends MatchActivity {
super.onCreate(savedInstanceState);
if (match.getCategorie().equals("SH")) {
if (match.getCategory().equals("SH")) {
int num = match.getId() % 7;
((TextView) findViewById(R.id.categorie)).setText(Util.getCategorieName(match.getCategorie()) + " n°" + num);
} else if (match.getCategorie().equals("SF")) {
((TextView) findViewById(R.id.categorie)).setText(Util.getCategorieName(match.getCategory()) + " n°" + num);
} else if (match.getCategory().equals("SF")) {
int num = (match.getId() - 2) % 7;
((TextView) findViewById(R.id.categorie)).setText(Util.getCategorieName(match.getCategorie()) + " n°" + num);
((TextView) findViewById(R.id.categorie)).setText(Util.getCategorieName(match.getCategory()) + " n°" + num);
}
matchScoreView.setPlayersNames(playerInfoA.getName(), playerInfoB.getName());
}
......
......@@ -64,18 +64,18 @@ public class MatchAdapter extends BaseAdapter {
}
final Match match = matches.get(position);
ViewHolder viewHolder = (ViewHolder) itemView.getTag();
viewHolder.drapeauA.setImageResource(Util.getCountryFlag(match.getPaysA()));
viewHolder.drapeauB.setImageResource(Util.getCountryFlag(match.getPaysB()));
viewHolder.paysA.setText(Util.getCountryName(match.getPaysA()));
viewHolder.paysB.setText(Util.getCountryName(match.getPaysB()));
if (match.getCategorie().equals("SH")) {
viewHolder.drapeauA.setImageResource(Util.getCountryFlag(match.getTeamA()));
viewHolder.drapeauB.setImageResource(Util.getCountryFlag(match.getTeamB()));
viewHolder.paysA.setText(Util.getCountryName(match.getTeamA()));
viewHolder.paysB.setText(Util.getCountryName(match.getTeamB()));
if (match.getCategory().equals("SH")) {
int num = match.getId() % 7;
viewHolder.categorie.setText(Util.getCategorieName(match.getCategorie()) + " n°" + num);
} else if (match.getCategorie().equals("SF")) {
viewHolder.categorie.setText(Util.getCategorieName(match.getCategory()) + " n°" + num);
} else if (match.getCategory().equals("SF")) {
int num = (match.getId() - 2) % 7;
viewHolder.categorie.setText(Util.getCategorieName(match.getCategorie()) + " n°" + num);
viewHolder.categorie.setText(Util.getCategorieName(match.getCategory()) + " n°" + num);
} else {
viewHolder.categorie.setText(Util.getCategorieName(match.getCategorie()));
viewHolder.categorie.setText(Util.getCategorieName(match.getCategory()));
}
viewHolder.tableau.setText(Util.getTableauName(match.getTableau()));
final View finalItemView = itemView;
......
......@@ -50,14 +50,14 @@ public class FirstServiceFragment extends SetupFragment {
});
final Button countryAButton = (Button) root.findViewById(R.id.countryA);
final Button countryBButton = (Button) root.findViewById(R.id.countryB);
countryAButton.setText(Util.getCountryName(match.getPaysA()));
countryBButton.setText(Util.getCountryName(match.getPaysB()));
countryAButton.setText(Util.getCountryName(match.getTeamA()));
countryBButton.setText(Util.getCountryName(match.getTeamB()));
countryAButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
countryAButton.setBackgroundColor(Color.RED);
countryBButton.setBackgroundColor(lightGrey);
matchSetupActivity.onFirstServiceChange(match.getPaysA());
matchSetupActivity.onFirstServiceChange(match.getTeamA());
nextButton.setVisibility(View.VISIBLE);
}
});
......@@ -66,7 +66,7 @@ public class FirstServiceFragment extends SetupFragment {
public void onClick(View view) {
countryAButton.setBackgroundColor(lightGrey);
countryBButton.setBackgroundColor(Color.RED);
matchSetupActivity.onFirstServiceChange(match.getPaysB());
matchSetupActivity.onFirstServiceChange(match.getTeamB());
nextButton.setVisibility(View.VISIBLE);
}
});
......
......@@ -55,8 +55,8 @@ public class InitialSideFragment extends SetupFragment {
matchSetupActivity.next();
}
});
countryAButton.setText(Util.getCountryName(match.getPaysA()));
countryBButton.setText(Util.getCountryName(match.getPaysB()));
countryAButton.setText(Util.getCountryName(match.getTeamA()));
countryBButton.setText(Util.getCountryName(match.getTeamB()));
countryAButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
......
......@@ -70,21 +70,21 @@ public class ResultFragment extends Fragment {
countryATV.setText(null);
countryBTV.setText(null);
} else {
if (match.getCategorie().equals("SH")) {
if (match.getCategory().equals("SH")) {
int num = match.getId() % 7;
categorieTV.setText(Util.getCategorieName(match.getCategorie()) + " n°" + num);
} else if (match.getCategorie().equals("SF")) {
categorieTV.setText(Util.getCategorieName(match.getCategory()) + " n°" + num);
} else if (match.getCategory().equals("SF")) {
int num = (match.getId() - 2) % 7;
categorieTV.setText(Util.getCategorieName(match.getCategorie()) + " n°" + num);
categorieTV.setText(Util.getCategorieName(match.getCategory()) + " n°" + num);
} else {
categorieTV.setText(Util.getCategorieName(match.getCategorie()));
categorieTV.setText(Util.getCategorieName(match.getCategory()));
}
categorieTV.setText(Util.getCategorieName(match.getCategorie()));
categorieTV.setText(Util.getCategorieName(match.getCategory()));
tableauTV.setText(Util.getTableauName(match.getTableau()));
flagA.setImageResource(Util.getCountryFlag(match.getPaysA()));
flagB.setImageResource(Util.getCountryFlag(match.getPaysB()));
countryATV.setText(Util.getCountryName(match.getPaysA()));
countryBTV.setText(Util.getCountryName(match.getPaysB()));
flagA.setImageResource(Util.getCountryFlag(match.getTeamA()));
flagB.setImageResource(Util.getCountryFlag(match.getTeamB()));
countryATV.setText(Util.getCountryName(match.getTeamA()));
countryBTV.setText(Util.getCountryName(match.getTeamB()));
}
}
......
......@@ -87,33 +87,36 @@ public class SelectMatchFragment extends SetupFragment implements OnMatchSelecte
final JsonObject param = new JsonObject();
param.addProperty("tableau", tableau);
Ion.with(matchSetupActivity)
.load(API_URLS.MATCHS)
.load("GET", API_URLS.MATCHS + "?round=1/4")
.setTimeout(1000 * 10)
.setJsonObjectBody(param)
.asJsonArray()
.setCallback(new FutureCallback<JsonArray>() {
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonArray result) {
if (e != null) {
public void onCompleted(Exception e, JsonObject result) {
if (e != null || result != null && result.get("code").getAsInt() != 0) {
loadMatches();
return;
}
JsonArray matchesArray = result.getAsJsonArray("matches");
progressBar.setVisibility(View.GONE);
for (int i = 0; i < result.size(); i++) {
JsonObject o = result.get(i).getAsJsonObject();
for (int i = 0; i < matchesArray.size(); i++) {
JsonObject o = matchesArray.get(i).getAsJsonObject();
String status = o.get("Statut").getAsString();
if (!status.equals("SOON")) // Display only the matches which can be played
continue;
int idMatch = o.get("IdMatch").getAsInt();
String countryA = o.get("Nation_A").getAsString();
String countryB = o.get("Nation_B").getAsString();
JsonElement playerAElement = o.get("Nom_Complet_A");
String teamA = o.get("Team_A").getAsString();
String teamB = o.get("Team_B").getAsString();
JsonElement playerAElement = o.get("Name_Complet_A");
String playerA = playerAElement.isJsonNull() ? null : playerAElement.getAsString();
JsonElement playerBElement = o.get("Nom_Complet_B");
JsonElement playerBElement = o.get("Name_Complet_B");
String playerB = playerBElement.isJsonNull() ? null : playerBElement.getAsString();
String categorie = o.get("Categorie").getAsString();
String category = o.get("Category").getAsString();
String tableau = o.get("Tableau").getAsString();
String status = o.get("Statut").getAsString();
JsonElement courtElement = o.get("Court");
int court = courtElement.isJsonNull() ? -1 : courtElement.getAsInt();
matches.add(new Match(idMatch, countryA, countryB, categorie, tableau));
matches.add(new Match(idMatch, teamA, teamB, category, tableau));
}
if (matchAdapter != null)
matchAdapter.notifyDataSetChanged();
......
......@@ -73,8 +73,8 @@ public class SelectPlayersFragment extends SetupFragment {
}
});
((TextView) root.findViewById(R.id.countryA)).setText(Util.getCountryName(match.getPaysA()));
((TextView) root.findViewById(R.id.countryB)).setText(Util.getCountryName(match.getPaysB()));
((TextView) root.findViewById(R.id.countryA)).setText(Util.getCountryName(match.getTeamA()));
((TextView) root.findViewById(R.id.countryB)).setText(Util.getCountryName(match.getTeamB()));
ListView playerAList = (ListView) root.findViewById(R.id.playerAListView);
ListView playerBList = (ListView) root.findViewById(R.id.playerBListView);
......@@ -132,13 +132,11 @@ public class SelectPlayersFragment extends SetupFragment {
private void loadPlayers(final int team) {
final JsonObject param = new JsonObject();
final String countryCode = team == TEAM_A ? match.getPaysA() : match.getPaysB();
param.addProperty("nation", countryCode);
String sexe = match.getCategorie().contains("H") ? "H" : match.getCategorie().contains("F") ? "F" : "M";
param.addProperty("sexe", sexe);
final String countryCode = team == TEAM_A ? match.getTeamA() : match.getTeamB();
String gender = match.getCategory().contains("M") ? "M" : match.getCategory().contains("W") ? "W" : "X";
Ion.with(matchSetupActivity)
.load(API_URLS.PLAYER_LIST)
.load(API_URLS.TEAM_PLAYERS(countryCode, gender))
.setTimeout(1000 * 10)
.setJsonObjectBody(param)
.asJsonArray()
......@@ -171,8 +169,8 @@ public class SelectPlayersFragment extends SetupFragment {
public void setMatch(Match match) {
this.match = match;
isDouble = match.getCategorie().contains("D");
isMixed = match.getCategorie().equals("DM");
isDouble = match.getCategory().contains("D");
isMixed = match.getCategory().equals("DM");
}
@Override
......
......@@ -5,15 +5,15 @@ import java.io.Serializable;
public class Match implements Serializable {
private int id;
private String paysA, paysB;
private String categorie;
private String teamA, teamB;
private String category;
private String tableau;
public Match(int id, String paysA, String paysB, String categorie, String tableau) {
public Match(int id, String teamA, String teamB, String category, String tableau) {
this.id = id;
this.paysA = paysA;
this.paysB = paysB;
this.categorie = categorie;
this.teamA = teamA;
this.teamB = teamB;
this.category = category;
this.tableau = tableau;
}
......@@ -21,28 +21,28 @@ public class Match implements Serializable {
return id;
}
public String getPaysA() {
return paysA;
public String getTeamA() {
return teamA;
}
public void setPaysA(String paysA) {
this.paysA = paysA;
public void setTeamA(String teamA) {
this.teamA = teamA;
}
public String getPaysB() {
return paysB;
public String getTeamB() {
return teamB;
}
public void setPaysB(String paysB) {
this.paysB = paysB;
public void setTeamB(String teamB) {
this.teamB = teamB;
}
public String getCategorie() {
return categorie;
public String getCategory() {
return category;
}
public void setCategorie(String categorie) {
this.categorie = categorie;
public void setCategory(String category) {
this.category = category;
}
public String getTableau() {
......
......@@ -2,15 +2,18 @@ package fr.istic.masteru.android.utils;
public class API_URLS {
public static final String BASE_URL = "http://5.196.21.161:8080/middlewareTennis";
public static final String BASE_URL = "http://5.196.21.161:9222";
public static final String PING_ADD_NUMBER = BASE_URL + "/test/nombres/ajouterNombre";
public static final String SCORE_UPDATE = BASE_URL + "/score/update";
public static final String SET_SCORE_UPDATE = BASE_URL + "/score/majSet";
public static final String SCORE_BACK = BASE_URL + "/score/supprPoint";
public static final String START_MATCH = BASE_URL + "/match/debut";
public static final String MATCH_WINNER = BASE_URL + "/match/finMatch";
public static final String MATCHS = BASE_URL + "/match/prochainsMatchs";
public static final String MATCHS = BASE_URL + "/matches";
public static final String INFO_MATCH = BASE_URL + "/match/info/"; // + idMatch
public static final String PLAYER_LIST = BASE_URL + "/joueur/listeJoueurs";
public static String TEAM_PLAYERS(String teamId, String gender) {
return BASE_URL + "/teams/" + teamId + "/players?gender=" + gender == null ? "X" : gender;
}
}
......@@ -80,15 +80,15 @@ public class Util {
}
public static String getCategorieName(String code) {
if (code.equals("SH"))
if (code.equals("SM"))
return "Men's Singles";
if (code.equals("SF"))
if (code.equals("SW"))
return "Women's Singles";
if (code.equals("DH"))
if (code.equals("DM"))
return "Men's Doubles";
if (code.equals("DF"))
if (code.equals("DW"))
return "Women's Doubles";
if (code.equals("DM"))
if (code.equals("DX"))
return "Mixed Doubles";
return null;
}
......
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