correcao de erros
This commit is contained in:
7
.idea/misc.xml
generated
7
.idea/misc.xml
generated
@@ -6,4 +6,11 @@
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
<component name="VisualizationToolProject">
|
||||
<option name="state">
|
||||
<ProjectState>
|
||||
<option name="scale" value="0.2492626953125" />
|
||||
</ProjectState>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@@ -2,9 +2,11 @@ package com.example.vdcscore.models;
|
||||
|
||||
import com.google.firebase.database.PropertyName;
|
||||
import java.util.ArrayList;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class Club {
|
||||
|
||||
public class Club implements Serializable {
|
||||
@PropertyName("id")
|
||||
private int id;
|
||||
|
||||
|
||||
@@ -47,51 +47,38 @@ public class ClubDetailFragment extends Fragment {
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
if (clubId != null) {
|
||||
mDatabase = FirebaseDatabase.getInstance().getReference().child("clubes").child(clubId);
|
||||
loadClubDetails();
|
||||
}
|
||||
// Verificar se vieram argumentos do Adapter
|
||||
if (getArguments() != null) {
|
||||
// Receber o objeto Club inteiro
|
||||
Club clubeRecebido = (Club) getArguments().getSerializable("clube_selecionado");
|
||||
|
||||
binding.btnPlayers.setOnClickListener(v -> {
|
||||
if (clubId != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("clubId", clubId);
|
||||
Navigation.findNavController(view).navigate(R.id.action_nav_club_detail_to_nav_club_players, bundle);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (clubeRecebido != null) {
|
||||
// Preencher os dados usando o binding
|
||||
binding.textDetailClubName.setText(clubeRecebido.getName());
|
||||
binding.textDetailPresident.setText(clubeRecebido.getPresident());
|
||||
binding.textDetailAddress.setText(clubeRecebido.getAddress());
|
||||
binding.textDetailFoundation.setText(String.valueOf(clubeRecebido.getFoundationYear()));
|
||||
|
||||
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
|
||||
|
||||
// binding.imageDetailLogo.setImageResource(R.mipmap.ic_launcher_round);
|
||||
// Carregar imagem
|
||||
if (getContext() != null) {
|
||||
Glide.with(ClubDetailFragment.this)
|
||||
.load(club.getImageUrl())
|
||||
Glide.with(this)
|
||||
.load(clubeRecebido.getImageUrl())
|
||||
.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();
|
||||
}
|
||||
}
|
||||
// Configurar botão de jogadores
|
||||
binding.btnPlayers.setOnClickListener(v -> {
|
||||
Bundle bundle = new Bundle();
|
||||
// Passando o ID como String, garantindo compatibilidade
|
||||
bundle.putString("clubId", String.valueOf(clubeRecebido.getId()));
|
||||
Navigation.findNavController(view).navigate(R.id.action_nav_club_detail_to_nav_club_players,
|
||||
bundle);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
|
||||
@@ -45,6 +45,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/nav_header_subtitle"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"/>
|
||||
android:textColor="@color/background_light"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user