tabela
This commit is contained in:
@@ -61,7 +61,7 @@ public class HomeFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fetchStandings() {
|
private void fetchStandings() {
|
||||||
mDatabase = FirebaseDatabase.getInstance().getReference("standings").child(currentEscalao);
|
mDatabase = FirebaseDatabase.getInstance().getReference("classificacoes").child(currentEscalao);
|
||||||
|
|
||||||
// Remove previous listener to avoid duplicate data or leaks
|
// Remove previous listener to avoid duplicate data or leaks
|
||||||
if (mValueEventListener != null) {
|
if (mValueEventListener != null) {
|
||||||
|
|||||||
@@ -56,6 +56,17 @@ public class StandingsAdapter extends RecyclerView.Adapter<StandingsAdapter.View
|
|||||||
}
|
}
|
||||||
|
|
||||||
holder.textTeamName.setText(team.getName());
|
holder.textTeamName.setText(team.getName());
|
||||||
|
|
||||||
|
if (team.getImageUrl() != null && !team.getImageUrl().isEmpty()) {
|
||||||
|
com.bumptech.glide.Glide.with(holder.itemView.getContext())
|
||||||
|
.load(team.getImageUrl())
|
||||||
|
.placeholder(R.mipmap.ic_launcher)
|
||||||
|
.error(R.mipmap.ic_launcher)
|
||||||
|
.into(holder.imageLogo);
|
||||||
|
} else {
|
||||||
|
holder.imageLogo.setImageResource(R.mipmap.ic_launcher);
|
||||||
|
}
|
||||||
|
|
||||||
holder.textPlayed.setText(String.valueOf(team.getPlayed()));
|
holder.textPlayed.setText(String.valueOf(team.getPlayed()));
|
||||||
holder.textWon.setText(String.valueOf(team.getWon()));
|
holder.textWon.setText(String.valueOf(team.getWon()));
|
||||||
holder.textDrawn.setText(String.valueOf(team.getDrawn()));
|
holder.textDrawn.setText(String.valueOf(team.getDrawn()));
|
||||||
|
|||||||
@@ -1,28 +1,44 @@
|
|||||||
package com.example.vdcscore.ui.home;
|
package com.example.vdcscore.ui.home;
|
||||||
|
|
||||||
|
import com.google.firebase.database.PropertyName;
|
||||||
|
|
||||||
public class Team {
|
public class Team {
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@PropertyName("nome")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@PropertyName("pontos")
|
||||||
private int points;
|
private int points;
|
||||||
|
|
||||||
|
@PropertyName("jogos")
|
||||||
private int played;
|
private int played;
|
||||||
|
|
||||||
|
@PropertyName("vitorias")
|
||||||
private int won;
|
private int won;
|
||||||
|
|
||||||
|
@PropertyName("empates")
|
||||||
private int drawn;
|
private int drawn;
|
||||||
|
|
||||||
|
@PropertyName("derrotas")
|
||||||
private int lost;
|
private int lost;
|
||||||
|
|
||||||
|
@PropertyName("golos_marcados")
|
||||||
private int goalsFor;
|
private int goalsFor;
|
||||||
|
|
||||||
|
@PropertyName("golos_sofridos")
|
||||||
private int goalsAgainst;
|
private int goalsAgainst;
|
||||||
|
|
||||||
|
@PropertyName("diferenca_golos")
|
||||||
private int goalDifference;
|
private int goalDifference;
|
||||||
|
|
||||||
|
@PropertyName("imagem")
|
||||||
|
private String imageUrl;
|
||||||
|
|
||||||
public Team() {
|
public Team() {
|
||||||
// Required empty constructor for Firebase
|
// Required empty constructor for Firebase
|
||||||
}
|
}
|
||||||
|
|
||||||
public Team(String id, String name, int points, int played) {
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
this.points = points;
|
|
||||||
this.played = played;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters and Setters
|
// Getters and Setters
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
@@ -32,75 +48,107 @@ public class Team {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("nome")
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("nome")
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("pontos")
|
||||||
public int getPoints() {
|
public int getPoints() {
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("pontos")
|
||||||
public void setPoints(int points) {
|
public void setPoints(int points) {
|
||||||
this.points = points;
|
this.points = points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("jogos")
|
||||||
public int getPlayed() {
|
public int getPlayed() {
|
||||||
return played;
|
return played;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("jogos")
|
||||||
public void setPlayed(int played) {
|
public void setPlayed(int played) {
|
||||||
this.played = played;
|
this.played = played;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("vitorias")
|
||||||
public int getWon() {
|
public int getWon() {
|
||||||
|
// Fallback calculation in case "vitorias" field is not explicit in DB
|
||||||
|
if (won == 0 && points > 0) {
|
||||||
|
return (points - drawn) / 3;
|
||||||
|
}
|
||||||
return won;
|
return won;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("vitorias")
|
||||||
public void setWon(int won) {
|
public void setWon(int won) {
|
||||||
this.won = won;
|
this.won = won;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("empates")
|
||||||
public int getDrawn() {
|
public int getDrawn() {
|
||||||
return drawn;
|
return drawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("empates")
|
||||||
public void setDrawn(int drawn) {
|
public void setDrawn(int drawn) {
|
||||||
this.drawn = drawn;
|
this.drawn = drawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("derrotas")
|
||||||
public int getLost() {
|
public int getLost() {
|
||||||
return lost;
|
return lost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("derrotas")
|
||||||
public void setLost(int lost) {
|
public void setLost(int lost) {
|
||||||
this.lost = lost;
|
this.lost = lost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("golos_marcados")
|
||||||
public int getGoalsFor() {
|
public int getGoalsFor() {
|
||||||
return goalsFor;
|
return goalsFor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("golos_marcados")
|
||||||
public void setGoalsFor(int goalsFor) {
|
public void setGoalsFor(int goalsFor) {
|
||||||
this.goalsFor = goalsFor;
|
this.goalsFor = goalsFor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("golos_sofridos")
|
||||||
public int getGoalsAgainst() {
|
public int getGoalsAgainst() {
|
||||||
return goalsAgainst;
|
return goalsAgainst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("golos_sofridos")
|
||||||
public void setGoalsAgainst(int goalsAgainst) {
|
public void setGoalsAgainst(int goalsAgainst) {
|
||||||
this.goalsAgainst = goalsAgainst;
|
this.goalsAgainst = goalsAgainst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("diferenca_golos")
|
||||||
public int getGoalDifference() {
|
public int getGoalDifference() {
|
||||||
return goalDifference;
|
return goalDifference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("diferenca_golos")
|
||||||
public void setGoalDifference(int goalDifference) {
|
public void setGoalDifference(int goalDifference) {
|
||||||
this.goalDifference = goalDifference;
|
this.goalDifference = goalDifference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PropertyName("imagem")
|
||||||
|
public String getImageUrl() {
|
||||||
|
return imageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PropertyName("imagem")
|
||||||
|
public void setImageUrl(String imageUrl) {
|
||||||
|
this.imageUrl = imageUrl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user