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