Update feyenoord authentication, UI fixes

This commit is contained in:
KaasKop
2024-09-22 12:22:22 +02:00
parent bf071914a4
commit 019ed9c49a
28 changed files with 188 additions and 178 deletions

7
.gitignore vendored
View File

@@ -1,12 +1,7 @@
*.iml *.iml
.gradle .gradle
/local.properties /local.properties
/.idea/caches /.idea
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store .DS_Store
/build /build
/captures /captures

3
.idea/.gitignore generated vendored
View File

@@ -1,3 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml

1
.idea/.name generated
View File

@@ -1 +0,0 @@
Thuis

6
.idea/compiler.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.android/avd/Pixel_4_XL_API_31.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-11-06T10:26:15.426480Z" />
</component>
</project>

20
.idea/gradle.xml generated
View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="Embedded JDK" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

View File

@@ -1,29 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewFontScaleMustBeGreaterThanZero" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewMultipleParameterProviders" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
</profile>
</component>

10
.idea/misc.xml generated
View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

6
.idea/vcs.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@@ -4,12 +4,12 @@ import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory import retrofit2.converter.gson.GsonConverterFactory
object FeyenoordRetrofitHelper { object FeyenoordRetrofitHelper {
val baseUrl = "https://tickets-api.feyenoord.nl/api/" const val baseUrl = "https://feyenoord.api.tymes4-infra.com/v2/"
private val retrofit = Retrofit.Builder() private val retrofit = Retrofit.Builder()
.baseUrl(baseUrl) .baseUrl(baseUrl)
.addConverterFactory(GsonConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create())
.build() .build()
val feyenoord = retrofit.create(FeyenoordService::class.java) val feyenoord: FeyenoordService = retrofit.create(FeyenoordService::class.java)
} }

View File

@@ -1,10 +1,14 @@
package com.mitchelbv.thuis_c.network.feyenoord package com.mitchelbv.thuis_c.network.feyenoord
import com.mitchelbv.thuis_c.network.feyenoord.responses.FeyenoordEventResponse import com.mitchelbv.thuis_c.network.feyenoord.FeyenoordTokenResponse.FeyenoordTokenResponse
import retrofit2.Call import com.mitchelbv.thuis_c.network.feyenoord.responses.FeyenoordEventResponse.FeyenoordEventResponse
import retrofit2.http.GET import retrofit2.http.GET
import retrofit2.http.Header
interface FeyenoordService { interface FeyenoordService {
@GET("event") @GET("Event")
suspend fun getEvents(): FeyenoordEventResponse suspend fun getEvents(@Header("Authorization") token: String): FeyenoordEventResponse
@GET("Account/default-token")
suspend fun getToken(): FeyenoordTokenResponse
} }

View File

@@ -0,0 +1,28 @@
package com.mitchelbv.thuis_c.network.feyenoord.FeyenoordTokenResponse
import com.google.gson.annotations.SerializedName
data class CurrentChannel(
@SerializedName("Id") var id: Int? = null,
@SerializedName("Name") var name: String? = null,
@SerializedName("Code") var code: String? = null,
@SerializedName("HexColor") var hexColor: String? = null,
@SerializedName("Active") var active: Boolean? = null,
@SerializedName("HexBackColor") var hexBackColor: String? = null,
@SerializedName("HexForeColor") var hexForeColor: String? = null,
@SerializedName("SalesGroupId") var salesGroupId: Int? = null,
@SerializedName("ShowMarketplaceForEvent") var showMarketplaceForEvent: Boolean? = null,
@SerializedName("RedirectToMarketplace") var redirectToMarketplace: Boolean? = null,
@SerializedName("AllowAnonymous") var allowAnonymous: Boolean? = null,
@SerializedName("ParentCode") var parentCode: String? = null,
@SerializedName("ParentId") var parentId: String? = null,
@SerializedName("UserSelectable") var userSelectable: Boolean? = null,
@SerializedName("HeaderImageId") var headerImageId: String? = null,
@SerializedName("HeaderImageFileName") var headerImageFileName: String? = null,
@SerializedName("HeaderImageUrl") var headerImageUrl: String? = null,
@SerializedName("TicketshopHeaderLinkText") var ticketshopHeaderLinkText: String? = null,
@SerializedName("CustomCSS") var customCSS: String? = null
)

View File

@@ -0,0 +1,11 @@
package com.mitchelbv.thuis_c.network.feyenoord.FeyenoordTokenResponse
import com.google.gson.annotations.SerializedName
data class FeyenoordTokenResponse(
@SerializedName("AuthResult") var authResult: Int? = null,
@SerializedName("Token") var token: String? = null,
@SerializedName("CurrentChannel") var currentChannel: CurrentChannel? = CurrentChannel(),
@SerializedName("SalesChannels") var salesChannels: ArrayList<SalesChannels> = arrayListOf(),
@SerializedName("IsArchiveMode") var isArchiveMode: Boolean? = null
)

View File

@@ -0,0 +1,26 @@
package com.mitchelbv.thuis_c.network.feyenoord.FeyenoordTokenResponse
import com.google.gson.annotations.SerializedName
data class SalesChannels(
@SerializedName("Id") var id: Int? = null,
@SerializedName("Name") var name: String? = null,
@SerializedName("Code") var code: String? = null,
@SerializedName("HexColor") var hexColor: String? = null,
@SerializedName("Active") var active: Boolean? = null,
@SerializedName("HexBackColor") var hexBackColor: String? = null,
@SerializedName("HexForeColor") var hexForeColor: String? = null,
@SerializedName("SalesGroupId") var salesGroupId: Int? = null,
@SerializedName("ShowMarketplaceForEvent") var showMarketplaceForEvent: Boolean? = null,
@SerializedName("RedirectToMarketplace") var redirectToMarketplace: Boolean? = null,
@SerializedName("AllowAnonymous") var allowAnonymous: Boolean? = null,
@SerializedName("ParentCode") var parentCode: String? = null,
@SerializedName("ParentId") var parentId: String? = null,
@SerializedName("UserSelectable") var userSelectable: Boolean? = null,
@SerializedName("HeaderImageId") var headerImageId: String? = null,
@SerializedName("HeaderImageFileName") var headerImageFileName: String? = null,
@SerializedName("HeaderImageUrl") var headerImageUrl: String? = null,
@SerializedName("TicketshopHeaderLinkText") var ticketshopHeaderLinkText: String? = null,
@SerializedName("CustomCSS") var customCSS: String? = null
)

View File

@@ -1,4 +1,4 @@
package com.mitchelbv.thuis_c.network.feyenoord.responses package com.mitchelbv.thuis_c.network.feyenoord.responses.FeyenoordEventResponse
import com.google.gson.annotations.SerializedName import com.google.gson.annotations.SerializedName
@@ -8,8 +8,8 @@ data class ButtonData(
@SerializedName("EventId") var EventId: Int? = null, @SerializedName("EventId") var EventId: Int? = null,
@SerializedName("SaleCategoryId") var SaleCategoryId: Int? = null, @SerializedName("SaleCategoryId") var SaleCategoryId: Int? = null,
@SerializedName("TranslationCode") var TranslationCode: String? = null, @SerializedName("TranslationCode") var TranslationCode: String? = null,
@SerializedName("ButtonStyle") var ButtonStyle: Int? = null, @SerializedName("ButtonStyle") var ButtonStyle: String? = null,
@SerializedName("ActionType") var ActionType: Int? = null, @SerializedName("ActionType") var ActionType: String? = null,
@SerializedName("Action") var Action: String? = null, @SerializedName("Action") var Action: String? = null,
@SerializedName("ActiveFrom") var ActiveFrom: String? = null, @SerializedName("ActiveFrom") var ActiveFrom: String? = null,
@SerializedName("ActiveTill") var ActiveTill: String? = null, @SerializedName("ActiveTill") var ActiveTill: String? = null,

View File

@@ -1,4 +1,4 @@
package com.mitchelbv.thuis_c.network.feyenoord.responses package com.mitchelbv.thuis_c.network.feyenoord.responses.FeyenoordEventResponse
import com.google.gson.annotations.SerializedName import com.google.gson.annotations.SerializedName

View File

@@ -1,4 +1,4 @@
package com.mitchelbv.thuis_c.network.feyenoord.responses package com.mitchelbv.thuis_c.network.feyenoord.responses.FeyenoordEventResponse
import com.google.gson.annotations.SerializedName import com.google.gson.annotations.SerializedName

View File

@@ -1,4 +1,4 @@
package com.mitchelbv.thuis_c.network.feyenoord.responses package com.mitchelbv.thuis_c.network.feyenoord.responses.FeyenoordEventResponse
import com.google.gson.annotations.SerializedName import com.google.gson.annotations.SerializedName

View File

@@ -1,4 +1,4 @@
package com.mitchelbv.thuis_c.network.feyenoord.responses package com.mitchelbv.thuis_c.network.feyenoord.responses.FeyenoordEventResponse
import com.google.gson.annotations.SerializedName import com.google.gson.annotations.SerializedName

View File

@@ -1,4 +1,4 @@
package com.mitchelbv.thuis_c.network.feyenoord.responses package com.mitchelbv.thuis_c.network.feyenoord.responses.FeyenoordEventResponse
import com.google.gson.annotations.SerializedName import com.google.gson.annotations.SerializedName
@@ -51,8 +51,6 @@ data class Items(
@SerializedName("EventTypeLogoFileName") var EventTypeLogoFileName: String? = null, @SerializedName("EventTypeLogoFileName") var EventTypeLogoFileName: String? = null,
@SerializedName("EventTypeLogoUniqueName") var EventTypeLogoUniqueName: String? = null, @SerializedName("EventTypeLogoUniqueName") var EventTypeLogoUniqueName: String? = null,
@SerializedName("InfoUrl") var InfoUrl: String? = null, @SerializedName("InfoUrl") var InfoUrl: String? = null,
@SerializedName("EventStartDateTimeFormatted") var EventStartDateTimeFormatted: EventStartDateTimeFormatted? = EventStartDateTimeFormatted(),
@SerializedName("EventEndDateTimeFormatted") var EventEndDateTimeFormatted: EventEndDateTimeFormatted? = EventEndDateTimeFormatted(),
@SerializedName("ButtonData") var ButtonData: ButtonData? = ButtonData(), @SerializedName("ButtonData") var ButtonData: ButtonData? = ButtonData(),
@SerializedName("ShowMarketplaceForEvent") var ShowMarketplaceForEvent: Boolean? = null, @SerializedName("ShowMarketplaceForEvent") var ShowMarketplaceForEvent: Boolean? = null,
@SerializedName("RedirectToMarketplace") var RedirectToMarketplace: Boolean? = null, @SerializedName("RedirectToMarketplace") var RedirectToMarketplace: Boolean? = null,

View File

@@ -1,4 +1,4 @@
package com.mitchelbv.thuis_c.network.feyenoord.responses package com.mitchelbv.thuis_c.network.feyenoord.responses.FeyenoordEventResponse
import com.google.gson.annotations.SerializedName import com.google.gson.annotations.SerializedName

View File

@@ -1,5 +1,6 @@
package com.mitchelbv.thuis_c.ui.feyenoord package com.mitchelbv.thuis_c.ui.feyenoord
import android.widget.Spinner
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
@@ -20,8 +21,20 @@ import coil.compose.AsyncImage
import com.mitchelbv.thuis_c.R import com.mitchelbv.thuis_c.R
@Composable @Composable
fun FeyenoordScreen(feyenoordViewModel: FeyenoordViewModel = viewModel(), navHostController: NavHostController) { fun FeyenoordScreen(
feyenoordViewModel: FeyenoordViewModel = viewModel(),
navHostController: NavHostController
) {
val feyenoordUiState by feyenoordViewModel.uiState.collectAsState() val feyenoordUiState by feyenoordViewModel.uiState.collectAsState()
if (feyenoordUiState.loading) {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
CircularProgressIndicator()
}
}
Column( Column(
modifier = Modifier modifier = Modifier
.verticalScroll(rememberScrollState()) .verticalScroll(rememberScrollState())
@@ -42,7 +55,13 @@ fun MatchList(matches: List<Match>, modifier: Modifier) {
@Composable @Composable
fun TeamNameWithLogo(team_name: String, team_logo_url: String, modifier: Modifier) { fun TeamNameWithLogo(team_name: String, team_logo_url: String, modifier: Modifier) {
Column(modifier = modifier.size(128.dp).fillMaxWidth(), Arrangement.Center, Alignment.CenterHorizontally) { Column(
modifier = modifier
.size(128.dp)
.fillMaxWidth(),
Arrangement.Center,
Alignment.CenterHorizontally
) {
AsyncImage( AsyncImage(
model = team_logo_url, model = team_logo_url,
contentDescription = team_name, contentDescription = team_name,
@@ -50,7 +69,12 @@ fun TeamNameWithLogo(team_name: String, team_logo_url: String, modifier: Modifie
contentScale = ContentScale.Fit, contentScale = ContentScale.Fit,
modifier = modifier.size(64.dp) modifier = modifier.size(64.dp)
) )
Text(text = team_name, modifier = modifier.fillMaxWidth().wrapContentWidth(Alignment.CenterHorizontally)) Text(
text = team_name,
modifier = modifier
.fillMaxWidth()
.wrapContentWidth(Alignment.CenterHorizontally)
)
} }
} }
@@ -66,8 +90,8 @@ fun MatchCard(match: Match, modifier: Modifier) {
.height(128.dp) .height(128.dp)
) { ) {
TeamNameWithLogo( TeamNameWithLogo(
team_name = match.home_team, team_name = match.homeTeam,
team_logo_url = match.home_image, team_logo_url = match.homeImage,
modifier = modifier modifier = modifier
) )
Column( Column(
@@ -76,14 +100,14 @@ fun MatchCard(match: Match, modifier: Modifier) {
) { ) {
Text(text = match.date, overflow = TextOverflow.Ellipsis) Text(text = match.date, overflow = TextOverflow.Ellipsis)
Row { Row {
Text(match.begin_time) Text(match.beginTime)
Text(" - ") Text(" - ")
Text(match.end_time) Text(match.endTime)
} }
} }
TeamNameWithLogo( TeamNameWithLogo(
team_name = match.away_team, team_name = match.awayTeam,
team_logo_url = match.away_image, team_logo_url = match.awayImage,
modifier = modifier modifier = modifier
) )
@@ -94,13 +118,13 @@ fun MatchCard(match: Match, modifier: Modifier) {
@Composable @Composable
fun PreviewMatchCard() { fun PreviewMatchCard() {
val test = Match( val test = Match(
home_image = "https://tymes4-cdn.azureedge.net/feyenoord/21-feyenoord-logo-original.png", homeImage = "https://tymes4-cdn.azureedge.net/feyenoord/21-feyenoord-logo-original.png",
away_image = "https://tymes4-cdn.azureedge.net/feyenoord/291-S.S._Lazio_badge.svg-min-original.png", awayImage = "https://tymes4-cdn.azureedge.net/feyenoord/291-S.S._Lazio_badge.svg-min-original.png",
home_team = "Feyenoord Vrouwen 1", homeTeam = "Feyenoord Vrouwen 1",
away_team = "FC Twente Vrouwen 1", awayTeam = "FC Twente Vrouwen 1",
date = "do 03 November 2023", date = "do 03 November 2023",
begin_time = "18:03", beginTime = "18:03",
end_time = "20:03" endTime = "20:03"
) )
MatchCard(match = test, Modifier) MatchCard(match = test, Modifier)
} }

View File

@@ -1,23 +1,20 @@
package com.mitchelbv.thuis_c.ui.feyenoord package com.mitchelbv.thuis_c.ui.feyenoord
import android.util.Log
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.mitchelbv.thuis_c.network.feyenoord.FeyenoordRetrofitHelper import com.mitchelbv.thuis_c.network.feyenoord.FeyenoordRetrofitHelper
import com.mitchelbv.thuis_c.network.feyenoord.FeyenoordService
import com.mitchelbv.thuis_c.network.feyenoord.responses.FeyenoordEventResponse
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import okhttp3.ResponseBody import java.text.SimpleDateFormat
import retrofit2.Call import java.util.Locale
import retrofit2.Callback import java.util.TimeZone
import retrofit2.Response
data class FeyenoordUiState( data class FeyenoordUiState(
val matches: List<Match> = listOf() val matches: List<Match> = listOf(),
val loading: Boolean = true
) )
class FeyenoordViewModel : ViewModel() { class FeyenoordViewModel : ViewModel() {
@@ -28,27 +25,47 @@ class FeyenoordViewModel : ViewModel() {
fillMatches() fillMatches()
} }
private fun toLocalFormattedDateTime(date: String, outputFormat: String): String {
val apiUtcDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault())
apiUtcDate.timeZone = TimeZone.getTimeZone("UTC")
val parsedDate = apiUtcDate.parse(date)
val localDateFormat = SimpleDateFormat(outputFormat, Locale.getDefault())
localDateFormat.timeZone = TimeZone.getDefault()
return localDateFormat.format(parsedDate);
}
private fun fillMatches() { private fun fillMatches() {
val tempMatches = mutableListOf<Match>() val tempMatches = mutableListOf<Match>()
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
val apiResponse = FeyenoordRetrofitHelper.feyenoord.getEvents()
val tokenResponse = FeyenoordRetrofitHelper.feyenoord.getToken()
val apiResponse = tokenResponse.token?.let {
FeyenoordRetrofitHelper.feyenoord.getEvents(
it
)
}
if (apiResponse != null) {
for (tabItem in apiResponse.TabItems) { for (tabItem in apiResponse.TabItems) {
val test = arrayOf(tabItem).filter { it.CategoryId == 2 } val test = arrayOf(tabItem).filter { it.CategoryId == 2 }
test.forEach { test.forEach {
for (item in it.Items) { for (item in it.Items) {
tempMatches.add(Match( tempMatches.add(
home_team = item.NameHomeTeam!!, Match(
away_team = item.NameAwayTeam!!, homeTeam = item.NameHomeTeam!!,
date = item.EventStartDateTimeFormatted?.Full!!, awayTeam = item.NameAwayTeam!!,
begin_time = item.EventStartDateTimeFormatted?.Time!!, date = item.EventStartDateTime?.let { it1 -> toLocalFormattedDateTime(it1, "dd MMMM") }.toString(),
end_time = item.EventEndDateTimeFormatted?.Time!!, beginTime = item.EventStartDateTime?.let { it1 -> toLocalFormattedDateTime(it1, "HH:mm")}.toString(),
away_image = item.AwayImageUrl!!, endTime = item.EventEndDateTime?.let { it1 -> toLocalFormattedDateTime(it1, "HH:mm")}.toString(),
home_image = item.HomeImageUrl!! awayImage = item.AwayImageUrl!!,
)) homeImage = item.HomeImageUrl!!
)
)
} }
} }
} }
_uiState.value = FeyenoordUiState(matches = tempMatches) }
_uiState.value = FeyenoordUiState(matches = tempMatches, loading = false)
} }
} }
} }

View File

@@ -1,11 +1,11 @@
package com.mitchelbv.thuis_c.ui.feyenoord package com.mitchelbv.thuis_c.ui.feyenoord
data class Match( data class Match(
val home_image: String, val homeImage: String,
val away_image: String, val awayImage: String,
val home_team: String, val homeTeam: String,
val away_team: String, val awayTeam: String,
val date: String, val date: String,
val begin_time: String, val beginTime: String,
val end_time: String val endTime: String
) )

View File

@@ -2,11 +2,8 @@ package com.mitchelbv.thuis_c.ui.home
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.mitchelbv.thuis_c.Screen
import com.mitchelbv.thuis_c.network.feyenoord.FeyenoordRetrofitHelper import com.mitchelbv.thuis_c.network.feyenoord.FeyenoordRetrofitHelper
import com.mitchelbv.thuis_c.network.feyenoord.FeyenoordService
import com.mitchelbv.thuis_c.ui.feyenoord.Match import com.mitchelbv.thuis_c.ui.feyenoord.Match
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.asStateFlow
@@ -33,17 +30,17 @@ class HomeViewModel : ViewModel() {
private fun getUpcomingMatch() { private fun getUpcomingMatch() {
viewModelScope.launch { viewModelScope.launch {
val apiResponse = FeyenoordRetrofitHelper.feyenoord.getEvents().HeaderItem!! // val apiResponse = FeyenoordRetrofitHelper.feyenoord.getEvents().HeaderItem!!
val match = Match( // val match = Match(
home_team = notNullHandler(apiResponse.NameHomeTeam), // homeTeam = notNullHandler(apiResponse.NameHomeTeam),
away_team = notNullHandler(apiResponse.NameAwayTeam), // awayTeam = notNullHandler(apiResponse.NameAwayTeam),
date = notNullHandler(apiResponse.EventStartDateTimeFormatted?.Full), // date = notNullHandler(apiResponse.EventStartDateTimeFormatted?.Full),
begin_time = notNullHandler(apiResponse.EventStartDateTimeFormatted?.Time), // beginTime = notNullHandler(apiResponse.EventStartDateTimeFormatted?.Time),
end_time = notNullHandler(apiResponse.EventEndDateTimeFormatted?.Time), // endTime = notNullHandler(apiResponse.EventEndDateTimeFormatted?.Time),
away_image = notNullHandler(apiResponse.AwayImageUrl), // awayImage = notNullHandler(apiResponse.AwayImageUrl),
home_image = notNullHandler(apiResponse.HomeImageUrl) // homeImage = notNullHandler(apiResponse.HomeImageUrl)
) // )
_uiState.value = HomeUiState(upcomingMatch = match) // _uiState.value = HomeUiState(upcomingMatch = match)
} }
} }
} }

View File

@@ -4,7 +4,7 @@ buildscript {
} }
}// Top-level build file where you can add configuration options common to all sub-projects/modules. }// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins { plugins {
id 'com.android.application' version '7.4.0' apply false id 'com.android.application' version '8.6.0' apply false
id 'com.android.library' version '7.4.0' apply false id 'com.android.library' version '8.6.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
} }

View File

@@ -21,3 +21,5 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies, # resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library # thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true android.nonTransitiveRClass=true
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false

View File

@@ -1,6 +1,6 @@
#Mon Oct 31 14:59:45 CET 2022 #Mon Oct 31 14:59:45 CET 2022
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME