Remove hardcoded avatar image library
Delete the bundled character avatar JPGs and the AvatarLibrary/AvatarProvider Kotlin files that referenced them.
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 120 KiB |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 243 KiB |
|
Before Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 94 KiB |
|
|
@ -1,24 +0,0 @@
|
|||
package com.fluxa.app.ui.catalog
|
||||
|
||||
data class AvatarCategory(
|
||||
val showName: String,
|
||||
val imdbId: String,
|
||||
val characters: List<AvatarCharacter> = emptyList() // Will be populated dynamically
|
||||
)
|
||||
|
||||
data class AvatarCharacter(
|
||||
val name: String,
|
||||
val url: String
|
||||
)
|
||||
|
||||
object AvatarLibrary {
|
||||
private val defaultCategories = listOf(
|
||||
AvatarCategory("The Boys", "TheBoys"),
|
||||
AvatarCategory("Breaking Bad", "BreakingBad"),
|
||||
AvatarCategory("Peaky Blinders", "PeakyBlinders"),
|
||||
AvatarCategory("Invincible", "Invincible"),
|
||||
AvatarCategory("Avatar: The Last Airbender", "ATLA")
|
||||
)
|
||||
|
||||
val categories: List<AvatarCategory> = defaultCategories
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
package com.fluxa.app.ui.catalog
|
||||
|
||||
import android.content.Context
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
object AvatarProvider {
|
||||
private val cache = ConcurrentHashMap<String, List<AvatarCharacter>>()
|
||||
|
||||
suspend fun fetchAvatarsForShow(context: Context, folderName: String): List<AvatarCharacter> = withContext(Dispatchers.IO) {
|
||||
cache[folderName]?.let { return@withContext it }
|
||||
|
||||
val basePath = "profile_avatars/$folderName"
|
||||
val characters = runCatching {
|
||||
context.assets.list(basePath)
|
||||
.orEmpty()
|
||||
.filter { fileName -> fileName.endsWith(".jpg", true) || fileName.endsWith(".jpeg", true) || fileName.endsWith(".png", true) || fileName.endsWith(".webp", true) || fileName.endsWith(".gif", true) }
|
||||
.sorted()
|
||||
.map { fileName ->
|
||||
val name = fileName.substringBeforeLast('.')
|
||||
.replace('-', ' ')
|
||||
.replace('_', ' ')
|
||||
.split(' ')
|
||||
.filter { it.isNotBlank() }
|
||||
.joinToString(" ") { part -> part.replaceFirstChar(Char::titlecase) }
|
||||
AvatarCharacter(name, "file:///android_asset/$basePath/${File(fileName).name}")
|
||||
}
|
||||
}.getOrDefault(emptyList())
|
||||
cache[folderName] = characters
|
||||
characters
|
||||
}
|
||||
}
|
||||