Sam Dukes
03/28/2025, 10:47 AMandroid.content.res.Resources$NotFoundException: Resource ID #0x0
. I'm trying to work out how I can get this data from the database to maybe persist and be saved through an orientation change, or possibly getting the image composable to wait a second for the flow to emit the data again. Any help would be appreciated (I am fairly new to compose) 🙏Chiranjeevi Pandey
03/28/2025, 11:37 AMChrimaeon
03/28/2025, 11:44 AMSam Dukes
03/28/2025, 11:45 AMfun getCharacterEntry(name: String) {
characterState.value = allCharacters.value.first { it.name == name }
}
// Repository Functions
fun getAllCharacterEntries() =
tekkenDataRepository.getAllCharacters()
.map { it }
.stateIn(
scope = viewModelScope,
started = SharingStarted.WhileSubscribed(5_000L),
initialValue = listOf()
)
Sam Dukes
03/28/2025, 11:45 AMSam Dukes
03/28/2025, 11:45 AMSam Dukes
03/28/2025, 11:47 AMval character by comboViewModel.characterState.collectAsState()
val allCombos by comboViewModel.allCombos.collectAsState()
val allComboEntries by comboViewModel.comboEntries.collectAsState()
val allMoves by comboViewModel.allMoves.collectAsState()
// Combo Screen
composable(route = FlowScreen.Combos.name) {
ComboScreen(
comboViewModel = comboViewModel,
deviceType = deviceType,
onAddCombo = {
addComboViewModel.characterState.value = comboViewModel.characterState.value
addComboViewModel.allMoves.value = comboViewModel.allMoves.value
addComboViewModel.editing.value = false
navController.navigate(FlowScreen.AddCombo.name)
},
onEditCombo = {
addComboViewModel.comboState.value = comboViewModel.comboState.value
addComboViewModel.characterState.value = comboViewModel.characterState.value
addComboViewModel.allMoves.value = comboViewModel.allMoves.value
addComboViewModel.existingCombos.value = comboViewModel.comboEntries.value
addComboViewModel.editing.value = true
navController.navigate(FlowScreen.AddCombo.name)
},
navigateBack = navController::navigateUp,
character = character,
comboDisplayList = allCombos,
comboEntryList = allComboEntries,
allMoves = allMoves,
)
}
Sam Dukes
03/28/2025, 11:54 AM@Composable
fun Header(
character: CharacterEntry,
fontColor: Color,
onAddCombo: () -> Unit,
modifier: Modifier = Modifier,
) {
Box(
modifier = modifier.fillMaxWidth()
) {
Log.d("", "Loading Character Image...")
Image(
painter = painterResource(character.imageId),
contentDescription = character.name,
modifier = Modifier
.size(75.dp)
.align(Alignment.CenterStart)
)
Text(
text = character.name,
color = fontColor,
fontSize = if (character.name.length > 9) 60.sp else 80.sp,
style = MaterialTheme.typography.displayMedium,
modifier = modifier.align(Alignment.Center)
)
Log.d("", "Loading Icon image")
IconButton(
modifier = modifier
.align(Alignment.CenterEnd)
.size(75.dp),
onClick = onAddCombo,
content = {
Icon(
imageVector = Icons.Default.Add,
contentDescription = stringResource(R.string.add_combo),
modifier.size(75.dp)
)
}
)
}
}
Sam Dukes
04/02/2025, 9:27 AM