This commit is contained in:
2026-03-17 10:24:41 +00:00
parent acac87d95d
commit 548f1edd4c
3 changed files with 67 additions and 8 deletions

View File

@@ -61,7 +61,7 @@ public class HomeFragment extends Fragment {
}
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
if (mValueEventListener != null) {

View File

@@ -56,6 +56,17 @@ public class StandingsAdapter extends RecyclerView.Adapter<StandingsAdapter.View
}
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.textWon.setText(String.valueOf(team.getWon()));
holder.textDrawn.setText(String.valueOf(team.getDrawn()));

View File

@@ -1,28 +1,44 @@
package com.example.vdcscore.ui.home;
import com.google.firebase.database.PropertyName;
public class Team {
private String id;
@PropertyName("nome")
private String name;
@PropertyName("pontos")
private int points;
@PropertyName("jogos")
private int played;
@PropertyName("vitorias")
private int won;
@PropertyName("empates")
private int drawn;
@PropertyName("derrotas")
private int lost;
@PropertyName("golos_marcados")
private int goalsFor;
@PropertyName("golos_sofridos")
private int goalsAgainst;
@PropertyName("diferenca_golos")
private int goalDifference;
@PropertyName("imagem")
private String imageUrl;
public Team() {
// 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
public String getId() {
return id;
@@ -32,75 +48,107 @@ public class Team {
this.id = id;
}
@PropertyName("nome")
public String getName() {
return name;
}
@PropertyName("nome")
public void setName(String name) {
this.name = name;
}
@PropertyName("pontos")
public int getPoints() {
return points;
}
@PropertyName("pontos")
public void setPoints(int points) {
this.points = points;
}
@PropertyName("jogos")
public int getPlayed() {
return played;
}
@PropertyName("jogos")
public void setPlayed(int played) {
this.played = played;
}
@PropertyName("vitorias")
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;
}
@PropertyName("vitorias")
public void setWon(int won) {
this.won = won;
}
@PropertyName("empates")
public int getDrawn() {
return drawn;
}
@PropertyName("empates")
public void setDrawn(int drawn) {
this.drawn = drawn;
}
@PropertyName("derrotas")
public int getLost() {
return lost;
}
@PropertyName("derrotas")
public void setLost(int lost) {
this.lost = lost;
}
@PropertyName("golos_marcados")
public int getGoalsFor() {
return goalsFor;
}
@PropertyName("golos_marcados")
public void setGoalsFor(int goalsFor) {
this.goalsFor = goalsFor;
}
@PropertyName("golos_sofridos")
public int getGoalsAgainst() {
return goalsAgainst;
}
@PropertyName("golos_sofridos")
public void setGoalsAgainst(int goalsAgainst) {
this.goalsAgainst = goalsAgainst;
}
@PropertyName("diferenca_golos")
public int getGoalDifference() {
return goalDifference;
}
@PropertyName("diferenca_golos")
public void setGoalDifference(int goalDifference) {
this.goalDifference = goalDifference;
}
@PropertyName("imagem")
public String getImageUrl() {
return imageUrl;
}
@PropertyName("imagem")
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
}