mudancas desgin

This commit is contained in:
2026-03-10 16:46:25 +00:00
parent 17ab677589
commit 3733e027ae
7 changed files with 202 additions and 45 deletions

View File

@@ -19,7 +19,7 @@ public class Club implements Serializable {
@PropertyName("campo")
private String stadium;
@PropertyName("ano fundacao")
@PropertyName("ano_fundacao")
private int foundationYear;
@PropertyName("morada")
@@ -83,12 +83,12 @@ public class Club implements Serializable {
this.stadium = stadium;
}
@PropertyName("ano fundacao")
@PropertyName("ano_fundacao")
public int getFoundationYear() {
return foundationYear;
}
@PropertyName("ano fundacao")
@PropertyName("ano_fundacao")
public void setFoundationYear(int foundationYear) {
this.foundationYear = foundationYear;
}

View File

@@ -82,7 +82,12 @@ public class ClubPlayersFragment extends Fragment {
}
if (!playerList.isEmpty()) {
PlayerAdapter adapter = new PlayerAdapter(playerList);
PlayerAdapter adapter = new PlayerAdapter(playerList, player -> {
android.os.Bundle bundle = new android.os.Bundle();
bundle.putSerializable("jogador_selecionado", player);
androidx.navigation.Navigation.findNavController(requireView()).navigate(
com.example.vdcscore.R.id.action_nav_club_players_to_nav_player_detail, bundle);
});
binding.recyclerPlayersList.setAdapter(adapter);
binding.textNoPlayers.setVisibility(View.GONE);
} else {

View File

@@ -19,9 +19,15 @@ import java.util.List;
public class PlayerAdapter extends RecyclerView.Adapter<PlayerAdapter.PlayerViewHolder> {
private final List<Player> mPlayers;
private final OnItemClickListener listener;
public PlayerAdapter(List<Player> players) {
mPlayers = players;
public interface OnItemClickListener {
void onItemClick(Player player);
}
public PlayerAdapter(List<Player> players, OnItemClickListener listener) {
this.mPlayers = players;
this.listener = listener;
}
@NonNull
@@ -35,7 +41,7 @@ public class PlayerAdapter extends RecyclerView.Adapter<PlayerAdapter.PlayerView
@Override
public void onBindViewHolder(@NonNull PlayerViewHolder holder, int position) {
Player player = mPlayers.get(position);
holder.bind(player);
holder.bind(player, listener);
}
@Override
@@ -45,33 +51,18 @@ public class PlayerAdapter extends RecyclerView.Adapter<PlayerAdapter.PlayerView
static class PlayerViewHolder extends RecyclerView.ViewHolder {
private final TextView name;
private final TextView details;
private final ImageView photo;
public PlayerViewHolder(@NonNull View itemView) {
super(itemView);
name = itemView.findViewById(R.id.text_player_name);
details = itemView.findViewById(R.id.text_player_details);
photo = itemView.findViewById(R.id.image_player_icon);
}
public void bind(Player player) {
public void bind(Player player, OnItemClickListener listener) {
if (player != null) {
name.setText(player.getNome());
String detailsText = "";
if (player.getNaturalidade() != null && !player.getNaturalidade().isEmpty()) {
detailsText += player.getNaturalidade() + " ";
}
if (player.getDataNascimento() != null && !player.getDataNascimento().isEmpty()) {
detailsText += " | " + player.getDataNascimento();
}
if (details != null) {
details.setText(detailsText.trim().startsWith("|") ? detailsText.replaceFirst("\\|", "").trim()
: detailsText.trim());
}
if (player.getFoto() != null && !player.getFoto().isEmpty()) {
Glide.with(itemView.getContext())
.load(player.getFoto())
@@ -82,6 +73,12 @@ public class PlayerAdapter extends RecyclerView.Adapter<PlayerAdapter.PlayerView
} else {
photo.setImageResource(R.drawable.ic_menu_camera);
}
itemView.setOnClickListener(v -> {
if (listener != null) {
listener.onItemClick(player);
}
});
}
}
}

View File

@@ -0,0 +1,62 @@
package com.example.vdcscore.ui.clubs;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.bumptech.glide.Glide;
import com.example.vdcscore.R;
import com.example.vdcscore.databinding.FragmentPlayerDetailBinding;
import com.example.vdcscore.models.Player;
public class PlayerDetailFragment extends Fragment {
private FragmentPlayerDetailBinding binding;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
binding = FragmentPlayerDetailBinding.inflate(inflater, container, false);
return binding.getRoot();
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (getArguments() != null) {
Player jogadorRecebido = (Player) getArguments().getSerializable("jogador_selecionado");
if (jogadorRecebido != null) {
binding.textDetailPlayerName.setText(jogadorRecebido.getNome());
String birthDate = jogadorRecebido.getDataNascimento();
binding.textDetailBirthdate.setText(birthDate != null && !birthDate.isEmpty() ? birthDate : "N/D");
String birthplace = jogadorRecebido.getNaturalidade();
binding.textDetailBirthplace.setText(birthplace != null && !birthplace.isEmpty() ? birthplace : "N/D");
if (getContext() != null) {
Glide.with(this)
.load(jogadorRecebido.getFoto())
.placeholder(R.drawable.ic_menu_camera)
.error(R.drawable.ic_menu_camera)
.circleCrop()
.into(binding.imageDetailPlayerPhoto);
}
}
}
}
@Override
public void onDestroyView() {
super.onDestroyView();
binding = null;
}
}

View File

@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
android:background="#FAFAFA"
tools:context=".ui.clubs.PlayerDetailFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal"
android:padding="24dp">
<ImageView
android:id="@+id/image_detail_player_photo"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginTop="24dp"
android:contentDescription="Player Photo"
android:src="@drawable/ic_menu_camera"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/text_detail_player_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Player Name"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="24sp"
android:textStyle="bold" />
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
app:cardCornerRadius="12dp"
app:cardElevation="2dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Data de Nascimento"
android:textColor="#888888"
android:textSize="14sp" />
<TextView
android:id="@+id/text_detail_birthdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="N/D"
android:textColor="@color/black"
android:textSize="16sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:background="#EEEEEE" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Naturalidade"
android:textColor="#888888"
android:textSize="14sp" />
<TextView
android:id="@+id/text_detail_birthplace"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="N/D"
android:textColor="@color/black"
android:textSize="16sp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</ScrollView>

View File

@@ -15,30 +15,14 @@
android:contentDescription="Player Icon"
android:layout_marginEnd="16dp"/>
<LinearLayout
<TextView
android:id="@+id/text_player_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/text_player_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Player Name"
android:textSize="16sp"
android:textColor="@color/black"
android:textStyle="bold" />
<TextView
android:id="@+id/text_player_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Details"
android:textSize="12sp"
android:textColor="#555555"
android:layout_marginTop="2dp" />
</LinearLayout>
android:text="Player Name"
android:textSize="16sp"
android:textColor="@color/black"
android:textStyle="bold" />
</LinearLayout>

View File

@@ -76,6 +76,20 @@
<argument
android:name="escalao"
app:argType="string" />
<action
android:id="@+id/action_nav_club_players_to_nav_player_detail"
app:destination="@id/nav_player_detail" />
</fragment>
<fragment
android:id="@+id/nav_player_detail"
android:name="com.example.vdcscore.ui.clubs.PlayerDetailFragment"
android:label="Detalhes do Jogador"
tools:layout="@layout/fragment_player_detail">
<argument
android:name="jogador_selecionado"
app:argType="com.example.vdcscore.models.Player" />
</fragment>
</navigation>