3 Commits

Author SHA1 Message Date
KaasKop
bc08cac918 Super basic error handling for the feyenoord api. 2024-12-30 20:06:56 +01:00
KaasKop
dce61f7477 Add loading to matches
Update gradle

Use repository?
2024-12-29 19:28:09 +01:00
KaasKop
019ed9c49a Update feyenoord authentication, UI fixes 2024-09-22 12:22:22 +02:00
33 changed files with 233 additions and 196 deletions

7
.gitignore vendored
View File

@@ -1,12 +1,7 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea
.DS_Store
/build
/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

@@ -5,14 +5,14 @@ plugins {
android {
namespace 'com.mitchelbv.thuis_c'
compileSdk 33
compileSdk 34
defaultConfig {
applicationId "com.mitchelbv.thuis_c"
minSdk 30
targetSdk 33
versionCode 1
versionName "1.0"
targetSdk 34
versionCode 3
versionName "1.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {

View File

@@ -4,7 +4,6 @@
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"

View File

@@ -4,12 +4,12 @@ import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
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()
.baseUrl(baseUrl)
.addConverterFactory(GsonConverterFactory.create())
.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
import com.mitchelbv.thuis_c.network.feyenoord.responses.FeyenoordEventResponse
import retrofit2.Call
import com.mitchelbv.thuis_c.network.feyenoord.FeyenoordTokenResponse.FeyenoordTokenResponse
import com.mitchelbv.thuis_c.network.feyenoord.responses.FeyenoordEventResponse.FeyenoordEventResponse
import retrofit2.http.GET
import retrofit2.http.Header
interface FeyenoordService {
@GET("event")
suspend fun getEvents(): FeyenoordEventResponse
@GET("Event")
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
@@ -8,8 +8,8 @@ data class ButtonData(
@SerializedName("EventId") var EventId: Int? = null,
@SerializedName("SaleCategoryId") var SaleCategoryId: Int? = null,
@SerializedName("TranslationCode") var TranslationCode: String? = null,
@SerializedName("ButtonStyle") var ButtonStyle: Int? = null,
@SerializedName("ActionType") var ActionType: Int? = null,
@SerializedName("ButtonStyle") var ButtonStyle: String? = null,
@SerializedName("ActionType") var ActionType: String? = null,
@SerializedName("Action") var Action: String? = null,
@SerializedName("ActiveFrom") var ActiveFrom: 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

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

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

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

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
@@ -51,8 +51,6 @@ data class Items(
@SerializedName("EventTypeLogoFileName") var EventTypeLogoFileName: String? = null,
@SerializedName("EventTypeLogoUniqueName") var EventTypeLogoUniqueName: 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("ShowMarketplaceForEvent") var ShowMarketplaceForEvent: 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

View File

@@ -0,0 +1,60 @@
package com.mitchelbv.thuis_c.repository
import androidx.lifecycle.LiveData
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 java.text.SimpleDateFormat
import java.util.Locale
import java.util.TimeZone
class FeyenoordRepository() {
private val feyenoordService: FeyenoordService = FeyenoordRetrofitHelper.feyenoord
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)
}
suspend fun getMatches(): List<Match> {
val tempMatches = mutableListOf<Match>()
val token = feyenoordService.getToken()
val feyenoordApiResponse = token.token?.let { feyenoordService.getEvents(it) }
feyenoordApiResponse?.TabItems?.filter { it.CategoryId == 2 }?.forEach {
for (item in it.Items) {
tempMatches.add(
Match(
homeTeam = item.NameHomeTeam!!,
awayTeam = item.NameAwayTeam!!,
date = item.EventStartDateTime?.let { it1 ->
toLocalFormattedDateTime(
it1,
"dd MMMM"
)
}.toString(),
beginTime = item.EventStartDateTime?.let { it1 ->
toLocalFormattedDateTime(
it1,
"HH:mm"
)
}.toString(),
endTime = item.EventEndDateTime?.let { it1 ->
toLocalFormattedDateTime(
it1,
"HH:mm"
)
}.toString(),
awayImage = item.AwayImageUrl!!,
homeImage = item.HomeImageUrl!!
)
)
}
}
return tempMatches
}
}

View File

@@ -11,6 +11,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
@@ -20,16 +22,25 @@ import coil.compose.AsyncImage
import com.mitchelbv.thuis_c.R
@Composable
fun FeyenoordScreen(feyenoordViewModel: FeyenoordViewModel = viewModel(), navHostController: NavHostController) {
fun FeyenoordScreen(
feyenoordViewModel: FeyenoordViewModel = viewModel(),
navHostController: NavHostController
) {
val feyenoordUiState by feyenoordViewModel.uiState.collectAsState()
Column(
modifier = Modifier
.verticalScroll(rememberScrollState())
// .padding(16.dp)
modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
if (feyenoordUiState.loading) {
CircularProgressIndicator()
} else if (feyenoordUiState.error != null) {
Text(stringResource(feyenoordUiState.error!!))
} else {
MatchList(matches = feyenoordUiState.matches, Modifier)
}
}
}
@Composable
fun MatchList(matches: List<Match>, modifier: Modifier) {
@@ -41,16 +52,28 @@ fun MatchList(matches: List<Match>, modifier: Modifier) {
}
@Composable
fun TeamNameWithLogo(team_name: String, team_logo_url: String, modifier: Modifier) {
Column(modifier = modifier.size(128.dp).fillMaxWidth(), Arrangement.Center, Alignment.CenterHorizontally) {
fun TeamNameWithLogo(teamName: String, teamLogoUrl: String, modifier: Modifier) {
Column(
modifier = modifier
.size(128.dp)
.fillMaxWidth(),
Arrangement.Center,
Alignment.CenterHorizontally
) {
AsyncImage(
model = team_logo_url,
contentDescription = team_name,
model = teamLogoUrl,
contentDescription = teamName,
placeholder = painterResource(id = R.drawable.placeholder),
contentScale = ContentScale.Fit,
modifier = modifier.size(64.dp)
)
Text(text = team_name, modifier = modifier.fillMaxWidth().wrapContentWidth(Alignment.CenterHorizontally))
Text(
text = teamName,
textAlign = TextAlign.Center,
modifier = modifier
.fillMaxWidth()
// .wrapContentWidth(Alignment.CenterHorizontally)
)
}
}
@@ -66,8 +89,8 @@ fun MatchCard(match: Match, modifier: Modifier) {
.height(128.dp)
) {
TeamNameWithLogo(
team_name = match.home_team,
team_logo_url = match.home_image,
teamName = match.homeTeam,
teamLogoUrl = match.homeImage,
modifier = modifier
)
Column(
@@ -76,14 +99,14 @@ fun MatchCard(match: Match, modifier: Modifier) {
) {
Text(text = match.date, overflow = TextOverflow.Ellipsis)
Row {
Text(match.begin_time)
Text(match.beginTime)
Text(" - ")
Text(match.end_time)
Text(match.endTime)
}
}
TeamNameWithLogo(
team_name = match.away_team,
team_logo_url = match.away_image,
teamName = match.awayTeam,
teamLogoUrl = match.awayImage,
modifier = modifier
)
@@ -94,13 +117,13 @@ fun MatchCard(match: Match, modifier: Modifier) {
@Composable
fun PreviewMatchCard() {
val test = Match(
home_image = "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",
home_team = "Feyenoord Vrouwen 1",
away_team = "FC Twente Vrouwen 1",
homeImage = "https://tymes4-cdn.azureedge.net/feyenoord/21-feyenoord-logo-original.png",
awayImage = "https://tymes4-cdn.azureedge.net/feyenoord/291-S.S._Lazio_badge.svg-min-original.png",
homeTeam = "Feyenoord Vrouwen 1",
awayTeam = "FC Twente Vrouwen 1",
date = "do 03 November 2023",
begin_time = "18:03",
end_time = "20:03"
beginTime = "18:03",
endTime = "20:03"
)
MatchCard(match = test, Modifier)
}

View File

@@ -1,54 +1,39 @@
package com.mitchelbv.thuis_c.ui.feyenoord
import android.util.Log
import android.content.res.Resources
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
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 com.mitchelbv.thuis_c.R
import com.mitchelbv.thuis_c.repository.FeyenoordRepository
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
data class FeyenoordUiState(
val matches: List<Match> = listOf()
val matches: List<Match> = listOf(),
val loading: Boolean = true,
val error: Int? = null
)
class FeyenoordViewModel : ViewModel() {
private val _uiState = MutableStateFlow(FeyenoordUiState())
val uiState: StateFlow<FeyenoordUiState> = _uiState.asStateFlow()
private val feyenoordRepository: FeyenoordRepository = FeyenoordRepository()
init {
fillMatches()
}
private fun fillMatches() {
val tempMatches = mutableListOf<Match>()
viewModelScope.launch(Dispatchers.IO) {
val apiResponse = FeyenoordRetrofitHelper.feyenoord.getEvents()
for (tabItem in apiResponse.TabItems) {
val test = arrayOf(tabItem).filter { it.CategoryId == 2 }
test.forEach {
for (item in it.Items) {
tempMatches.add(Match(
home_team = item.NameHomeTeam!!,
away_team = item.NameAwayTeam!!,
date = item.EventStartDateTimeFormatted?.Full!!,
begin_time = item.EventStartDateTimeFormatted?.Time!!,
end_time = item.EventEndDateTimeFormatted?.Time!!,
away_image = item.AwayImageUrl!!,
home_image = item.HomeImageUrl!!
))
try {
_uiState.value = FeyenoordUiState(matches = feyenoordRepository.getMatches(), loading = false)
} catch (e: Exception) {
_uiState.value = FeyenoordUiState(loading = false, error = R.string.feyenoord_network_error)
}
}
}
_uiState.value = FeyenoordUiState(matches = tempMatches)
}
}
}

View File

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

View File

@@ -24,8 +24,8 @@ fun HomeScreen(navController: NavHostController) {
// Row(modifier = Modifier.height(100.dp).width(180.dp)) {
// HomeCard(cardId = R.drawable.storefront, cardText = R.string.home_card_cards, routeTo = Screen.Cards.route, navController = navController)
// HomeCard(cardId = R.drawable.feyenoord, cardText = R.string.home_card_freezer, routeTo = Screen.Freezer.route, navController = navController)
HomeButton(buttonText = R.string.home_card_cards, routeTo = Screen.Cards.route, navController = navController)
HomeButton(buttonText = R.string.home_card_freezer, routeTo = Screen.Freezer.route, navController = navController)
// HomeButton(buttonText = R.string.home_card_cards, routeTo = Screen.Cards.route, navController = navController)
// HomeButton(buttonText = R.string.home_card_freezer, routeTo = Screen.Freezer.route, navController = navController)
// }
}
}

View File

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

View File

@@ -10,4 +10,5 @@
<string name="freezer_list_empty">Er zijn geen vriezers</string>
<string name="edit_freezer">Vriezer aanpassen</string>
<string name="feyenoord_network_error">Er is geen netwerk beschikbaar</string>
</resources>

View File

@@ -4,7 +4,7 @@ buildscript {
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.4.0' apply false
id 'com.android.library' version '7.4.0' apply false
id 'com.android.application' version '8.7.3' apply false
id 'com.android.library' version '8.7.3' 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,
# thereby reducing the size of the R class for that library
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
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME