Skip to content

Commit

Permalink
[android] add support for synced quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
redstonekasi committed Sep 22, 2024
1 parent 0fe7fc8 commit e8b14ca
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 62 deletions.
4 changes: 2 additions & 2 deletions clients/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId = "network.uwu.radio"
minSdk = 21
targetSdk = 33
versionCode = 100
versionName = "1.0.0"
versionCode = 110
versionName = "1.1.0"

vectorDrawables {
useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import io.ktor.client.plugins.logging.*
import io.ktor.serialization.kotlinx.json.*
import kotlinx.serialization.json.Json
import network.uwu.radio.BuildConfig
import network.uwu.radio.network.service.UwuRadioApiService
import network.uwu.radio.network.service.UwuRadioApiServiceImpl
import network.uwu.radio.network.service.UwuRadioSyncService
import network.uwu.radio.network.service.UwuRadioSyncServiceImpl
import org.koin.core.module.dsl.singleOf
Expand All @@ -35,5 +33,4 @@ val clientModule = module {
}
}
singleOf(::UwuRadioSyncServiceImpl) bind UwuRadioSyncService::class
singleOf(::UwuRadioApiServiceImpl) bind UwuRadioApiService::class
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ import kotlinx.coroutines.flow.map
import network.uwu.radio.domain.model.DomainSongData
import network.uwu.radio.network.dto.ApiSong
import network.uwu.radio.network.service.ClientState
import network.uwu.radio.network.service.UwuRadioApiService
import network.uwu.radio.network.service.UwuRadioSyncService

interface SessionRepository {

suspend fun connectSyncClient()

suspend fun requestData()

suspend fun getRandomQuote(submitter: String): String?


fun observeSyncClientState(): Flow<ClientState>

fun observeProgressbar(): Flow<Long>
Expand All @@ -26,7 +23,6 @@ interface SessionRepository {

class SessionRepositoryImpl(
private val uwuRadioSyncService: UwuRadioSyncService,
private val uwuRadioApiService: UwuRadioApiService
) : SessionRepository {

override suspend fun connectSyncClient() {
Expand Down Expand Up @@ -61,21 +57,14 @@ class SessionRepositoryImpl(
}
}

override suspend fun getRandomQuote(submitter: String): String? {
return uwuRadioApiService.getSubmitters()
.find { it.name == submitter }
?.quotes
?.randomOrNull()
}

private suspend fun ApiSong.toDomain(startTime: Long = 0L): DomainSongData {
private fun ApiSong.toDomain(startTime: Long = 0L): DomainSongData {
return DomainSongData(
songName = name,
songArtist = artist,
songArtworkUrl = artUrl,
songUrl = dlUrl!!,
songUrl = dlUrl,
submitterName = submitter,
submitterQuote = getRandomQuote(submitter),
submitterQuote = quote,
startTime = startTime
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package network.uwu.radio.network.dto
data class ApiSong(
val name: String,
val artist: String,
val dlUrl: String?,
val sourceUrl: String?,
val dlUrl: String,
val sourceUrl: String,
val artUrl: String?,
val album: String?,
val submitter: String,
val quote: String?,
)

This file was deleted.

0 comments on commit e8b14ca

Please sign in to comment.