adicao das jornadas e dos melhores marcadores (falta dar scrapping aos melhores marcadores)

This commit is contained in:
2026-04-24 16:03:24 +01:00
parent d567f548aa
commit ce16ff59b6
9 changed files with 71 additions and 1 deletions

View File

@@ -70,7 +70,7 @@ public class MainActivity extends AppCompatActivity {
// menu should be considered as top level destinations. // menu should be considered as top level destinations.
mAppBarConfiguration = new AppBarConfiguration.Builder( mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.nav_home, R.id.nav_gallery, R.id.nav_definicoes, R.id.nav_home, R.id.nav_gallery, R.id.nav_definicoes,
R.id.nav_live_games, R.id.nav_clubs) R.id.nav_live_games, R.id.nav_clubs, R.id.nav_top_scorers)
.setOpenableLayout(drawer) .setOpenableLayout(drawer)
.build(); .build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main); NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main);

View File

@@ -19,6 +19,8 @@ import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener; import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
public class GalleryFragment extends Fragment { public class GalleryFragment extends Fragment {
@@ -106,6 +108,20 @@ public class GalleryFragment extends Fragment {
} }
} }
// Sort matchdays numerically (e.g. "1" before "10")
Collections.sort(matchdaysList, new Comparator<Matchday>() {
@Override
public int compare(Matchday m1, Matchday m2) {
try {
Integer num1 = Integer.parseInt(m1.getName());
Integer num2 = Integer.parseInt(m2.getName());
return num1.compareTo(num2);
} catch (NumberFormatException e) {
return m1.getName().compareTo(m2.getName());
}
}
});
if (matchdaysList.isEmpty()) { if (matchdaysList.isEmpty()) {
binding.textJornadaName.setText("Sem jornadas"); binding.textJornadaName.setText("Sem jornadas");
adapter.setMatches(new ArrayList<>()); adapter.setMatches(new ArrayList<>());

View File

@@ -13,6 +13,7 @@ public class Match {
private String homeLogo; private String homeLogo;
private String awayLogo; private String awayLogo;
private String stadium; private String stadium;
private String matchReportUrl;
public Match() { public Match() {
} }
@@ -184,4 +185,14 @@ public class Match {
public void setStadium(String stadium) { public void setStadium(String stadium) {
this.stadium = stadium; this.stadium = stadium;
} }
@PropertyName("matchReportUrl")
public String getMatchReportUrl() {
return matchReportUrl;
}
@PropertyName("matchReportUrl")
public void setMatchReportUrl(String matchReportUrl) {
this.matchReportUrl = matchReportUrl;
}
} }

View File

@@ -12,6 +12,8 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.example.vdcscore.R; import com.example.vdcscore.R;
import android.content.Intent;
import android.net.Uri;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -87,6 +89,18 @@ public class MatchesAdapter extends RecyclerView.Adapter<MatchesAdapter.ViewHold
// Stadium // Stadium
String stadium = match.getStadium(); String stadium = match.getStadium();
holder.textStadium.setText(isValid(stadium) ? "Campo: " + stadium : "Campo a definir"); holder.textStadium.setText(isValid(stadium) ? "Campo: " + stadium : "Campo a definir");
// Match Report Button
if (isValid(match.getMatchReportUrl())) {
holder.btnMatchReport.setVisibility(View.VISIBLE);
holder.btnMatchReport.setOnClickListener(v -> {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(match.getMatchReportUrl()));
holder.itemView.getContext().startActivity(browserIntent);
});
} else {
holder.btnMatchReport.setVisibility(View.GONE);
holder.btnMatchReport.setOnClickListener(null);
}
} }
private boolean isValid(String text) { private boolean isValid(String text) {
@@ -107,6 +121,7 @@ public class MatchesAdapter extends RecyclerView.Adapter<MatchesAdapter.ViewHold
public final TextView textStadium; public final TextView textStadium;
public final ImageView imgHomeLogo; public final ImageView imgHomeLogo;
public final ImageView imgAwayLogo; public final ImageView imgAwayLogo;
public final com.google.android.material.button.MaterialButton btnMatchReport;
public ViewHolder(View view) { public ViewHolder(View view) {
super(view); super(view);
@@ -118,6 +133,7 @@ public class MatchesAdapter extends RecyclerView.Adapter<MatchesAdapter.ViewHold
textStadium = view.findViewById(R.id.text_match_stadium); textStadium = view.findViewById(R.id.text_match_stadium);
imgHomeLogo = view.findViewById(R.id.img_home_logo); imgHomeLogo = view.findViewById(R.id.img_home_logo);
imgAwayLogo = view.findViewById(R.id.img_away_logo); imgAwayLogo = view.findViewById(R.id.img_away_logo);
btnMatchReport = view.findViewById(R.id.btn_match_report);
} }
} }
} }

View File

@@ -153,6 +153,17 @@
</LinearLayout> </LinearLayout>
<!-- Match Report Button -->
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_match_report"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Ficha de Jogo"
android:visibility="gone"
app:cornerRadius="8dp" />
</LinearLayout> </LinearLayout>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>

View File

@@ -24,5 +24,9 @@
android:id="@+id/nav_definicoes" android:id="@+id/nav_definicoes"
android:icon="@android:drawable/ic_menu_preferences" android:icon="@android:drawable/ic_menu_preferences"
android:title="@string/menu_definicoes" /> android:title="@string/menu_definicoes" />
<item
android:id="@+id/nav_top_scorers"
android:icon="@android:drawable/btn_star"
android:title="@string/menu_top_scorers" />
</group> </group>
</menu> </menu>

View File

@@ -96,4 +96,10 @@
app:argType="com.example.vdcscore.models.Player" /> app:argType="com.example.vdcscore.models.Player" />
</fragment> </fragment>
<fragment
android:id="@+id/nav_top_scorers"
android:name="com.example.vdcscore.ui.topscorers.TopScorersFragment"
android:label="@string/menu_top_scorers"
tools:layout="@layout/fragment_top_scorers" />
</navigation> </navigation>

View File

@@ -14,6 +14,7 @@
<string name="menu_live_games">Jogos ao Vivo</string> <string name="menu_live_games">Jogos ao Vivo</string>
<string name="title_live_game_detail">Detalhes do Jogo</string> <string name="title_live_game_detail">Detalhes do Jogo</string>
<string name="menu_clubs">Clubes</string> <string name="menu_clubs">Clubes</string>
<string name="menu_top_scorers">Melhores Marcadores</string>
<!-- Profile Strings --> <!-- Profile Strings -->
<string name="change_photo_title">Alterar Foto de Perfil</string> <string name="change_photo_title">Alterar Foto de Perfil</string>

View File

@@ -33,4 +33,9 @@
<style name="Theme.VdcScore.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="Theme.VdcScore.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="Theme.VdcScore.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> <style name="Theme.VdcScore.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="ShapeAppearanceOverlay.App.CornerSize50Percent" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>
</resources> </resources>