Compare commits

...

8 Commits

Author SHA1 Message Date
6a1e604b96 . 2026-04-14 17:22:27 +01:00
a79ee68417 mais opcoes de ver estatisticas de clube 2026-03-17 17:16:23 +00:00
33a3064a89 tabela nova 2026-03-17 17:09:00 +00:00
109e4b4a92 tabela 2026-03-17 17:06:02 +00:00
1a4b5b7d37 resolve frcoisas 2026-03-17 17:03:32 +00:00
9348951090 resolver erros 2026-03-17 16:58:44 +00:00
a019287d92 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	app/src/main/java/com/example/vdcscore/ui/home/HomeFragment.java
#	app/src/main/java/com/example/vdcscore/ui/home/StandingsAdapter.java
2026-03-17 16:52:45 +00:00
012815d969 resolucao de erros 2026-03-17 16:52:14 +00:00
17 changed files with 892 additions and 429 deletions

View File

@@ -8,6 +8,7 @@ import android.view.Menu;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.navigation.NavigationView;
@@ -119,34 +120,13 @@ public class MainActivity extends AppCompatActivity {
}
private void loadProfileImageInNavHeader(String imageUrl, ImageView imageView) {
new Thread(() -> {
InputStream input = null;
try {
java.net.URL url = new java.net.URL(imageUrl);
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
input = connection.getInputStream();
Bitmap bitmap = BitmapFactory.decodeStream(input);
runOnUiThread(() -> {
if (bitmap != null && imageView != null) {
imageView.setImageBitmap(bitmap);
imageView.setScaleType(android.widget.ImageView.ScaleType.CENTER_CROP);
}
});
} catch (Exception e) {
// Se falhar, tentar carregar do Storage
runOnUiThread(() -> loadProfileImageFromStorage(imageView));
} finally {
if (input != null) {
try {
input.close();
} catch (Exception e) {
// Ignorar erro ao fechar
}
}
}
}).start();
if (imageUrl == null || imageView == null) return;
Glide.with(this)
.load(imageUrl)
.placeholder(R.mipmap.ic_launcher_round)
.error(R.mipmap.ic_launcher)
.circleCrop()
.into(imageView);
}
private void loadProfileImageFromStorage(ImageView imageView) {

View File

@@ -19,6 +19,7 @@ import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.example.vdcscore.ui.home.Team;
import com.bumptech.glide.Glide;
public class ClubDetailFragment extends Fragment {
@@ -50,73 +51,129 @@ public class ClubDetailFragment extends Fragment {
super.onViewCreated(view, savedInstanceState);
if (getArguments() != null) {
Club clubeRecebido = (Club) getArguments().getSerializable("clube_selecionado");
Team statsTeam = (Team) getArguments().getSerializable("clube_selecionado_estatisticas");
if (clubeRecebido != null) {
// Preencher views diretamente
binding.textDetailClubName.setText(clubeRecebido.getName());
binding.textDetailFoundation.setText(String.valueOf(clubeRecebido.getFoundationYear()));
binding.textDetailPresident.setText(clubeRecebido.getPresident());
binding.textDetailAddress.setText(clubeRecebido.getAddress());
if (getContext() != null) {
Glide.with(this)
.load(clubeRecebido.getImageUrl())
.placeholder(R.mipmap.ic_launcher_round)
.error(R.mipmap.ic_launcher)
.into(binding.imageDetailLogo);
if (statsTeam != null) {
populateStats(statsTeam);
setupComparison(statsTeam);
} else {
Club clubeRecebido = (Club) getArguments().getSerializable("clube_selecionado");
if (clubeRecebido != null) {
populateClubInfo(clubeRecebido);
}
// Configurar o botão para ver jogadores
binding.btnPlayers.setOnClickListener(v -> {
Bundle bundle = new Bundle();
// Passar o 'clube_selecionado' também para a lista de jogadores se necessário,
// ou passar o ID como antes se o fragmento de jogadores esperar ID
bundle.putString("clubId", String.valueOf(clubeRecebido.getId()));
bundle.putString("escalao", escalao);
// Se o ClubPlayersFragment esperar "clube_selecionado" tambem, poderiamos
// passar:
// bundle.putSerializable("clube_selecionado", clubeRecebido);
Navigation.findNavController(view).navigate(R.id.action_nav_club_detail_to_nav_club_players,
bundle);
});
}
}
}
private void loadClubDetails() {
mDatabase.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
Club club = snapshot.getValue(Club.class);
if (club != null) {
binding.textDetailClubName.setText(club.getName());
binding.textDetailFoundation.setText(String.valueOf(club.getFoundationYear()));
binding.textDetailPresident.setText(club.getPresident());
binding.textDetailAddress.setText(club.getAddress());
// binding.textDetailStadium.setText(club.getStadium()); // Hidden for now
private void populateStats(Team team) {
binding.textDetailClubName.setText(team.getNome());
binding.textDetailPoints.setText(String.valueOf(team.getPontos()));
binding.textDetailPlayed.setText(String.valueOf(team.getJogos()));
binding.textDetailWon.setText(team.getVitorias() + "V");
binding.textDetailDrawn.setText(team.getEmpates() + "E");
binding.textDetailLost.setText(team.getDerrotas() + "D");
binding.textDetailGoals.setText(team.getGolos_marcados() + " - " + team.getGolos_sofridos());
binding.textDetailGoalDiff.setText((team.getDiferenca_golos() > 0 ? "+" : "") + team.getDiferenca_golos());
// Posicao circle and text
binding.textDetailPosition.setText(team.getPosicao() > 0 ? team.getPosicao() + "º" : "---");
binding.textDetailPositionCircle.setText(String.valueOf(team.getPosicao() > 0 ? team.getPosicao() : "-"));
// binding.imageDetailLogo.setImageResource(R.mipmap.ic_launcher_round);
if (getContext() != null) {
Glide.with(ClubDetailFragment.this)
.load(club.getImageUrl())
.placeholder(R.mipmap.ic_launcher_round)
.error(R.mipmap.ic_launcher)
.into(binding.imageDetailLogo);
}
}
}
if (getContext() != null) {
Glide.with(this)
.load(team.getImagem())
.placeholder(R.mipmap.ic_launcher_round)
.error(R.mipmap.ic_launcher)
.into(binding.imageDetailLogo);
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
if (getContext() != null) {
Toast.makeText(getContext(), "Failed to load club details.", Toast.LENGTH_SHORT).show();
}
}
// Button players
binding.btnPlayers.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putString("clubId", String.valueOf(team.getTeam_id()));
bundle.putString("escalao", escalao);
Navigation.findNavController(v).navigate(R.id.action_nav_club_detail_to_nav_club_players, bundle);
});
}
private void populateClubInfo(Club club) {
binding.textDetailClubName.setText(club.getName());
// If coming from Clubs list, we don't have stats easily unless we fetch them or hide stats container.
// For now, hide stats if no statsTeam
binding.labelStats.setVisibility(View.GONE);
binding.containerStats.setVisibility(View.GONE);
binding.btnCompare.setVisibility(View.GONE);
if (getContext() != null) {
Glide.with(this)
.load(club.getImageUrl())
.placeholder(R.mipmap.ic_launcher_round)
.error(R.mipmap.ic_launcher)
.into(binding.imageDetailLogo);
}
binding.btnPlayers.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putString("clubId", String.valueOf(club.getId()));
bundle.putString("escalao", escalao);
Navigation.findNavController(v).navigate(R.id.action_nav_club_detail_to_nav_club_players, bundle);
});
}
private void setupComparison(Team team1) {
binding.btnCompare.setOnClickListener(v -> {
// Fetch all teams of same escalao if not fetched
FirebaseDatabase.getInstance().getReference("classificacoes").child(escalao)
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
java.util.List<Team> otherTeams = new java.util.ArrayList<>();
for (DataSnapshot postSnapshot : snapshot.getChildren()) {
Team t = postSnapshot.getValue(Team.class);
if (t != null && t.getTeam_id() != team1.getTeam_id()) {
otherTeams.add(t);
}
}
showComparisonDialog(team1, otherTeams);
}
@Override
public void onCancelled(@NonNull DatabaseError error) {}
});
});
}
private void showComparisonDialog(Team team1, java.util.List<Team> otherTeams) {
String[] teamNames = new String[otherTeams.size()];
for (int i = 0; i < otherTeams.size(); i++) {
teamNames[i] = otherTeams.get(i).getNome();
}
new androidx.appcompat.app.AlertDialog.Builder(requireContext())
.setTitle("Selecionar Equipa para Comparar")
.setItems(teamNames, (dialog, which) -> {
Team team2 = otherTeams.get(which);
displayComparison(team1, team2);
})
.show();
}
private void displayComparison(Team t1, Team t2) {
binding.layoutComparison.setVisibility(View.VISIBLE);
binding.textCompareTeam1.setText(t1.getNome());
binding.textCompareTeam2.setText(t2.getNome());
binding.textCompareP1.setText(String.valueOf(t1.getPontos()));
binding.textCompareP2.setText(String.valueOf(t2.getPontos()));
binding.textCompareG1.setText(String.valueOf(t1.getGolos_marcados()));
binding.textCompareG2.setText(String.valueOf(t2.getGolos_marcados()));
// Highlight advantage
binding.textCompareP1.setTextColor(t1.getPontos() >= t2.getPontos() ? android.graphics.Color.GREEN : android.graphics.Color.RED);
binding.textCompareP2.setTextColor(t2.getPontos() >= t1.getPontos() ? android.graphics.Color.GREEN : android.graphics.Color.RED);
}
@Override
public void onDestroyView() {
super.onDestroyView();

View File

@@ -62,49 +62,55 @@ public class ClubsFragment extends Fragment {
}
private void loadClubsData(RecyclerView recyclerView, ProgressBar progressBar) {
progressBar.setVisibility(View.VISIBLE);
mDatabase = FirebaseDatabase.getInstance().getReference().child("clubes");
if (progressBar != null) progressBar.setVisibility(View.VISIBLE);
// Remove previous listener to avoid duplicate data or leaks
if (mValueEventListener != null) {
// Remove previous listener from the PREVIOUS path
if (mDatabase != null && mValueEventListener != null) {
mDatabase.removeEventListener(mValueEventListener);
}
mDatabase = FirebaseDatabase.getInstance().getReference().child("clubes");
mValueEventListener = new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
if (binding == null) return;
List<Club> clubs = new ArrayList<>();
for (DataSnapshot postSnapshot : snapshot.getChildren()) {
if (postSnapshot.child("jogadores").child(currentEscalao).exists()) {
Club club = postSnapshot.getValue(Club.class);
if (club != null) {
clubs.add(club);
try {
Club club = postSnapshot.getValue(Club.class);
if (club != null) {
clubs.add(club);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
ClubAdapter adapter = new ClubAdapter(clubs, club -> {
if (binding == null) return;
Bundle bundle = new Bundle();
bundle.putSerializable("clube_selecionado", club);
bundle.putString("escalao", currentEscalao);
androidx.navigation.fragment.NavHostFragment.findNavController(ClubsFragment.this)
.navigate(R.id.action_nav_clubs_to_nav_club_detail, bundle);
});
recyclerView.setAdapter(adapter);
progressBar.setVisibility(View.GONE);
if (clubs.isEmpty()) {
// Keep UI empty but don't show mock data automatically to avoid confusion
// Toast.makeText(getContext(), "No clubs found.", Toast.LENGTH_SHORT).show();
if (recyclerView != null) {
recyclerView.setAdapter(adapter);
}
if (progressBar != null) {
progressBar.setVisibility(View.GONE);
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
Log.w(TAG, "loadClubs:onCancelled", error.toException());
if (getContext() != null) {
if (getContext() != null && binding != null) {
Toast.makeText(getContext(), "Failed to load clubs.", Toast.LENGTH_SHORT).show();
}
if (binding != null) {
binding.progressBar.setVisibility(View.GONE);
}
}

View File

@@ -28,6 +28,7 @@ import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import com.bumptech.glide.Glide;
import com.example.vdcscore.LoginActivity;
import com.example.vdcscore.R;
import com.google.android.material.appbar.MaterialToolbar;
@@ -193,32 +194,13 @@ public class ContaActivity extends AppCompatActivity {
}
private void loadProfileImage(String imageUrl) {
new Thread(() -> {
InputStream input = null;
try {
java.net.URL url = new java.net.URL(imageUrl);
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
input = connection.getInputStream();
Bitmap bitmap = BitmapFactory.decodeStream(input);
runOnUiThread(() -> {
if (bitmap != null && imageProfile != null) {
imageProfile.setImageBitmap(bitmap);
}
});
} catch (Exception e) {
runOnUiThread(() -> loadProfileImageFromStorage());
} finally {
if (input != null) {
try {
input.close();
} catch (Exception e) {
// Ignorar erro ao fechar
}
}
}
}).start();
if (imageUrl == null || imageProfile == null) return;
Glide.with(this)
.load(imageUrl)
.placeholder(R.mipmap.ic_launcher_round)
.error(R.mipmap.ic_launcher)
.circleCrop()
.into(imageProfile);
}
private void loadProfileImageFromStorage() {

View File

@@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.example.vdcscore.R;
import com.example.vdcscore.databinding.FragmentGalleryBinding;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
@@ -23,8 +24,12 @@ import java.util.List;
public class GalleryFragment extends Fragment {
private FragmentGalleryBinding binding;
private MatchdaysAdapter adapter;
private MatchesAdapter adapter;
private DatabaseReference mDatabase;
private List<Matchday> matchdaysList = new ArrayList<>();
private int currentJornadaIndex = 0;
private String currentCategory = "seniores";
private ValueEventListener currentListener;
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
@@ -33,56 +38,119 @@ public class GalleryFragment extends Fragment {
View root = binding.getRoot();
// Initialize RecyclerView
adapter = new MatchdaysAdapter();
adapter = new MatchesAdapter();
binding.recyclerMatchdays.setLayoutManager(new LinearLayoutManager(getContext()));
binding.recyclerMatchdays.setAdapter(adapter);
// Initialize Firebase
mDatabase = FirebaseDatabase.getInstance().getReference("matchdays");
// Setup Toggle Group
binding.toggleGroupCategory.addOnButtonCheckedListener((group, checkedId, isChecked) -> {
if (isChecked) {
if (checkedId == R.id.btn_seniores) {
currentCategory = "seniores";
} else if (checkedId == R.id.btn_juniores) {
currentCategory = "juniores";
}
fetchMatchdays();
}
});
// Fetch Data
// Setup Navigation Buttons
binding.btnPrevJornada.setOnClickListener(v -> {
if (currentJornadaIndex > 0) {
currentJornadaIndex--;
updateUI();
}
});
binding.btnNextJornada.setOnClickListener(v -> {
if (currentJornadaIndex < matchdaysList.size() - 1) {
currentJornadaIndex++;
updateUI();
}
});
// Initial Fetch
fetchMatchdays();
return root;
}
private void fetchMatchdays() {
mDatabase.addValueEventListener(new ValueEventListener() {
if (mDatabase != null && currentListener != null) {
mDatabase.removeEventListener(currentListener);
}
binding.textJornadaName.setText("Carregando...");
mDatabase = FirebaseDatabase.getInstance().getReference("jornadas").child(currentCategory);
currentListener = new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
List<Matchday> matchdays = new ArrayList<>();
for (DataSnapshot postSnapshot : snapshot.getChildren()) {
Matchday matchday = new Matchday();
matchday.setId(postSnapshot.getKey());
matchday.setName(postSnapshot.child("name").getValue(String.class));
if (binding == null) return;
matchdaysList.clear();
for (DataSnapshot jornadaSnap : snapshot.getChildren()) {
String name = jornadaSnap.getKey();
List<Match> matches = new ArrayList<>();
for (DataSnapshot matchSnapshot : postSnapshot.child("matches").getChildren()) {
Match match = matchSnapshot.getValue(Match.class);
for (DataSnapshot matchSnap : jornadaSnap.getChildren()) {
Match match = matchSnap.getValue(Match.class);
if (match != null) {
match.setId(matchSnapshot.getKey());
match.setId(matchSnap.getKey());
matches.add(match);
}
}
matchday.setMatches(matches);
matchdays.add(matchday);
if (!matches.isEmpty()) {
matchdaysList.add(new Matchday(name, matches));
}
}
if (matchdaysList.isEmpty()) {
binding.textJornadaName.setText("Sem jornadas");
adapter.setMatches(new ArrayList<>());
} else {
// Try to stay on the same index or go to the first one
if (currentJornadaIndex >= matchdaysList.size()) {
currentJornadaIndex = matchdaysList.size() - 1;
}
updateUI();
}
adapter.setMatchdays(matchdays);
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
if (getContext() != null) {
Toast.makeText(getContext(), "Erro ao carregar jornadas: " + error.getMessage(), Toast.LENGTH_SHORT)
.show();
Toast.makeText(getContext(), "Erro ao carregar: " + error.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
};
mDatabase.addValueEventListener(currentListener);
}
private void updateUI() {
if (matchdaysList.isEmpty()) return;
Matchday currentMatchday = matchdaysList.get(currentJornadaIndex);
binding.textJornadaName.setText(currentMatchday.getName());
adapter.setMatches(currentMatchday.getMatches());
// Enable/Disable navigation buttons
binding.btnPrevJornada.setEnabled(currentJornadaIndex > 0);
binding.btnNextJornada.setEnabled(currentJornadaIndex < matchdaysList.size() - 1);
// Visual feedback for disabled buttons
binding.btnPrevJornada.setAlpha(currentJornadaIndex > 0 ? 1.0f : 0.3f);
binding.btnNextJornada.setAlpha(currentJornadaIndex < matchdaysList.size() - 1 ? 1.0f : 0.3f);
}
@Override
public void onDestroyView() {
super.onDestroyView();
if (mDatabase != null && currentListener != null) {
mDatabase.removeEventListener(currentListener);
}
binding = null;
}
}

View File

@@ -1,27 +1,22 @@
package com.example.vdcscore.ui.gallery;
import com.google.firebase.database.PropertyName;
public class Match {
private String id;
private String homeTeam;
private String awayTeam;
private int homeScore;
private int awayScore;
private String homeName;
private String awayName;
private Integer homeScore;
private Integer awayScore;
private String date;
private String time;
private String status; // "Scheduled", "Finished", "Live"
private String homeLogo;
private String awayLogo;
private String stadium;
public Match() {
}
public Match(String homeTeam, String awayTeam, String date, String time) {
this.homeTeam = homeTeam;
this.awayTeam = awayTeam;
this.date = date;
this.time = time;
this.status = "Scheduled";
}
// Getters and Setters
public String getId() {
return id;
}
@@ -30,59 +25,93 @@ public class Match {
this.id = id;
}
public String getHomeTeam() {
return homeTeam;
@PropertyName("home_nome")
public String getHomeName() {
return homeName;
}
public void setHomeTeam(String homeTeam) {
this.homeTeam = homeTeam;
@PropertyName("home_nome")
public void setHomeName(String homeName) {
this.homeName = homeName;
}
public String getAwayTeam() {
return awayTeam;
@PropertyName("away_nome")
public String getAwayName() {
return awayName;
}
public void setAwayTeam(String awayTeam) {
this.awayTeam = awayTeam;
@PropertyName("away_nome")
public void setAwayName(String awayName) {
this.awayName = awayName;
}
public int getHomeScore() {
@PropertyName("home_golos")
public Integer getHomeScore() {
return homeScore;
}
public void setHomeScore(int homeScore) {
@PropertyName("home_golos")
public void setHomeScore(Integer homeScore) {
this.homeScore = homeScore;
}
public int getAwayScore() {
@PropertyName("away_golos")
public Integer getAwayScore() {
return awayScore;
}
public void setAwayScore(int awayScore) {
@PropertyName("away_golos")
public void setAwayScore(Integer awayScore) {
this.awayScore = awayScore;
}
@PropertyName("data")
public String getDate() {
return date;
}
@PropertyName("data")
public void setDate(String date) {
this.date = date;
}
@PropertyName("hora")
public String getTime() {
return time;
}
@PropertyName("hora")
public void setTime(String time) {
this.time = time;
}
public String getStatus() {
return status;
@PropertyName("home_logo")
public String getHomeLogo() {
return homeLogo;
}
public void setStatus(String status) {
this.status = status;
@PropertyName("home_logo")
public void setHomeLogo(String homeLogo) {
this.homeLogo = homeLogo;
}
@PropertyName("away_logo")
public String getAwayLogo() {
return awayLogo;
}
@PropertyName("away_logo")
public void setAwayLogo(String awayLogo) {
this.awayLogo = awayLogo;
}
@PropertyName("campo")
public String getStadium() {
return stadium;
}
@PropertyName("campo")
public void setStadium(String stadium) {
this.stadium = stadium;
}
}

View File

@@ -3,21 +3,32 @@ package com.example.vdcscore.ui.gallery;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.example.vdcscore.R;
import java.util.ArrayList;
import java.util.List;
public class MatchesAdapter extends RecyclerView.Adapter<MatchesAdapter.ViewHolder> {
private List<Match> matches;
private List<Match> matches = new ArrayList<>();
public MatchesAdapter() {
}
public MatchesAdapter(List<Match> matches) {
this.matches = matches;
this.matches = (matches != null) ? matches : new ArrayList<>();
}
public void setMatches(List<Match> matches) {
this.matches = (matches != null) ? matches : new ArrayList<>();
notifyDataSetChanged();
}
@NonNull
@@ -31,21 +42,45 @@ public class MatchesAdapter extends RecyclerView.Adapter<MatchesAdapter.ViewHold
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
Match match = matches.get(position);
holder.textHomeTeam.setText(match.getHomeTeam());
holder.textAwayTeam.setText(match.getAwayTeam());
if ("Finished".equals(match.getStatus())) {
// Team Names with fallback
String homeName = match.getHomeName();
String awayName = match.getAwayName();
holder.textHomeTeam.setText(isValid(homeName) ? homeName : "Equipa A");
holder.textAwayTeam.setText(isValid(awayName) ? awayName : "Equipa B");
// Logos
Glide.with(holder.itemView.getContext())
.load(match.getHomeLogo())
.placeholder(R.drawable.ic_club_placeholder)
.into(holder.imgHomeLogo);
Glide.with(holder.itemView.getContext())
.load(match.getAwayLogo())
.placeholder(R.drawable.ic_club_placeholder)
.into(holder.imgAwayLogo);
// Scores and Time
if (match.getHomeScore() != null && match.getAwayScore() != null) {
holder.textScore.setText(match.getHomeScore() + " - " + match.getAwayScore());
holder.textTime.setText("Final");
holder.textTime.setText(match.getDate() != null ? match.getDate() : "Final");
} else {
holder.textScore.setText("Vs");
holder.textTime.setText(match.getTime());
String timeStr = "";
if (match.getDate() != null) timeStr += match.getDate();
if (match.getTime() != null) timeStr += " " + match.getTime();
holder.textTime.setText(timeStr.trim().isEmpty() ? "Agendado" : timeStr.trim());
}
}
private boolean isValid(String text) {
return text != null && !text.trim().isEmpty() && !text.equalsIgnoreCase("null");
}
@Override
public int getItemCount() {
return matches == null ? 0 : matches.size();
return matches.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
@@ -53,6 +88,8 @@ public class MatchesAdapter extends RecyclerView.Adapter<MatchesAdapter.ViewHold
public final TextView textAwayTeam;
public final TextView textScore;
public final TextView textTime;
public final ImageView imgHomeLogo;
public final ImageView imgAwayLogo;
public ViewHolder(View view) {
super(view);
@@ -60,6 +97,8 @@ public class MatchesAdapter extends RecyclerView.Adapter<MatchesAdapter.ViewHold
textAwayTeam = view.findViewById(R.id.text_away_team);
textScore = view.findViewById(R.id.text_score);
textTime = view.findViewById(R.id.text_time);
imgHomeLogo = view.findViewById(R.id.img_home_logo);
imgAwayLogo = view.findViewById(R.id.img_away_logo);
}
}
}

View File

@@ -39,6 +39,12 @@ public class HomeFragment extends Fragment {
// Initialize RecyclerView
adapter = new StandingsAdapter();
adapter.setOnTeamClickListener(team -> {
Bundle bundle = new Bundle();
bundle.putSerializable("clube_selecionado_estatisticas", team);
bundle.putString("escalao", currentEscalao);
androidx.navigation.Navigation.findNavController(root).navigate(R.id.action_nav_home_to_nav_club_detail, bundle);
});
binding.recyclerStandings.setLayoutManager(new LinearLayoutManager(getContext()));
binding.recyclerStandings.setAdapter(adapter);
@@ -61,50 +67,50 @@ public class HomeFragment extends Fragment {
}
private void fetchStandings() {
mDatabase = FirebaseDatabase.getInstance().getReference("classificacoes").child(currentEscalao);
// Remove previous listener to avoid duplicate data or leaks
if (mValueEventListener != null) {
// Remove previous listener from the PREVIOUS path
if (mDatabase != null && mValueEventListener != null) {
mDatabase.removeEventListener(mValueEventListener);
}
mDatabase = FirebaseDatabase.getInstance().getReference("classificacoes").child(currentEscalao);
mValueEventListener = new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
if (binding == null) return;
List<Team> teams = new ArrayList<>();
for (DataSnapshot postSnapshot : snapshot.getChildren()) {
try {
Team team = postSnapshot.getValue(Team.class);
if (team != null) {
// If ID is missing, set it from the key
if (team.getId() == null) {
team.setId(postSnapshot.getKey());
if (team.getTeam_id() == 0) {
try {
team.setTeam_id(Integer.parseInt(postSnapshot.getKey()));
} catch (NumberFormatException e) {
// fallback if key is not a number
}
}
teams.add(team);
}
} catch (Exception e) {
android.util.Log.e("HomeFragment", "Error mapping Team: " + e.getMessage());
e.printStackTrace();
}
}
android.util.Log.d("HomeFragment", "Fetched " + teams.size() + " teams for escalao: " + currentEscalao);
// Sort by Points (Descending), then Goal Difference, then Goals For
Collections.sort(teams, new Comparator<Team>() {
@Override
public int compare(Team t1, Team t2) {
if (t1.getPoints() != t2.getPoints()) {
return t2.getPoints() - t1.getPoints(); // Descending points
}
return t2.getGoalDifference() - t1.getGoalDifference(); // Descending GD
}
});
// Set positions after sorting
for (int i = 0; i < teams.size(); i++) {
teams.get(i).setPosicao(i + 1);
}
adapter.setTeams(teams);
if (adapter != null) {
adapter.setTeams(teams);
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
if (getContext() != null) {
if (getContext() != null && binding != null) {
Toast.makeText(getContext(), "Erro ao carregar classificação: " + error.getMessage(),
Toast.LENGTH_SHORT).show();
}

View File

@@ -9,19 +9,29 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.vdcscore.R;
import com.bumptech.glide.Glide;
import java.util.ArrayList;
import java.util.List;
import com.bumptech.glide.Glide;
public class StandingsAdapter extends RecyclerView.Adapter<StandingsAdapter.ViewHolder> {
private List<Team> mTeams;
private OnTeamClickListener mListener;
public interface OnTeamClickListener {
void onTeamClick(Team team);
}
public StandingsAdapter() {
this.mTeams = new ArrayList<>();
}
public void setOnTeamClickListener(OnTeamClickListener listener) {
this.mListener = listener;
}
public void setTeams(List<Team> teams) {
this.mTeams = teams;
notifyDataSetChanged();
@@ -38,6 +48,7 @@ public class StandingsAdapter extends RecyclerView.Adapter<StandingsAdapter.View
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
Team team = mTeams.get(position);
if (team == null) return;
int rank = position + 1;
holder.textPosition.setText(String.valueOf(rank));
@@ -56,24 +67,26 @@ public class StandingsAdapter extends RecyclerView.Adapter<StandingsAdapter.View
holder.textPosition.setTextColor(android.graphics.Color.BLACK);
}
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);
}
String imageUrl = team.getImagem();
Glide.with(holder.itemView.getContext())
.load(imageUrl != null ? imageUrl : "")
.placeholder(R.mipmap.ic_launcher)
.error(R.mipmap.ic_launcher)
.into(holder.imageLogo);
holder.textPlayed.setText(String.valueOf(team.getPlayed()));
holder.textWon.setText(String.valueOf(team.getWon()));
holder.textDrawn.setText(String.valueOf(team.getDrawn()));
holder.textLost.setText(String.valueOf(team.getLost()));
holder.textGoalDiff.setText(String.valueOf(team.getGoalDifference()));
holder.textPoints.setText(String.valueOf(team.getPoints()));
holder.textTeamName.setText(team.getNome() != null ? team.getNome() : "---");
holder.textPlayed.setText(String.valueOf(team.getJogos()));
holder.textWon.setText(String.valueOf(team.getVitorias()));
holder.textDrawn.setText(String.valueOf(team.getEmpates()));
holder.textLost.setText(String.valueOf(team.getDerrotas()));
holder.textGoalDiff.setText(String.valueOf(team.getDiferenca_golos()));
holder.textPoints.setText(String.valueOf(team.getPontos()));
holder.itemView.setOnClickListener(v -> {
if (mListener != null) {
mListener.onTeamClick(team);
}
});
}
@Override

View File

@@ -1,115 +1,118 @@
package com.example.vdcscore.ui.home;
public class Team {
private String id;
private String name;
private int points;
private int played;
private int won;
private int drawn;
private int lost;
private int goalsFor;
private int goalsAgainst;
private int goalDifference;
private String imageUrl;
@com.google.firebase.database.IgnoreExtraProperties
public class Team implements java.io.Serializable {
private int team_id;
private String nome;
private int pontos;
private int jogos;
private int vitorias;
private int empates;
private int derrotas;
private int golos_marcados;
private int golos_sofridos;
private int diferenca_golos;
private String imagem;
private int posicao;
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;
public int getTeam_id() {
return team_id;
}
public void setId(String id) {
this.id = id;
public void setTeam_id(int team_id) {
this.team_id = team_id;
}
public String getName() {
return name;
public String getNome() {
return nome;
}
public void setName(String name) {
this.name = name;
public void setNome(String nome) {
this.nome = nome;
}
public int getPoints() {
return points;
public int getPontos() {
return pontos;
}
public void setPoints(int points) {
this.points = points;
public void setPontos(int pontos) {
this.pontos = pontos;
}
public int getPlayed() {
return played;
public int getJogos() {
return jogos;
}
public void setPlayed(int played) {
this.played = played;
public void setJogos(int jogos) {
this.jogos = jogos;
}
public int getWon() {
return won;
public int getVitorias() {
return vitorias;
}
public void setWon(int won) {
this.won = won;
public void setVitorias(int vitorias) {
this.vitorias = vitorias;
}
public int getDrawn() {
return drawn;
public int getEmpates() {
return empates;
}
public void setDrawn(int drawn) {
this.drawn = drawn;
public void setEmpates(int empates) {
this.empates = empates;
}
public int getLost() {
return lost;
public int getDerrotas() {
return derrotas;
}
public void setLost(int lost) {
this.lost = lost;
public void setDerrotas(int derrotas) {
this.derrotas = derrotas;
}
public int getGoalsFor() {
return goalsFor;
public int getGolos_marcados() {
return golos_marcados;
}
public void setGoalsFor(int goalsFor) {
this.goalsFor = goalsFor;
public void setGolos_marcados(int golos_marcados) {
this.golos_marcados = golos_marcados;
}
public int getGoalsAgainst() {
return goalsAgainst;
public int getGolos_sofridos() {
return golos_sofridos;
}
public void setGoalsAgainst(int goalsAgainst) {
this.goalsAgainst = goalsAgainst;
public void setGolos_sofridos(int golos_sofridos) {
this.golos_sofridos = golos_sofridos;
}
public int getGoalDifference() {
return goalDifference;
public int getDiferenca_golos() {
return diferenca_golos;
}
public void setGoalDifference(int goalDifference) {
this.goalDifference = goalDifference;
public void setDiferenca_golos(int diferenca_golos) {
this.diferenca_golos = diferenca_golos;
}
public String getImageUrl() {
return imageUrl;
public String getImagem() {
return imagem;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
public void setImagem(String imagem) {
this.imagem = imagem;
}
public int getPosicao() {
return posicao;
}
public void setPosicao(int posicao) {
this.posicao = posicao;
}
}

View File

@@ -31,6 +31,7 @@ public class LiveGamesFragment extends Fragment {
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
gameViewModel.getGames().observe(getViewLifecycleOwner(), games -> {
if (binding == null) return;
GameAdapter adapter = new GameAdapter(games, game -> {
gameViewModel.selectGame(game);
Navigation.findNavController(root).navigate(R.id.action_nav_live_games_to_nav_live_game_detail);

View File

@@ -61,150 +61,314 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<!-- President Section -->
<!-- Statistics Header -->
<TextView
android:id="@+id/label_stats"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ESTATÍSTICAS:"
android:textSize="14sp"
android:textColor="#616161"
android:layout_marginTop="32dp"
app:layout_constraintTop_toBottomOf="@id/text_detail_club_name"
app:layout_constraintStart_toStartOf="parent"/>
<!-- Stats Container -->
<LinearLayout
android:id="@+id/layout_president"
android:id="@+id/container_stats"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_marginTop="24dp"
app:layout_constraintTop_toBottomOf="@id/text_detail_club_name"
android:orientation="vertical"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@id/label_stats"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/ic_person"
app:tint="#455A64"
android:background="@drawable/circle_edit_background"
android:backgroundTint="#ECEFF1"
android:padding="8dp"/>
<!-- Posicao Row -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="16dp">
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingVertical="8dp">
<TextView
android:id="@+id/text_detail_position_circle"
android:layout_width="40dp"
android:layout_height="40dp"
android:gravity="center"
android:text="1"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
android:background="@drawable/bg_circle_green"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="16dp"
android:text="POSIÇÃO ATUAL:"
android:textSize="12sp"
android:textColor="#616161"/>
<TextView
android:id="@+id/text_detail_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1º"
android:textSize="18sp"
android:textColor="#263238"
android:textStyle="bold"/>
</LinearLayout>
<!-- Pontos Row -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingVertical="8dp">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/ic_soccer"
app:tint="#D32F2F"
android:background="@drawable/circle_edit_background"
android:backgroundTint="#FFEBEE"
android:padding="8dp"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="16dp"
android:text="PONTOS:"
android:textSize="12sp"
android:textColor="#616161"/>
<TextView
android:id="@+id/text_detail_points"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="30"
android:textSize="18sp"
android:textColor="#D32F2F"
android:textStyle="bold"/>
</LinearLayout>
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#F5F5F5"/>
<!-- Games Row -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingVertical="8dp">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/ic_soccer"
app:tint="#1976D2"
android:background="@drawable/circle_edit_background"
android:backgroundTint="#E3F2FD"
android:padding="8dp"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="16dp"
android:text="JOGOS REALIZADOS:"
android:textSize="12sp"
android:textColor="#616161"/>
<TextView
android:id="@+id/text_detail_played"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10"
android:textSize="16sp"
android:textColor="#263238"
android:textStyle="bold"/>
</LinearLayout>
<!-- W/D/L Summary -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginStart="56dp"
android:paddingBottom="8dp">
<TextView
android:id="@+id/text_detail_won"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PRESIDENTE:"
android:textSize="12sp"
android:textColor="#616161"/>
android:text="10V"
android:textColor="#388E3C"
android:textStyle="bold"
android:textSize="14sp"
android:layout_marginEnd="16dp"/>
<TextView
android:id="@+id/text_detail_president"
android:id="@+id/text_detail_drawn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="João Silva"
android:textSize="16sp"
android:textColor="#263238"
android:textStyle="bold"/>
android:text="0E"
android:textColor="#FBC02D"
android:textStyle="bold"
android:textSize="14sp"
android:layout_marginEnd="16dp"/>
<TextView
android:id="@+id/text_detail_lost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0D"
android:textColor="#D32F2F"
android:textStyle="bold"
android:textSize="14sp"/>
</LinearLayout>
</LinearLayout>
<!-- Address Section -->
<LinearLayout
android:id="@+id/layout_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@id/layout_president"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/ic_location"
app:tint="#455A64"
android:background="@drawable/circle_edit_background"
android:backgroundTint="#ECEFF1"
android:padding="8dp"/>
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#F5F5F5"/>
<!-- Goals Row -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="16dp">
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingVertical="8dp">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/ic_soccer"
app:tint="#455A64"
android:background="@drawable/circle_edit_background"
android:backgroundTint="#ECEFF1"
android:padding="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="MORADA:"
android:layout_weight="1"
android:layout_marginStart="16dp"
android:text="GOLOS (M-S):"
android:textSize="12sp"
android:textColor="#616161"/>
<TextView
android:id="@+id/text_detail_address"
android:id="@+id/text_detail_goals"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Rua Desportiva 123"
android:text="54 - 8"
android:textSize="16sp"
android:textColor="#263238"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
<!-- Foundation Section -->
<LinearLayout
android:id="@+id/layout_foundation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@id/layout_address"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/ic_calendar"
app:tint="#455A64"
android:background="@drawable/circle_edit_background"
android:backgroundTint="#ECEFF1"
android:padding="8dp"/>
<!-- Goal Diff Row -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="16dp">
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingVertical="8dp">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/ic_soccer"
app:tint="#7B1FA2"
android:background="@drawable/circle_edit_background"
android:backgroundTint="#F3E5F5"
android:padding="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="ANO DE FUNDAÇÃO:"
android:layout_weight="1"
android:layout_marginStart="16dp"
android:text="DIFERENÇA DE GOLOS:"
android:textSize="12sp"
android:textColor="#616161"/>
<TextView
android:id="@+id/text_detail_foundation"
android:id="@+id/text_detail_goal_diff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="1995"
android:text="+46"
android:textSize="16sp"
android:textColor="#263238"
android:textColor="#7B1FA2"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
<!-- Comparison Button -->
<Button
android:id="@+id/btn_compare"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="COMPARAR ESTATÍSTICAS"
android:layout_marginTop="24dp"
app:cornerRadius="12dp"
android:backgroundTint="#FFC107"
android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@id/container_stats"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<!-- Comparison View (Hidden initially) -->
<LinearLayout
android:id="@+id/layout_comparison"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
android:layout_marginTop="16dp"
android:padding="12dp"
android:background="@drawable/shape_score_bg"
app:layout_constraintTop_toBottomOf="@id/btn_compare">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CONFRONTO DIRETO"
android:textStyle="bold"
android:textSize="14sp"
android:layout_gravity="center"
android:layout_marginBottom="8dp"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow android:padding="4dp">
<View android:layout_width="0dp" android:layout_weight="1"/>
<TextView android:id="@+id/text_compare_team1" android:text="Equipa A" android:textStyle="bold" android:gravity="center" android:layout_width="0dp" android:layout_weight="2"/>
<TextView android:id="@+id/text_compare_team2" android:text="Equipa B" android:textStyle="bold" android:gravity="center" android:layout_width="0dp" android:layout_weight="2"/>
</TableRow>
<TableRow android:padding="4dp">
<TextView android:text="Pontos" android:textSize="12sp" android:layout_width="0dp" android:layout_weight="1"/>
<TextView android:id="@+id/text_compare_p1" android:text="30" android:gravity="center" android:layout_width="0dp" android:layout_weight="2"/>
<TextView android:id="@+id/text_compare_p2" android:text="20" android:gravity="center" android:layout_width="0dp" android:layout_weight="2"/>
</TableRow>
<TableRow android:padding="4dp">
<TextView android:text="Golos" android:textSize="12sp" android:layout_width="0dp" android:layout_weight="1"/>
<TextView android:id="@+id/text_compare_g1" android:text="50" android:gravity="center" android:layout_width="0dp" android:layout_weight="2"/>
<TextView android:id="@+id/text_compare_g2" android:text="30" android:gravity="center" android:layout_width="0dp" android:layout_weight="2"/>
</TableRow>
</TableLayout>
</LinearLayout>
<!-- Stadium Section (Hidden per screenshot but kept in model, or should I show it?)
The screenshot doesn't explicitly show Stadium but the code had it.
I will hide it for now to match screenshot strictly or add it if plenty space?
The user said "appears like this", implies following the screenshot.
But previously stadium was shown. I will add it as well for completeness if it fits,
or just omit if the screenshot is strict.
Screenshot: CLUBE, PRESIDENTE, MORADA, ANO DE FUNDACAO. No Stadium.
I will omit Stadium from UI to match unique request "like this".
-->
<!-- Players Button -->
<Button
@@ -223,7 +387,7 @@
app:iconTint="@color/white"
android:gravity="center"
android:layout_marginTop="40dp"
app:layout_constraintTop_toBottomOf="@id/layout_foundation"
app:layout_constraintTop_toBottomOf="@id/layout_comparison"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="1.0"
android:layout_marginBottom="20dp"/>

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -9,19 +10,91 @@
tools:context=".ui.gallery.GalleryFragment">
<TextView
android:id="@+id/text_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Jornadas"
android:textSize="24sp"
android:textSize="28sp"
android:textStyle="bold"
android:textColor="@color/primary_color"
android:layout_marginBottom="16dp" />
<!-- Category Toggle -->
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/toggle_group_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
app:singleSelection="true"
app:selectionRequired="true"
app:checkedButton="@+id/btn_seniores">
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_seniores"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Seniores"
android:textAllCaps="false" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_juniores"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Juniores"
android:textAllCaps="false" />
</com.google.android.material.button.MaterialButtonToggleGroup>
<!-- Matchday Navigation -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:background="@drawable/bg_jornada_nav"
android:padding="8dp"
android:layout_marginBottom="16dp">
<ImageButton
android:id="@+id/btn_prev_jornada"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@android:drawable/ic_media_previous"
android:contentDescription="Anterior"
app:tint="@color/primary_color" />
<TextView
android:id="@+id/text_jornada_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Carregando..."
android:textSize="18sp"
android:textStyle="bold"
android:gravity="center"
android:textColor="@color/text_primary" />
<ImageButton
android:id="@+id/btn_next_jornada"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@android:drawable/ic_media_next"
android:contentDescription="Próxima"
app:tint="@color/primary_color" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_matchdays"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="16dp"/>
android:paddingBottom="16dp"
tools:listitem="@layout/item_match"/>
</LinearLayout>

View File

@@ -48,7 +48,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingVertical="8dp"
android:paddingVertical="10dp"
android:paddingHorizontal="8dp"
android:background="@drawable/bg_table_header">
@@ -56,10 +56,10 @@
android:layout_width="28dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="POS"
android:text="#"
android:textColor="@color/white"
android:textSize="10sp"
android:textStyle="normal" />
android:textSize="11sp"
android:textStyle="bold" />
<Space
android:layout_width="28dp"
@@ -71,8 +71,8 @@
android:layout_weight="1"
android:text="EQUIPA"
android:textColor="@color/white"
android:textSize="10sp"
android:textStyle="normal" />
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="24dp"
@@ -80,8 +80,8 @@
android:gravity="center"
android:text="J"
android:textColor="@color/white"
android:textSize="10sp"
android:textStyle="normal" />
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="24dp"
@@ -89,8 +89,8 @@
android:gravity="center"
android:text="V"
android:textColor="@color/white"
android:textSize="10sp"
android:textStyle="normal" />
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="24dp"
@@ -98,8 +98,8 @@
android:gravity="center"
android:text="E"
android:textColor="@color/white"
android:textSize="10sp"
android:textStyle="normal" />
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="24dp"
@@ -107,8 +107,8 @@
android:gravity="center"
android:text="D"
android:textColor="@color/white"
android:textSize="10sp"
android:textStyle="normal" />
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="26dp"
@@ -116,8 +116,8 @@
android:gravity="center"
android:text="DG"
android:textColor="@color/white"
android:textSize="10sp"
android:textStyle="normal" />
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="32dp"
@@ -125,8 +125,8 @@
android:gravity="center"
android:text="PTS"
android:textColor="@color/white"
android:textSize="10sp"
android:textStyle="normal" />
android:textSize="11sp"
android:textStyle="bold" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView

View File

@@ -1,30 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:padding="8dp">
android:padding="12dp"
android:layout_marginBottom="8dp"
android:background="@drawable/bg_match_item">
<!-- Home Team -->
<TextView
android:id="@+id/text_home_team"
<!-- Home Team Section -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:text="Home"
android:textStyle="bold"
android:textColor="@color/text_primary" />
android:gravity="center_vertical|end"
android:orientation="horizontal">
<!-- Score / Time -->
<TextView
android:id="@+id/text_home_team"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:text="Home"
android:textStyle="bold"
android:textColor="@color/text_primary"
android:layout_marginEnd="8dp" />
<ImageView
android:id="@+id/img_home_logo"
android:layout_width="24dp"
android:layout_height="24dp"
android:padding="2dp"
android:scaleType="centerInside"
android:src="@drawable/ic_club_placeholder" />
</LinearLayout>
<!-- Score / Time Section -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="12dp"
android:gravity="center"
android:orientation="vertical"
android:minWidth="60dp">
android:minWidth="70dp">
<TextView
android:id="@+id/text_score"
@@ -32,27 +52,44 @@
android:layout_height="wrap_content"
android:text="Vs"
android:textStyle="bold"
android:textColor="@color/secondary_color"
android:textSize="16sp" />
android:textColor="@color/primary_color"
android:textSize="18sp" />
<TextView
android:id="@+id/text_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="15:00"
android:textSize="12sp"
android:textSize="11sp"
android:textColor="@color/text_secondary" />
</LinearLayout>
<!-- Away Team -->
<TextView
android:id="@+id/text_away_team"
<!-- Away Team Section -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:text="Away"
android:textStyle="bold"
android:textColor="@color/text_primary" />
android:gravity="center_vertical|start"
android:orientation="horizontal">
<ImageView
android:id="@+id/img_away_logo"
android:layout_width="24dp"
android:layout_height="24dp"
android:padding="2dp"
android:scaleType="centerInside"
android:src="@drawable/ic_club_placeholder" />
<TextView
android:id="@+id/text_away_team"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:text="Away"
android:textStyle="bold"
android:textColor="@color/text_primary"
android:layout_marginStart="8dp" />
</LinearLayout>
</LinearLayout>

View File

@@ -7,7 +7,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingVertical="12dp"
android:paddingVertical="10dp"
android:paddingHorizontal="8dp"
android:gravity="center_vertical"
android:background="?attr/selectableItemBackground">
@@ -20,7 +20,7 @@
android:gravity="center"
android:text="1"
android:textColor="@color/white"
android:textSize="12sp"
android:textSize="11sp"
android:textStyle="bold"
android:background="@drawable/bg_circle_green" />
@@ -29,6 +29,7 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginHorizontal="2dp"
android:scaleType="centerInside"
android:src="@mipmap/ic_launcher" />
<TextView
@@ -37,7 +38,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Team Name"
android:textColor="@color/black"
android:textColor="@color/text_primary"
android:textSize="13sp"
android:textStyle="bold"
android:ellipsize="end"
@@ -49,7 +50,7 @@
android:layout_height="wrap_content"
android:gravity="center"
android:text="0"
android:textColor="@color/text_primary"
android:textColor="@color/text_secondary"
android:textSize="12sp" />
<TextView
@@ -58,7 +59,7 @@
android:layout_height="wrap_content"
android:gravity="center"
android:text="0"
android:textColor="@color/text_primary"
android:textColor="@color/text_secondary"
android:textSize="12sp" />
<TextView
@@ -67,7 +68,7 @@
android:layout_height="wrap_content"
android:gravity="center"
android:text="0"
android:textColor="@color/text_primary"
android:textColor="@color/text_secondary"
android:textSize="12sp" />
<TextView
@@ -76,7 +77,7 @@
android:layout_height="wrap_content"
android:gravity="center"
android:text="0"
android:textColor="@color/text_primary"
android:textColor="@color/text_secondary"
android:textSize="12sp" />
<TextView
@@ -85,7 +86,7 @@
android:layout_height="wrap_content"
android:gravity="center"
android:text="0"
android:textColor="@color/text_primary"
android:textColor="@color/text_secondary"
android:textSize="12sp" />
<TextView
@@ -95,7 +96,7 @@
android:gravity="center"
android:text="0"
android:textStyle="bold"
android:textColor="@color/black"
android:textColor="@color/text_primary"
android:textSize="13sp" />
</LinearLayout>

View File

@@ -9,7 +9,11 @@
android:id="@+id/nav_home"
android:name="com.example.vdcscore.ui.home.HomeFragment"
android:label="@string/menu_home"
tools:layout="@layout/fragment_home" />
tools:layout="@layout/fragment_home">
<action
android:id="@+id/action_nav_home_to_nav_club_detail"
app:destination="@id/nav_club_detail" />
</fragment>
<fragment
android:id="@+id/nav_gallery"