Commit 9c0a8cc0 authored by rakam's avatar rakam

Display message if all matches are completed

parent 60ae01e9
......@@ -34,7 +34,7 @@ public class SelectMatchFragment extends SetupFragment implements OnMatchSelecte
private MatchAdapter matchAdapter;
private Button nextButton;
private ProgressBar progressBar;
private TextView noMatches;
private TextView messageTV;
@Override
public void onAttach(Activity activity) {
......@@ -56,7 +56,7 @@ public class SelectMatchFragment extends SetupFragment implements OnMatchSelecte
}
});
progressBar = (ProgressBar) root.findViewById(R.id.progressBar);
noMatches = (TextView) root.findViewById(R.id.noMatches);
messageTV = (TextView) root.findViewById(R.id.messageTV);
ListView matchListView = (ListView) root.findViewById(R.id.matchListView);
matchListView.setDividerHeight(getResources().getDimensionPixelSize(R.dimen.divider_height));
matchAdapter = new MatchAdapter(matchSetupActivity, matches, this);
......@@ -77,7 +77,7 @@ public class SelectMatchFragment extends SetupFragment implements OnMatchSelecte
public void onCompleted(Exception e, JsonObject result) {
if (e != null || result != null && result.get("code").getAsInt() != 0) {
if (result.get("code").getAsInt() == -3)
noMatches();
displayMessage(matchSetupActivity.getString(R.string.no_match_setting_up));
else
loadMatches();
return;
......@@ -105,15 +105,18 @@ public class SelectMatchFragment extends SetupFragment implements OnMatchSelecte
int court = courtElement.isJsonNull() ? -1 : courtElement.getAsInt();
matches.add(new Match(idMatch, teamA, teamB, category, tableau));
}
if (matches.size() == 0) {
displayMessage(matchSetupActivity.getString(R.string.no_matchs_all_ended));
}
if (matchAdapter != null)
matchAdapter.notifyDataSetChanged();
}
});
}
private void noMatches() {
private void displayMessage(String message) {
progressBar.setVisibility(View.GONE);
noMatches.setText(matchSetupActivity.getString(R.string.no_match_setting_up));
messageTV.setText(message);
}
@Override
......
......@@ -38,7 +38,7 @@
android:layout_centerInParent="true"/>
<TextView
android:id="@+id/noMatches"
android:id="@+id/messageTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
......
......@@ -39,5 +39,6 @@
<string name="COUP_GAGNANT">COUP GAGNANT</string>
<string name="SERVICE_GAGNANT">SERVICE GAGNANT</string>
<string name="no_match_setting_up">Aucun match disponible.\nLa compétition n\'a pas commencé.</string>
<string name="no_matchs_all_ended">Tous les matchs de la phase courante ont été terminés.</string>
</resources>
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