Compare commits

..

No commits in common. 'master' and 'HorizontalView' have entirely different histories.

@ -8,17 +8,12 @@ trigger:
steps:
- name: code-analysis
image: openjdk:8-jdk
image: androidsdk/android-31
environment:
SONAR_TOKEN:
from_secret: SECRET_TOKEN
SONAR_TOKEN:
from_secret: SECRET_TOKEN
settings:
sources: ./src/
sources: ./src/
commands:
- export SONAR_SCANNER_VERSION=4.7.0.2747
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
- export SONAR_SCANNER_OPTS="-server"
- sonar-scanner -D sonar.projectKey=Scor_It -D sonar.sources=./src -D sonar.host.url=https://codefirst.iut.uca.fr/sonar
- cd src
- ./gradlew --no-daemon :app:assembleDebug sonarqube -Dsonar.projectKey=Scor_It -Dsonar.host.url=https://codefirst.iut.uca.fr/sonar -Dsonar.login=$${SONAR_TOKEN}

@ -216,56 +216,6 @@ StubManager --|> DataManager
@enduml
```
## Visuel de l'Application
<div align = center>
<img src="doc/Images/StartPage.jpg" width="250" >
<img src="doc/Images/HomePage.jpg" width="250" >
<img src="doc/Images/FavoritePage.jpg" width="250" >
<img src="doc/Images/DetailCompetitionPage.jpg" width="250" >
</div>
## Avancement du projet
<u>Où en sommes-nous</u>:grey_question::grey_exclamation: (:white_check_mark: réalisé, :warning: presque abouti, :x: non commencé )
```Côté vue:```
- :white_check_mark: [**Partie 1**](src) : **Réalisation de la vue Start Page**
- :white_check_mark: [**Partie 2**](src) : **Réalisation de la vue Home Page**
- :white_check_mark: [**Partie 3**](src) : **Réalisation de la vue Favorite Page**
- :white_check_mark: [**Partie 4**](src) : **Réalisation de la vue Detail Competition Page**
- :x: [**Partie 5**](src) : **Réalisation de la vue Team Detail Page**
```Côté back-end:```
- :white_check_mark: [**Partie 1**](src) : **Réalisation de la navigation entre les fragments**
- :white_check_mark: [**Partie 2**](src) : **Master Detail**
- :white_check_mark: [**Partie 3**](src) : **Appelle à l'API**
- :white_check_mark: [**Partie 4**](src) : **Gyroscope pour le ballon de foot**
- :white_check_mark: [**Partie 5**](doc) : **Conception et réalisation du Model**
- :warning: [**Partie 6**](src) : **Persistance des donnéees**
- :x: [**Partie 7**](src) : **Réalisation de la barre de recherche**
- :x: [**Partie 8**](src) : **Affichage des images SVG**
```Autre:```
- :white_check_mark: [**Partie 1**](.drone.yml) : **Mise en place de SonarQube**
## :construction_worker: Technicien en charge de l'application
- Emre KARTAL : Emre.KARTAL@etu.uca.fr
@ -274,7 +224,7 @@ StubManager --|> DataManager
<a href = "https://codefirst.iut.uca.fr/git/emre.kartal">
<img src="https://codefirst.iut.uca.fr/git/avatars/402cf312e853192f42c0135a888725c2?size=870" width="50" >
</a>
<a href = "https://codefirst.iut.uca.fr/git/baptiste.marcel">
<a href = "https://codefirst.iut.uca.fr/git/david.d_almeida">
<img src="https://codefirst.iut.uca.fr/git/avatars/6b1f2a8b8f636d8f4d315b060075578f?size=870" width="50" >
</a>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

@ -32,25 +32,17 @@ android {
}
}
apply plugin: 'kotlin-kapt'
dependencies {
// Navigation
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
// Glide
//Glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
implementation 'com.caverock:androidsvg:1.4'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
// Room
implementation 'androidx.room:room-runtime:2.5.1'
implementation 'androidx.room:room-ktx:2.5.1'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

@ -1,119 +0,0 @@
package uca.iut.clermont.api
import AreaManager
import CompetitionsManager
import DataManager
import MatchesManager
import PeopleManager
import TeamsManager
import kotlinx.coroutines.coroutineScope
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import uca.iut.clermont.model.*
val retrofit: Retrofit = Retrofit.Builder()
.baseUrl("https://api.football-data.org/v4/")
.addConverterFactory(GsonConverterFactory.create())
.build()
val footballApi: FootballApi = retrofit.create(FootballApi::class.java)
class ApiManager : DataManager() {
override val areaMgr: AreaManager = ApiAreaManager()
override val peopleMgr: PeopleManager = ApiPeopleManager()
override val matchesMgr: MatchesManager = ApiMatchesManager()
override val competitionsMgr: CompetitionsManager = ApiCompetitionsManager()
override val teamsMgr: TeamsManager = ApiTeamsManager()
class ApiAreaManager : AreaManager {
override suspend fun getItemsByName(substring: String): List<Area> = coroutineScope {
val areas = footballApi.getAreas()
return@coroutineScope areas.areas.filter { it.name.contains(substring) }
}
override suspend fun getItems(): List<Area> = coroutineScope {
val areas = footballApi.getAreas()
return@coroutineScope areas.areas
}
override suspend fun getItemById(id: Int): Area = coroutineScope {
val area = footballApi.getArea(id)
return@coroutineScope area
}
}
class ApiPeopleManager : PeopleManager {
override suspend fun getItems(): List<Personne> = listOf()
override suspend fun getItemById(id: Int): Personne? = coroutineScope {
val personne = footballApi.getPlayer(id)
return@coroutineScope personne.toModel()
}
}
class ApiMatchesManager : MatchesManager {
override suspend fun getNbItemsByCompetition(id: Int): Int = coroutineScope {
val matches = footballApi.getMatchesByCompetition(id)
return@coroutineScope matches.matches.size
}
override suspend fun getItemsByCompetition(id: Int): List<Match> =
coroutineScope {
val matches = footballApi.getMatchesByCompetition(id)
return@coroutineScope matches.matches.map { it.toModel() }
}
override suspend fun getItems(): List<Match> = coroutineScope {
val matches = footballApi.getMatches()
return@coroutineScope matches.matches.map { matchResult -> matchResult.toModel() }
}
override suspend fun getItemById(id: Int): Match = coroutineScope {
val match = footballApi.getMatch(id)
return@coroutineScope match.toModel()
}
}
class ApiCompetitionsManager : CompetitionsManager {
override suspend fun getItemsByName(substring: String): List<Competition> = coroutineScope {
val competitons = footballApi.getCompetitions()
return@coroutineScope competitons.competitions.map { competitionResult -> competitionResult.toModel() }
.filter { it.name == substring }
}
override suspend fun getItems(): List<Competition> = coroutineScope {
val competitons = footballApi.getCompetitions()
return@coroutineScope competitons.competitions.map { competitionResult -> competitionResult.toModel() }
.sortedBy { it.name }
}
override suspend fun getItemById(id: Int): Competition = coroutineScope {
val competition = footballApi.getCompetition(id)
return@coroutineScope competition.toModel()
}
}
class ApiTeamsManager : TeamsManager {
override fun getItemsByName(substring: String): List<Team> {
TODO("Not yet implemented")
}
override suspend fun getItems(): List<Team> {
TODO("Not yet implemented")
}
override suspend fun getItemById(id: Int): Team? {
TODO("Not yet implemented")
}
}
}

@ -1,48 +0,0 @@
package uca.iut.clermont.api
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.Path
import uca.iut.clermont.api.response.areaResponse.AreaResponse
import uca.iut.clermont.api.response.competitionResponse.CompetitionResponse
import uca.iut.clermont.api.response.competitionResponse.CompetitionResult
import uca.iut.clermont.api.response.matchResponse.MatchResponse
import uca.iut.clermont.api.response.matchResponse.MatchResult
import uca.iut.clermont.model.Area
import uca.iut.clermont.model.PlayerResponse
interface FootballApi {
@Headers("X-Auth-Token: 7814ffe5b0314b5291a287d32a178e57")
@GET("areas/{id}")
suspend fun getArea(@Path("id") id: Int): Area
@Headers("X-Auth-Token: 7814ffe5b0314b5291a287d32a178e57")
@GET("areas")
suspend fun getAreas(): AreaResponse
@Headers("X-Auth-Token: 7814ffe5b0314b5291a287d32a178e57")
@GET("persons/{id}")
suspend fun getPlayer(@Path("id") playerId: Int): PlayerResponse
@Headers("X-Auth-Token: 621ef06e148542f98b4993a5442421eb")
@GET("competitions")
suspend fun getCompetitions(): CompetitionResponse
@Headers("X-Auth-Token: 8f51b43de0444026bd3ec3484f082575")
@GET("competitions/{id}")
suspend fun getCompetition(@Path("id") id: Int): CompetitionResult
@Headers("X-Auth-Token: 7814ffe5b0314b5291a287d32a178e57")
@GET("matches")
suspend fun getMatches(): MatchResponse
@Headers("X-Auth-Token: 621ef06e148542f98b4993a5442421eb")
@GET("matches/{id}")
suspend fun getMatch(@Path("id") id: Int): MatchResult
@Headers("X-Auth-Token: b002ff114afa41a590e2baef63d8c689")
@GET("competitions/{id}/matches")
suspend fun getMatchesByCompetition(@Path("id") id: Int): MatchResponse
}

@ -1,8 +0,0 @@
package uca.iut.clermont.api.response.areaResponse
import uca.iut.clermont.model.Area
data class AreaResponse(
val areas: List<Area>,
val count: Int
)

@ -1,7 +0,0 @@
package uca.iut.clermont.api.response.competitionResponse
data class CompetitionResponse(
val competitions: List<CompetitionResult>,
val count: Int,
val filters: Filters
)

@ -1,24 +0,0 @@
package uca.iut.clermont.api.response.competitionResponse
import uca.iut.clermont.model.Area
import uca.iut.clermont.model.Competition
class CompetitionResult(
val id: Int,
val name: String,
val code: String,
val type: String,
val emblem: String,
val currentSeason: CurrentSeason,
val area: Area
) {
fun toModel() = Competition(
id,
name,
code,
type,
emblem,
currentSeason.toModel(),
area
)
}

@ -1,29 +0,0 @@
package uca.iut.clermont.api.response.competitionResponse
import uca.iut.clermont.model.Season
import java.text.SimpleDateFormat
import java.util.*
data class CurrentSeason(
val currentMatchday: Int,
val endDate: String,
val id: Int,
val startDate: String,
val winner: Any
) {
fun toModel(): Season {
val calendar = Calendar.getInstance()
val calendar2 = Calendar.getInstance()
return Season(
id,
calendar.apply {
time = SimpleDateFormat("yyyy-MM-dd", Locale.US).parse(startDate) as Date
},
calendar2.apply {
time = SimpleDateFormat("yyyy-MM-dd", Locale.US).parse(endDate) as Date
},
currentMatchday,
if (winner is Int) winner else null
)
}
}

@ -1,5 +0,0 @@
package uca.iut.clermont.api.response.competitionResponse
data class Filters(
val client: String
)

@ -1,7 +0,0 @@
package uca.iut.clermont.api.response.matchResponse
data class Filters(
val dateFrom: String,
val dateTo: String,
val permission: String
)

@ -1,23 +0,0 @@
package uca.iut.clermont.api.response.matchResponse
import uca.iut.clermont.api.response.competitionResponse.CurrentSeason
import uca.iut.clermont.model.Area
import uca.iut.clermont.model.Competition
class MatchCompetitionResult(
val id: Int,
val name: String,
val code: String,
val type: String,
val emblem: String
) {
fun toModel(season: CurrentSeason, area: Area) = Competition(
id,
name,
code,
type,
emblem,
season.toModel(),
area
)
}

@ -1,7 +0,0 @@
package uca.iut.clermont.api.response.matchResponse
data class MatchResponse(
val filters: Filters,
val matches: List<MatchResult>,
val resultSet: ResultSet
)

@ -1,32 +0,0 @@
package uca.iut.clermont.api.response.matchResponse
import uca.iut.clermont.api.response.competitionResponse.CurrentSeason
import uca.iut.clermont.model.Area
import uca.iut.clermont.model.Match
import java.text.SimpleDateFormat
import java.util.*
class MatchResult(
val id: Int,
val homeTeam: TeamResult,
val awayTeam: TeamResult,
val utcDate: String,
val status: String,
val score: ScoreResult,
val season: CurrentSeason,
val area: Area,
val competition: MatchCompetitionResult
) {
fun toModel() = Match(
id,
homeTeam.toModel(),
awayTeam.toModel(),
Calendar.getInstance().apply {
time = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US).parse(utcDate) as Date
},
status,
score.toModel(),
competition.toModel(season, area)
)
}

@ -1,9 +0,0 @@
package uca.iut.clermont.api.response.matchResponse
data class ResultSet(
val competitions: String,
val count: Int,
val first: String,
val last: String,
val played: Int
)

@ -1,16 +0,0 @@
package uca.iut.clermont.api.response.matchResponse
import uca.iut.clermont.model.Score
data class ScoreResult(
val duration: String,
val fullTime: Time,
val halfTime: Time,
val winner: String?
){
fun toModel() = Score(
fullTime.home,
fullTime.away,
winner
)
}

@ -1,37 +0,0 @@
package uca.iut.clermont.api.response.matchResponse
import uca.iut.clermont.model.Area
import uca.iut.clermont.model.Coach
import uca.iut.clermont.model.Contract
import uca.iut.clermont.model.Team
import java.util.*
class TeamResult(
val id: Int,
val name: String,
val shortName: String,
val crest: String
) {
fun toModel() = Team(
id,
name,
shortName,
crest,
"",
"",
"",
"",
Area(1, "", "", "", ""),
"",
Coach(
1, "", "", "", Calendar.getInstance()
.apply { set(2022, 12, 28) }, "",
Contract(
Calendar.getInstance().apply { set(2020, 7, 1) },
Calendar.getInstance().apply { set(2024, 7, 1) })
),
listOf(),
listOf()
)
}

@ -1,6 +0,0 @@
package uca.iut.clermont.api.response.matchResponse
data class Time(
val away: Int?,
val home: Int?
)

@ -1,6 +0,0 @@
package uca.iut.clermont.api.response.playerResponse
data class ContractResponse(
val start: String,
val until: String
)

@ -1,7 +0,0 @@
package uca.iut.clermont.api.response.playerResponse
data class CurrentTeamResponse(
val id: Int,
val name: String,
val contract: ContractResponse
)

@ -1,38 +0,0 @@
package uca.iut.clermont.model
import uca.iut.clermont.api.response.playerResponse.CurrentTeamResponse
import java.text.SimpleDateFormat
import java.util.*
data class PlayerResponse(
val id: Int,
val firstName: String,
val lastName: String,
val name: String,
val dateOfBirth: String,
val nationality: String,
val position: String,
val shirtNumber: Int,
val lastUpdated: String,
val currentTeam: CurrentTeamResponse
) {
fun toModel() = Personne(
id,
firstName,
lastName,
name,
Calendar.getInstance().apply {
time = SimpleDateFormat("yyyy-MM-dd", Locale.US).parse(dateOfBirth) as Date
},
nationality,
Contract(
Calendar.getInstance().apply {
time = SimpleDateFormat("yyyy-MM", Locale.US).parse(currentTeam.contract.start) as Date
},
Calendar.getInstance().apply {
time = SimpleDateFormat("yyyy-MM", Locale.US).parse(currentTeam.contract.until) as Date
}
)
)
}

@ -1,31 +0,0 @@
package uca.iut.clermont.data
import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import uca.iut.clermont.data.dao.CompetitionDao
import uca.iut.clermont.model.Competition
@Database(entities = arrayOf(Competition::class), version = 1)
abstract class BDD : RoomDatabase() {
abstract fun competitionDao(): CompetitionDao
companion object {
private var INSTANCE: BDD? = null
fun getInstance(context: Context) =
INSTANCE ?: synchronized(this) {
val db = Room.databaseBuilder(
context,
BDD::class.java,
"ScorItDB"
).build()
INSTANCE = db
}
}
}

@ -246,7 +246,7 @@ class StubData : DataManager() {
)
)
private val random = Random()
private val random = java.util.Random()
val matchList: MutableList<Match> = mutableListOf()
fun initMatches() {
@ -421,43 +421,44 @@ class StubData : DataManager() {
class StubAreaManager(private val parent: StubData) : AreaManager {
override suspend fun getItemsByName(substring: String) =
override fun getItemsByName(substring: String) =
parent.areaList.filter { it.name.contains(substring, ignoreCase = true) }
override suspend fun getItems(): List<Area> = parent.areaList
override fun getItems(): List<Area> = parent.areaList
override suspend fun getItemById(id: Int) = parent.areaList.find { it.id == id }
override fun getItemById(id: Int) = parent.areaList.find { it.id == id }
}
class StubPeopleManager(private val parent: StubData) : PeopleManager {
override fun getItemsByName(substring: String) =
parent.peopleList.filter { it.name.contains(substring, ignoreCase = true) }
override suspend fun getItems() = parent.peopleList
override fun getItems() = parent.peopleList
override suspend fun getItemById(id: Int) = parent.peopleList.find { it.id == id }
override fun getItemById(id: Int) = parent.peopleList.find { it.id == id }
}
class StubMatchesManager(private val parent: StubData) : MatchesManager {
override fun getNbItemsByCompetition(substring: String) =
parent.matchList.filter { it.competition.name.contains(substring) }.count()
override suspend fun getNbItemsByCompetition(id: Int) =
parent.matchList.filter { it.competition.id == id }.size
override fun getItemsByCompetition(substring: String) =
parent.matchList.filter { it.competition.name.contains(substring) }
override suspend fun getItemsByCompetition(id: Int) =
parent.matchList.filter { it.competition.id == id }
override fun getItems(): List<Match> = parent.matchList
override suspend fun getItems(): List<Match> = parent.matchList
override suspend fun getItemById(id: Int) = parent.matchList.find { it.id == id }
override fun getItemById(id: Int) = parent.matchList.find { it.id == id }
}
class StubCompetitionsManager(private val parent: StubData) : CompetitionsManager {
override suspend fun getItemsByName(substring: String) =
override fun getItemsByName(substring: String) =
parent.competitionList.filter { it.name.contains(substring, ignoreCase = true) }
override suspend fun getItems() = parent.competitionList
override fun getItems() = parent.competitionList
override suspend fun getItemById(id: Int) = parent.competitionList.find { it.id == id }
override fun getItemById(id: Int) = parent.competitionList.find { it.id == id }
}
@ -465,9 +466,9 @@ class StubData : DataManager() {
override fun getItemsByName(substring: String) =
parent.teamList.filter { it.name.contains(substring, ignoreCase = true) }
override suspend fun getItems() = parent.teamList
override fun getItems() = parent.teamList
override suspend fun getItemById(id: Int) = parent.teamList.find { it.id == id }
override fun getItemById(id: Int) = parent.teamList.find { it.id == id }
}
}

@ -1,22 +0,0 @@
package uca.iut.clermont.data.dao
import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import kotlinx.coroutines.flow.Flow
import uca.iut.clermont.model.Competition
@Dao
interface CompetitionDao {
@Delete
fun deleteCompetition(competition: Competition)
@Query("SELECT * FROM competition")
fun getAllCompetitions(): Flow<List<Competition>>
@Insert
fun insertCompetition(competition: Competition)
}

@ -0,0 +1,95 @@
package uca.iut.clermont.model
import AreaManager
import CompetitionsManager
import DataManager
import MatchesManager
import PeopleManager
import TeamsManager
class ApiManager : DataManager() {
override val areaMgr: AreaManager = ApiAreaManager()
override val peopleMgr: PeopleManager = ApiPeopleManager()
override val matchesMgr: MatchesManager = ApiMatchesManager()
override val competitionsMgr: CompetitionsManager = ApiCompetitionsManager()
override val teamsMgr: TeamsManager = ApiTeamsManager()
class ApiAreaManager : AreaManager {
override fun getItemsByName(substring: String): List<Area> {
TODO("Not yet implemented")
}
override fun getItems(): List<Area> {
TODO("Not yet implemented")
}
override fun getItemById(id: Int): Area? {
TODO("Not yet implemented")
}
}
class ApiPeopleManager : PeopleManager {
override fun getItemsByName(substring: String): List<Personne> {
TODO("Not yet implemented")
}
override fun getItems(): List<Personne> {
TODO("Not yet implemented")
}
override fun getItemById(id: Int): Personne? {
TODO("Not yet implemented")
}
}
class ApiMatchesManager : MatchesManager {
override fun getNbItemsByCompetition(substring: String): Int {
TODO("Not yet implemented")
}
override fun getItemsByCompetition(substring: String): List<Match> {
TODO("Not yet implemented")
}
override fun getItems(): List<Match> {
TODO("Not yet implemented")
}
override fun getItemById(id: Int): Match? {
TODO("Not yet implemented")
}
}
class ApiCompetitionsManager : CompetitionsManager {
override fun getItemsByName(substring: String): List<Competition> {
TODO("Not yet implemented")
}
override fun getItems(): List<Competition> {
TODO("Not yet implemented")
}
override fun getItemById(id: Int): Competition? {
TODO("Not yet implemented")
}
}
class ApiTeamsManager : TeamsManager {
override fun getItemsByName(substring: String): List<Team> {
TODO("Not yet implemented")
}
override fun getItems(): List<Team> {
TODO("Not yet implemented")
}
override fun getItemById(id: Int): Team? {
TODO("Not yet implemented")
}
}
}

@ -1,16 +1,11 @@
package uca.iut.clermont.model
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "competitions")
class Competition(
@PrimaryKey val id: Int,
@ColumnInfo val name: String,
@ColumnInfo val code: String,
@ColumnInfo val type: String,
@ColumnInfo val emblem: String,
@ColumnInfo val currentSeason: Season,
val id: Int,
val name: String,
val code: String,
val type: String,
val emblem: String,
val currentSeason: Season,
val area: Area
)

@ -6,23 +6,26 @@ abstract class DataManager {
abstract val matchesMgr: MatchesManager
abstract val competitionsMgr: CompetitionsManager
abstract val teamsMgr: TeamsManager
}
interface AreaManager : GenericDataManager<Area> {
suspend fun getItemsByName(substring: String): List<Area>
fun getItemsByName(substring: String): List<Area>
}
interface PeopleManager : GenericDataManager<Personne> {}
interface PeopleManager : GenericDataManager<Personne> {
fun getItemsByName(substring: String): List<Personne>
}
interface MatchesManager : GenericDataManager<Match> {
suspend fun getNbItemsByCompetition(id: Int): Int
fun getNbItemsByCompetition(substring: String): Int
suspend fun getItemsByCompetition(id: Int): List<Match>
fun getItemsByCompetition(substring: String): List<Match>
}
interface CompetitionsManager : GenericDataManager<Competition> {
suspend fun getItemsByName(substring: String): List<Competition>
fun getItemsByName(substring: String): List<Competition>
}
interface TeamsManager : GenericDataManager<Team> {

@ -1,6 +1,6 @@
package uca.iut.clermont.model
interface GenericDataManager<T> {
suspend fun getItems(): List<T>
suspend fun getItemById(id: Int): T?
fun getItems(): List<T>
fun getItemById(id: Int): T?
}

@ -2,7 +2,7 @@ package uca.iut.clermont.model
import java.util.Calendar
open class Personne(
abstract class Personne(
val id: Int,
val firstName: String,
val lastName: String,

@ -1,7 +1,7 @@
package uca.iut.clermont.model
class Score(
val home: Int?,
val away: Int?,
val winner: String?
val home: Int,
val away: Int,
val winner: String
)

@ -8,25 +8,19 @@ import android.widget.ImageButton
import android.widget.ImageView
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import com.bumptech.glide.Glide
import uca.iut.clermont.R
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import uca.iut.clermont.R
import uca.iut.clermont.model.Competition
import uca.iut.clermont.view.adapter.MatchesAdapter
import uca.iut.clermont.view.viewModel.DetailViewModel
import java.text.SimpleDateFormat
import java.util.*
class DetailFragment : Fragment() {
private var isLiked = false
private lateinit var competition: Competition
private val viewModel: DetailViewModel by viewModels()
override fun onCreateView(
inflater: LayoutInflater,
@ -38,32 +32,10 @@ class DetailFragment : Fragment() {
val id = arguments?.getInt("idItem")!!
competition = (activity as MainActivity).manager.competitionsMgr.getItemById(id)!!
viewModel.competition.observe(viewLifecycleOwner, Observer { comp ->
comp?.let {
competition = comp
initializeView(view)
initRecyclerView(view)
}
})
viewModel.loadCurrentCompetition(id)
viewModel.nbCompetitionMatches.observe(viewLifecycleOwner, Observer { comp ->
comp?.let {
initNumberMatches(view)
}
})
viewModel.competitionMatches.observe(viewLifecycleOwner, Observer { competitions ->
competitions?.let {
initRecyclerView(view)
viewModel.loadNumberMatches()
}
})
viewModel.loadMatches(id)
initializeView(view)
initRecyclerView(view)
return view;
}
@ -94,35 +66,32 @@ class DetailFragment : Fragment() {
titleHeader.text = competition.name
var date = competition.currentSeason.endDate
var formatter = SimpleDateFormat("dd-MM-yyyy", Locale.US)
var formatter = SimpleDateFormat("dd-MM-yyyy")
var formattedDate = formatter.format(date.time)
dateEnd.text = formattedDate
date = competition.currentSeason.startDate
formatter = SimpleDateFormat("dd-MM-yyyy", Locale.US)
formatter = SimpleDateFormat("dd-MM-yyyy")
formattedDate = formatter.format(date.time)
dateStart.text = formattedDate
nbMatches.text =
(activity as MainActivity).manager.matchesMgr.getNbItemsByCompetition(competition.name)
.toString()
}
private fun initNumberMatches(view: View) {
val nbMatches = view.findViewById<TextView>(R.id.nbMatches)
nbMatches.text = viewModel.nbCompetitionMatches.value.toString()
}
private fun initRecyclerView(view: View) {
val recyclerViewMatches = view.findViewById<RecyclerView>(R.id.listRecentsMatches)
with(recyclerViewMatches) {
layoutManager = LinearLayoutManager(view.context)
adapter = viewModel.competitionMatches.value?.toList()?.let {
MatchesAdapter(
it.toTypedArray()
)
}
adapter = MatchesAdapter(
(activity as MainActivity).manager.matchesMgr.getItemsByCompetition(competition.name)
.toList().toTypedArray()
)
}
}

@ -8,34 +8,24 @@ import android.widget.Button
import android.widget.ImageButton
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import uca.iut.clermont.R
import uca.iut.clermont.model.Competition
import uca.iut.clermont.view.adapter.FavoritesAdapter
import uca.iut.clermont.view.viewModel.FavoriteViewModel
class FavoriteFragment : Fragment(), FavoritesAdapter.OnItemClickListener {
private val viewModel: FavoriteViewModel by viewModels()
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_favorite, container, false)
viewModel.competitions.observe(viewLifecycleOwner, Observer { competitions ->
competitions?.let {
initRecyclerView(view, competitions, this)
}
})
viewModel.loadCompetitions()
var competitions = (activity as MainActivity).manager.competitionsMgr.getItems()
initRecyclerView(view, competitions, this)
initializeView(view)
return view
@ -46,8 +36,8 @@ class FavoriteFragment : Fragment(), FavoritesAdapter.OnItemClickListener {
}
private fun initializeView(view: View) {
val buttonHome = view.findViewById<ImageButton>(R.id.buttonHome)
val buttonTextFavorite = view.findViewById<Button>(R.id.buttonTextHome)
var buttonHome = view.findViewById<ImageButton>(R.id.buttonHome)
var buttonTextFavorite = view.findViewById<Button>(R.id.buttonTextHome)
buttonHome.setOnClickListener {
navigate()
@ -71,7 +61,7 @@ class FavoriteFragment : Fragment(), FavoritesAdapter.OnItemClickListener {
}
override fun onItemClick(position: Int) {
val competitions = viewModel.competitions.value!!
var competitions = (activity as MainActivity).manager.competitionsMgr.getItems()
val bundle = bundleOf("idItem" to competitions[position].id)
findNavController().navigate(R.id.action_favoriteFragment_to_detailFragment, bundle)
}

@ -5,22 +5,16 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageButton
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import uca.iut.clermont.R
import uca.iut.clermont.model.Match
import uca.iut.clermont.view.adapter.MatchesAdapter
import uca.iut.clermont.view.viewModel.HomeViewModel
class HomeFragment : Fragment() {
val viewModel: HomeViewModel by viewModels()
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@ -28,31 +22,15 @@ class HomeFragment : Fragment() {
): View? {
val view = inflater.inflate(R.layout.fragment_home, container, false)
val matches = (activity as MainActivity).manager.matchesMgr.getItems()
val buttonFavorite = view.findViewById<ImageButton>(R.id.buttonFavorite)
val restartMatches = view.findViewById<ImageButton>(R.id.restartMatches)
val text = view.findViewById<TextView>(R.id.textEmpty)
viewModel.matches.observe(viewLifecycleOwner, Observer { matches ->
matches?.let {
if (it.isNotEmpty()) {
initRecyclerView(view, it)
} else {
text.setText(R.string.noMatches)
}
}
})
displayMatches()
buttonFavorite.setOnClickListener {
findNavController().navigate(R.id.favoriteFragment)
}
restartMatches.setOnClickListener {
displayMatches()
}
initRecyclerView(view, matches)
return view
}
@ -61,11 +39,9 @@ class HomeFragment : Fragment() {
with(recyclerViewMatches) {
layoutManager = LinearLayoutManager(view.context)
adapter = MatchesAdapter(matches.toList().toTypedArray())
}
}
private fun displayMatches() {
viewModel.loadMatches()
}

@ -19,6 +19,7 @@ class MainActivity : AppCompatActivity() {
private lateinit var navController: NavController
@RequiresApi(Build.VERSION_CODES.R)
private fun hideSystemUI() {
WindowCompat.setDecorFitsSystemWindows(window, false)
@ -33,6 +34,7 @@ class MainActivity : AppCompatActivity() {
}
@RequiresApi(Build.VERSION_CODES.R)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

@ -0,0 +1,13 @@
package uca.iut.clermont.view
import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.module.AppGlideModule
@GlideModule
class SampleGlideModule : AppGlideModule() {
override fun isManifestParsingEnabled(): Boolean {
return false
}
}

@ -16,8 +16,8 @@ import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import uca.iut.clermont.R
class StartFragment : Fragment(), SensorEventListener {
class StartFragment : Fragment(), SensorEventListener {
private lateinit var ball: ImageView
private lateinit var sensorManager: SensorManager

@ -8,7 +8,6 @@ import uca.iut.clermont.R
import uca.iut.clermont.model.Match
import uca.iut.clermont.view.viewHolder.MatchHolder
import java.text.SimpleDateFormat
import java.util.*
class MatchesAdapter(private val recentMatches: Array<Match>) :
RecyclerView.Adapter<MatchHolder>() {
@ -20,54 +19,15 @@ class MatchesAdapter(private val recentMatches: Array<Match>) :
override fun onBindViewHolder(holder: MatchHolder, position: Int) {
holder.titleFirstTeam.text = recentMatches[position].homeTeam.name
holder.titleSecondTeam.text = recentMatches[position].awayTeam.name
if (recentMatches[position].score.home != null) {
holder.scoreHomeTeam.text = recentMatches[position].score.home.toString()
} else {
holder.scoreHomeTeam.text = "0"
}
holder.scoreHomeTeam.text = recentMatches[position].score.home.toString()
holder.scoreAwayTeam.text = recentMatches[position].score.away.toString()
if (recentMatches[position].score.away != null) {
holder.scoreAwayTeam.text = recentMatches[position].score.away.toString()
} else {
holder.scoreAwayTeam.text = "0"
}
var date = recentMatches[position].date
val date = recentMatches[position].date
val formatter = SimpleDateFormat("dd/MM/yyyy' 'HH:mm", Locale.US)
val formattedDate = formatter.format(date.time)
var formatter = SimpleDateFormat("dd-MM-yyyy")
var formattedDate = formatter.format(date.time)
with(holder.iconStatus) {
setImageResource(R.drawable.mi_temp)
layoutParams.width = 0
layoutParams.height = 0
(layoutParams as ViewGroup.MarginLayoutParams).apply {
topMargin = 8
bottomMargin = 7
}
}
if (recentMatches[position].status == "IN_PLAY") {
with(holder.iconStatus) {
setImageResource(R.drawable.live)
layoutParams.width = 130
layoutParams.height = 130
(layoutParams as ViewGroup.MarginLayoutParams).apply {
topMargin = 0
bottomMargin = 0
}
}
}
if (recentMatches[position].status == "PAUSED") {
with(holder.iconStatus) {
setImageResource(R.drawable.mi_temp)
layoutParams.width = 100
layoutParams.height = 100
}
}
holder.dateCompetition.text =
recentMatches[position].competition.name.plus(" : ").plus(formattedDate)
holder.dateCompetition.text = recentMatches[position].competition.name + " : " + formattedDate
Glide.with(holder.itemView.context)
.load(recentMatches[position].homeTeam.crest)

@ -13,7 +13,6 @@ class MatchHolder(view: View) : RecyclerView.ViewHolder(view) {
val scoreAwayTeam: TextView
val imageHomeTeam: ImageView
val imageAwayTeam: ImageView
val iconStatus: ImageView
val dateCompetition: TextView
init {
@ -24,7 +23,6 @@ class MatchHolder(view: View) : RecyclerView.ViewHolder(view) {
imageHomeTeam = view.findViewById(R.id.ImageFirstTeam)
imageAwayTeam = view.findViewById(R.id.ImageSecondTeam)
dateCompetition = view.findViewById(R.id.DateCompetition)
iconStatus = view.findViewById(R.id.iconStatus)
}

@ -1,45 +0,0 @@
package uca.iut.clermont.view.viewModel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.launch
import uca.iut.clermont.api.ApiManager
import uca.iut.clermont.model.Competition
import uca.iut.clermont.model.Match
import java.util.*
class DetailViewModel(
//val dao: CompetitionDao
) : ViewModel() {
val manager = ApiManager()
val competition = MutableLiveData<Competition?>()
val competitionMatches = MutableLiveData<List<Match>>()
val nbCompetitionMatches = MutableLiveData<Int>()
/*fun insertCompetition(competition: Competition) =
viewModelScope.launch {
dao.insertCompetition(competition)
}
*/
fun loadCurrentCompetition(id: Int) = viewModelScope.launch {
val result = manager.competitionsMgr.getItemById(id)
competition.value = result
}
fun loadMatches(id: Int) = viewModelScope.launch {
val matchResults = manager.matchesMgr.getItemsByCompetition(id)
competitionMatches.value =
matchResults.filter { it.status != "TIMED" && it.status != "SCHEDULED" && it.status != "POSTPONED" }
.apply { forEach { it.date.add(Calendar.HOUR_OF_DAY, 2) } }
.sortedBy { it.competition.name }
.sortedByDescending { it.date }
}
fun loadNumberMatches() = viewModelScope.launch {
nbCompetitionMatches.value = competitionMatches.value?.size
}
}

@ -1,25 +0,0 @@
package uca.iut.clermont.view.viewModel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.launch
import uca.iut.clermont.api.ApiManager
import uca.iut.clermont.model.Competition
class FavoriteViewModel(
//val dao: CompetitionDao
) : ViewModel() {
val manager = ApiManager()
val competitions = MutableLiveData<List<Competition>>()
//fun getAllCompetitions() = dao.getAllCompetitions()
//.isLiveDate()
fun loadCompetitions() = viewModelScope.launch {
val result = manager.competitionsMgr.getItems()
competitions.value = result
}
}

@ -1,24 +0,0 @@
package uca.iut.clermont.view.viewModel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.launch
import uca.iut.clermont.api.ApiManager
import uca.iut.clermont.model.Match
import java.util.*
class HomeViewModel : ViewModel() {
val manager = ApiManager()
val matches = MutableLiveData<List<Match>?>()
fun loadMatches() = viewModelScope.launch {
val matchResults = manager.matchesMgr.getItems()
matches.value = matchResults.filter { it.status != "TIMED" }
.apply { forEach { it.date.add(Calendar.HOUR_OF_DAY, 2) } }
.sortedBy { it.competition.name }
.sortedByDescending { it.date }
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

@ -20,8 +20,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:src="@drawable/arrow"
android:contentDescription="@string/imageNotFound" />
android:src="@drawable/arrow" />
<Button
android:id="@+id/buttonTextHome"

@ -19,7 +19,7 @@
android:id="@+id/textViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello"
android:text="Hello"
android:textColor="@color/title"
android:textSize="20sp"
android:textStyle="bold" />
@ -28,11 +28,10 @@
android:id="@+id/buttonFavorite"
android:layout_width="34dp"
android:layout_height="34dp"
android:layout_gravity="end"
android:layout_gravity="right"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/icon_like"
android:contentDescription="@string/imageNotFound" />
android:src="@drawable/icon_like" />
</FrameLayout>

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_width="350dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/border_rounded"
@ -19,8 +19,7 @@
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="10dp"
android:contentDescription="@string/imageNotFound"/>
android:layout_marginVertical="10dp" />
<TextView
android:id="@+id/textFavorites"
@ -30,7 +29,7 @@
android:fontFamily="@font/mulish_bold"
android:maxLines="3"
android:textColor="@color/black"
android:textSize="18sp" />
android:textSize="18dp" />
</LinearLayout>

@ -1,14 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_width="350dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginTop="10dp"
android:background="@drawable/background"
android:gravity="center"
android:orientation="vertical"
@ -16,25 +15,11 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iconStatus"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="end"
android:layout_marginTop="8dp"
android:layout_marginBottom="7dp"
android:contentDescription="@string/imageNotFound" />
</FrameLayout>
<TextView
android:id="@+id/DateCompetition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:ellipsize="end"
android:fontFamily="@font/mulish_bold"
@ -47,15 +32,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:baselineAligned="false"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:gravity="center"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
@ -126,7 +109,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:gravity="center"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView

@ -8,10 +8,11 @@
<ImageView
android:id="@+id/imageDetail"
android:layout_width="220dp"
android:layout_width="170dp"
android:layout_height="0dp"
android:layout_marginTop="30dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_launcher_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.25"
app:layout_constraintStart_toStartOf="parent"
@ -199,10 +200,9 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/listRecentsMatches"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_height="500dp"
android:layout_marginTop="10dp"
android:paddingHorizontal="30dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/latestMatch"

@ -22,8 +22,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:src="@drawable/arrow"
android:contentDescription="@string/imageNotFound" />
android:src="@drawable/arrow" />
<Button
android:id="@+id/buttonTextHome"

@ -20,7 +20,7 @@
android:id="@+id/textViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello"
android:text="Hello"
android:textColor="@color/title"
android:textSize="20sp"
android:textStyle="bold" />
@ -29,11 +29,10 @@
android:id="@+id/buttonFavorite"
android:layout_width="34dp"
android:layout_height="34dp"
android:layout_gravity="end"
android:layout_gravity="right"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/icon_like"
android:contentDescription="@string/imageNotFound" />
android:src="@drawable/icon_like" />
</FrameLayout>
@ -89,41 +88,17 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Recent Matches Day"
android:text="Recent Matches"
android:textColor="@color/title"
android:textSize="20dp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchBarContainer" />
<ImageButton
android:id="@+id/restartMatches"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginTop="20dp"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/restart"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/searchBarContainer" />
<TextView
android:id="@+id/textEmpty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/title"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewRecentMatches" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/listRecentsMatches"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:paddingBottom="200dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewRecentMatches"

@ -13,8 +13,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:contentDescription="@string/imageNotFound" />
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/shadow"
@ -28,7 +27,6 @@
<LinearLayout
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="70dp"

@ -1,7 +1,3 @@
<resources>
<string name="app_name">Scor_It</string>
<string name="noMatches">No games started yet!</string>
<string name="imageNotFound">Image not found</string>
<string name="hello">Hello</string>
</resources>
Loading…
Cancel
Save