Skip to content

Commit

Permalink
Fix null value handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobminer committed Mar 23, 2022
1 parent 259ea7e commit e39aa65
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class MainActivity : AppCompatActivity() {
showSecretText = showSecretText.value,
altButtonText = useAltButtonText.value,
altButtonColour = useAltButtonColour.value,
selection = temp2Selection.value)
selection = temp2Selection.value ?: "")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ internal class MenuClassBuilder(
}
is SelectionProviderWrapper -> {
"""
val ${it.key}Selection = DebugValue(flow<String> {
DebugMenu.instance.flow<Int>("${it.key}").collect {
val ${it.key}Selection = DebugValue(flow<String?> {
DebugMenu.instance.flow<Int?>("${it.key}").collect {
val option = (DebugMenu.instance.optionForKey("${it.key}") as? OptionSelection) ?: return@collect
emit(option.options.get(it))
emit(if (it != null) option.options.get(it) else null)
}
})
"""
Expand All @@ -95,10 +95,10 @@ internal class MenuClassBuilder(
is SelectionWrapper -> {
val toggle = it.selectionValue
"""
val ${toggle.key} = DebugValue(flow<String> {
DebugMenu.instance.flow<Int>("${toggle.key}").collect {
val ${toggle.key} = DebugValue(flow<String?> {
DebugMenu.instance.flow<Int?>("${toggle.key}").collect {
val option = (DebugMenu.instance.optionForKey("${toggle.key}") as? OptionSelection) ?: return@collect
emit(option.options.get(it))
emit(if (it != null) option.options.get(it) else null)
}
})
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ suspend inline fun <reified T: Any> DebugMenu.value(key: String): T? {
return state.persistence.readValue(key)
}

inline fun <reified T: Any> DebugMenu.flow(key: String): Flow<T> {
inline fun <reified T: Any?> DebugMenu.flow(key: String): Flow<T> {
return state.persistence.flowValue(key)
}

Expand Down

0 comments on commit e39aa65

Please sign in to comment.