From 259e8bb0e15dac3f984e8bc4e64e63114396f2bf Mon Sep 17 00:00:00 2001 From: Emre KARTAL Date: Tue, 14 Mar 2023 21:36:57 +0100 Subject: [PATCH] Finish FavoritePage and beginning StubData :cyclone: --- src/app/src/main/AndroidManifest.xml | 3 - .../java/uca/iut/clermont/data/StubData.kt | 135 +++++++++++++----- .../main/java/uca/iut/clermont/model/Area.kt | 3 +- .../main/java/uca/iut/clermont/model/Coach.kt | 3 +- .../uca/iut/clermont/model/Competition.kt | 3 +- .../java/uca/iut/clermont/model/Personne.kt | 3 +- .../java/uca/iut/clermont/model/Player.kt | 3 +- .../java/uca/iut/clermont/model/Season.kt | 3 +- .../main/java/uca/iut/clermont/model/Staff.kt | 3 +- .../main/java/uca/iut/clermont/model/Team.kt | 5 +- .../uca/iut/clermont/view/FavoriteActivity.kt | 3 +- .../uca/iut/clermont/view/HomeActivity.kt | 8 ++ src/app/src/main/res/layout/activity_home.xml | 8 +- 13 files changed, 121 insertions(+), 62 deletions(-) diff --git a/src/app/src/main/AndroidManifest.xml b/src/app/src/main/AndroidManifest.xml index 84bfaf7..6a01fe5 100644 --- a/src/app/src/main/AndroidManifest.xml +++ b/src/app/src/main/AndroidManifest.xml @@ -14,9 +14,6 @@ android:supportsRtl="true" android:theme="@style/Theme.Scor_It" tools:targetApi="31"> - diff --git a/src/app/src/main/java/uca/iut/clermont/data/StubData.kt b/src/app/src/main/java/uca/iut/clermont/data/StubData.kt index c82c788..db9140e 100644 --- a/src/app/src/main/java/uca/iut/clermont/data/StubData.kt +++ b/src/app/src/main/java/uca/iut/clermont/data/StubData.kt @@ -7,42 +7,108 @@ import MatchesManager import PeopleManager import TeamsManager import uca.iut.clermont.model.* +import java.util.* class StubData: DataManager() { - override val areaMgr: AreaManager = StubAreaManager() - override val peopleMgr: PeopleManager = StubPeopleManager() + override val areaMgr: AreaManager = StubAreaManager(this) + override val peopleMgr: PeopleManager = StubPeopleManager(this) override val matchesMgr: MatchesManager = StubMatchesManager() override val competitionsMgr: CompetitionsManager = StubCompetitionsManager() - override val teamsMgr: TeamsManager = StubTeamsManager() - - class StubAreaManager : AreaManager { - override fun getItemsByName(substring: String): List { - TODO("Not yet implemented") - } - - override fun getItems(): List { - TODO("Not yet implemented") - } - - override fun getItemById(id: Int): Area? { - TODO("Not yet implemented") - } + override val teamsMgr: TeamsManager = StubTeamsManager(this) + + private val areaList = listOf( + Area(1, "France", "FRA", "https://crests.football-data.org/773.svg", "Europe"), + Area(2, "Spain", "ESP", "https://crests.football-data.org/760.svg", "Europe"), + Area(3, "Brazil", "BRA", "https://crests.football-data.org/764.svg", "South America"), + Area(4, "Mexico", "Mex", "https://crests.football-data.org/mexico.svg", "North America"), + Area(5, "Australia", "AUS", "https://australie-voyage.fr/wp-content/uploads/2020/08/Drapeau-australien.jpg", "Oceania") + ) + + private val peopleList = listOf( + Player(1, "Lionel", "Messi", "L. Messi", Date(1987, 6, 24), "Argentina", Contract(Date(2020, 6, 1), Date(2025, 6, 1)), "Forward", 10), + Player(2, "Cristiano", "Ronaldo", "C. Ronaldo", Date(1985, 2, 5), "Portugal", Contract(Date(2020, 7, 1), Date(2024, 7, 1)), "Forward", 7), + Player(3, "Neymar", "Jr", "Neymar", Date(1992, 2, 5), "Brazil", Contract(Date(2021, 1, 1), Date(2026, 1, 1)), "Forward", 10), + Player(4, "Kylian", "Mbappe", "K. Mbappe", Date(1998, 12, 20), "France", Contract(Date(2022, 1, 1), Date(2027, 1, 1)), "Forward", 7), + Player(5, "Mohamed", "Salah", "M. Salah", Date(1992, 6, 15), "Egypt", Contract(Date(2021, 7, 1), Date(2025, 7, 1)), "Forward", 11), + Player(6, "Kevin", "De Bruyne", "K. De Bruyne", Date(1991, 6, 28), "Belgium", Contract(Date(2021, 8, 1), Date(2026, 8, 1)), "Midfielder", 17), + Player(7, "Robert", "Lewandowski", "R. Lewandowski", Date(1988, 8, 21), "Poland", Contract(Date(2021, 1, 1), Date(2024, 1, 1)), "Forward", 9), + Player(8, "Sadio", "Mane", "S. Mane", Date(1992, 4, 10), "Senegal", Contract(Date(2022, 1, 1), Date(2026, 1, 1)), "Forward", 10), + Player(9, "Virgil", "Van Dijk", "V. Van Dijk", Date(1991, 7, 8), "Netherlands", Contract(Date(2023, 1, 1), Date(2026, 1, 1)), "Defender", 4), + Player(10, "Luka", "Modric", "L. Modric", Date(1985, 9, 9), "Croatia", Contract(Date(2020, 6, 1), Date(2022, 6, 1)), "Midfielder", 10), + Player(11, "Harry", "Kane", "H. Kane", Date(1993, 7, 28), "England", Contract(Date(2021, 7, 1), Date(2025, 7, 1)), "Forward", 10), + Player(12, "Sergio", "Aguero", "S. Aguero", Date(1988, 6, 2), "Argentina", Contract(Date(2021, 6, 1), Date(2023, 6, 1)), "Forward", 10), + Player(13, "Eden", "Hazard", "E. Hazard", Date(1991, 1, 7), "Belgium", Contract(Date(2022, 1, 1), Date(2027, 1, 1)), "Forward", 7), + Coach(14, "Pep", "Guardiola", "P. Guardiola", Date(1971, 1, 18), "Spain", Contract(Date(2020, 6, 1), Date(2023, 6, 1))), + Coach(15, "Jurgen", "Klopp", "J. Klopp", Date(1967, 6, 16), "Germany", Contract(Date(2020, 7, 1), Date(2024, 7, 1))), + Staff(16, "Jorge", "Desio", "J. Desio", Date(1966, 1, 1), "Argentina", Contract(Date(2020, 6, 1), Date(2023, 6, 1))), + Staff(17, "Craig", "Mawson", "C. Mawson", Date(1973, 8, 22), "England", Contract(Date(2020, 7, 1), Date(2024, 7, 1))) + ) + private val teamList = listOf( + Team( + 1, + "Paris Saint-Germain FC", + "PSG", + "https://crests.football-data.org/524.svg", + "24 Rue du Commandant Guilbaud, 75016 Paris, France", + "https://www.psg.fr/", + "1970", + "Navy / Red", + areaList[0], + "Parc des Princes", + peopleList[0] as Coach, + listOf(peopleList[2] as Staff), + listOf(peopleList[0] as Player, peopleList[3] as Player, peopleList[11] as Player) + ), + Team( + 2, + "FC Barcelona", + "BAR", + "https://crests.football-data.org/81.svg", + "Carrer d'Aristides Maillol, s/n, 08028 Barcelona, Spain", + "https://www.fcbarcelona.com/", + "1899", + "Blue / Red", + areaList[3], + "Camp Nou", + peopleList[0] as Coach, + listOf(peopleList[2] as Staff), + listOf(peopleList[0] as Player, peopleList[5] as Player, peopleList[9] as Player) + ), + Team( + 3, + "Liverpool FC", + "LIV", + "https://crests.football-data.org/64.svg", + "Anfield Road, Liverpool L4 0TH, United Kingdom", + "https://www.liverpoolfc.com/", + "1892", + "Red", + areaList[2], + "Anfield", + peopleList[1] as Coach, + listOf(peopleList[3] as Staff), + listOf(peopleList[7] as Player, peopleList[8] as Player, peopleList[10] as Player) + ) + ) + + + class StubAreaManager(private val parent: StubData) : AreaManager { + override fun getItemsByName(substring: String) = + parent.areaList.filter { it.name.contains(substring, ignoreCase = true) } + + override fun getItems(): List = parent.areaList + + override fun getItemById(id: Int) = parent.areaList.find { it.id == id } } - class StubPeopleManager : PeopleManager { - override fun getItemsByName(substring: String): List { - TODO("Not yet implemented") - } - - override fun getItems(): List { - TODO("Not yet implemented") - } + class StubPeopleManager(private val parent: StubData) : PeopleManager { + override fun getItemsByName(substring: String) = + parent.peopleList.filter { it.name.contains(substring, ignoreCase = true) } - override fun getItemById(id: Int): Personne? { - TODO("Not yet implemented") - } + override fun getItems() = parent.peopleList + override fun getItemById(id: Int) = parent.peopleList.find { it.id == id } } class StubMatchesManager : MatchesManager { @@ -75,18 +141,13 @@ class StubData: DataManager() { } - class StubTeamsManager : TeamsManager { - override fun getItemsByName(substring: String): List { - TODO("Not yet implemented") - } + class StubTeamsManager(private val parent: StubData) : TeamsManager { + override fun getItemsByName(substring: String) = + parent.teamList.filter { it.name.contains(substring, ignoreCase = true) } - override fun getItems(): List { - TODO("Not yet implemented") - } + override fun getItems() = parent.teamList - override fun getItemById(id: Int): Team? { - TODO("Not yet implemented") - } + override fun getItemById(id: Int) = parent.teamList.find { it.id == id } } } \ No newline at end of file diff --git a/src/app/src/main/java/uca/iut/clermont/model/Area.kt b/src/app/src/main/java/uca/iut/clermont/model/Area.kt index 313d771..eecbec5 100644 --- a/src/app/src/main/java/uca/iut/clermont/model/Area.kt +++ b/src/app/src/main/java/uca/iut/clermont/model/Area.kt @@ -6,5 +6,4 @@ class Area( val code: String, val flag: String, val parentArea: String -) { -} \ No newline at end of file +) \ No newline at end of file diff --git a/src/app/src/main/java/uca/iut/clermont/model/Coach.kt b/src/app/src/main/java/uca/iut/clermont/model/Coach.kt index 1eac986..6c03a15 100644 --- a/src/app/src/main/java/uca/iut/clermont/model/Coach.kt +++ b/src/app/src/main/java/uca/iut/clermont/model/Coach.kt @@ -10,5 +10,4 @@ class Coach( dateOfBirth: Date, nationality: String, contract: Contract -) : Personne(id, firstName, lastName, name, dateOfBirth, nationality, contract) { -} \ No newline at end of file +) : Personne(id, firstName, lastName, name, dateOfBirth, nationality, contract) \ No newline at end of file diff --git a/src/app/src/main/java/uca/iut/clermont/model/Competition.kt b/src/app/src/main/java/uca/iut/clermont/model/Competition.kt index 81eda26..103a57a 100644 --- a/src/app/src/main/java/uca/iut/clermont/model/Competition.kt +++ b/src/app/src/main/java/uca/iut/clermont/model/Competition.kt @@ -8,5 +8,4 @@ class Competition( val emblem: String, val currentSeason: Season, val area: Area -) { -} \ No newline at end of file +) \ No newline at end of file diff --git a/src/app/src/main/java/uca/iut/clermont/model/Personne.kt b/src/app/src/main/java/uca/iut/clermont/model/Personne.kt index 79985a5..af00497 100644 --- a/src/app/src/main/java/uca/iut/clermont/model/Personne.kt +++ b/src/app/src/main/java/uca/iut/clermont/model/Personne.kt @@ -10,5 +10,4 @@ abstract class Personne( val dateOfBirth: Date, val nationality: String, val contract: Contract -) { -} \ No newline at end of file +) \ No newline at end of file diff --git a/src/app/src/main/java/uca/iut/clermont/model/Player.kt b/src/app/src/main/java/uca/iut/clermont/model/Player.kt index 406f0ef..8fbc3bc 100644 --- a/src/app/src/main/java/uca/iut/clermont/model/Player.kt +++ b/src/app/src/main/java/uca/iut/clermont/model/Player.kt @@ -12,5 +12,4 @@ class Player( contract: Contract, val position: String, val shirtNumber: Int -) : Personne(id, firstName, lastName, name, dateOfBirth, nationality, contract) { -} \ No newline at end of file +) : Personne(id, firstName, lastName, name, dateOfBirth, nationality, contract) \ No newline at end of file diff --git a/src/app/src/main/java/uca/iut/clermont/model/Season.kt b/src/app/src/main/java/uca/iut/clermont/model/Season.kt index e991765..d414d77 100644 --- a/src/app/src/main/java/uca/iut/clermont/model/Season.kt +++ b/src/app/src/main/java/uca/iut/clermont/model/Season.kt @@ -8,5 +8,4 @@ class Season( val endDate: Date, val currentMatchday: Int, val winner: Int -) { -} \ No newline at end of file +) \ No newline at end of file diff --git a/src/app/src/main/java/uca/iut/clermont/model/Staff.kt b/src/app/src/main/java/uca/iut/clermont/model/Staff.kt index b346f5b..f169843 100644 --- a/src/app/src/main/java/uca/iut/clermont/model/Staff.kt +++ b/src/app/src/main/java/uca/iut/clermont/model/Staff.kt @@ -10,5 +10,4 @@ class Staff( dateOfBirth: Date, nationality: String, contract: Contract -) : Personne(id, firstName, lastName, name, dateOfBirth, nationality, contract) { -} \ No newline at end of file +) : Personne(id, firstName, lastName, name, dateOfBirth, nationality, contract) \ No newline at end of file diff --git a/src/app/src/main/java/uca/iut/clermont/model/Team.kt b/src/app/src/main/java/uca/iut/clermont/model/Team.kt index eff8b4d..18b41bb 100644 --- a/src/app/src/main/java/uca/iut/clermont/model/Team.kt +++ b/src/app/src/main/java/uca/iut/clermont/model/Team.kt @@ -12,7 +12,6 @@ class Team( val area: Area, val venue: String, val coach: Coach, - val staff: Staff, + val staff: List, val squads: List -) { -} \ No newline at end of file +) \ No newline at end of file diff --git a/src/app/src/main/java/uca/iut/clermont/view/FavoriteActivity.kt b/src/app/src/main/java/uca/iut/clermont/view/FavoriteActivity.kt index 334a460..524bec6 100644 --- a/src/app/src/main/java/uca/iut/clermont/view/FavoriteActivity.kt +++ b/src/app/src/main/java/uca/iut/clermont/view/FavoriteActivity.kt @@ -2,8 +2,9 @@ package uca.iut.clermont.view import androidx.appcompat.app.AppCompatActivity import android.os.Bundle +import uca.iut.clermont.R -class FavoriteActivity : Activity() { +class FavoriteActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_favorite) diff --git a/src/app/src/main/java/uca/iut/clermont/view/HomeActivity.kt b/src/app/src/main/java/uca/iut/clermont/view/HomeActivity.kt index c21e90d..99e9495 100644 --- a/src/app/src/main/java/uca/iut/clermont/view/HomeActivity.kt +++ b/src/app/src/main/java/uca/iut/clermont/view/HomeActivity.kt @@ -2,12 +2,20 @@ package uca.iut.clermont.view import android.app.Activity import android.os.Bundle +import android.widget.ImageView +import com.bumptech.glide.Glide import uca.iut.clermont.R class HomeActivity : Activity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_home) + val imageFirstTeam = findViewById(R.id.ImageFirstTeam) + + Glide.with(this) + .load("https://crests.football-data.org/1765.svg") + .error(R.drawable.imagenotfound) + .into(imageFirstTeam) } } \ No newline at end of file diff --git a/src/app/src/main/res/layout/activity_home.xml b/src/app/src/main/res/layout/activity_home.xml index 36318b1..ba9b5aa 100644 --- a/src/app/src/main/res/layout/activity_home.xml +++ b/src/app/src/main/res/layout/activity_home.xml @@ -119,8 +119,8 @@ + android:layout_width="60dp" + android:layout_height="60dp" /> + android:layout_width="60dp" + android:layout_height="60dp" />