Merge "Disable the async preference when it is loading"
This commit is contained in:
@@ -127,11 +127,11 @@ object PreferencePageProvider : SettingsPageProvider {
|
||||
.setStatusDataFn { EntryStatusData(isDisabled = false) }
|
||||
.setUiLayoutFn {
|
||||
val model = PreferencePageModel.create()
|
||||
val asyncSummary = remember { model.getAsyncSummary() }
|
||||
Preference(
|
||||
object : PreferenceModel {
|
||||
override val title = ASYNC_PREFERENCE_TITLE
|
||||
override val summary = asyncSummary
|
||||
override val summary = model.asyncSummary
|
||||
override val enabled = model.asyncEnable
|
||||
}
|
||||
)
|
||||
}.build()
|
||||
|
||||
@@ -59,7 +59,8 @@ class PreferencePageModel : PageModel() {
|
||||
|
||||
private val spaLogger = SpaEnvironmentFactory.instance.logger
|
||||
|
||||
private val asyncSummary = mutableStateOf(" ")
|
||||
val asyncSummary = mutableStateOf("(loading)")
|
||||
val asyncEnable = mutableStateOf(false)
|
||||
|
||||
private val manualUpdater = mutableStateOf(0)
|
||||
|
||||
@@ -87,16 +88,13 @@ class PreferencePageModel : PageModel() {
|
||||
override fun initialize(arguments: Bundle?) {
|
||||
spaLogger.message(TAG, "initialize with args " + arguments.toString())
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
// Loading your data here.
|
||||
delay(2000L)
|
||||
asyncSummary.value = ASYNC_PREFERENCE_SUMMARY
|
||||
asyncEnable.value = true
|
||||
}
|
||||
}
|
||||
|
||||
fun getAsyncSummary(): State<String> {
|
||||
spaLogger.message(TAG, "getAsyncSummary")
|
||||
return asyncSummary
|
||||
}
|
||||
|
||||
fun getManualUpdaterSummary(): State<String> {
|
||||
spaLogger.message(TAG, "getManualUpdaterSummary")
|
||||
return derivedStateOf { manualUpdater.value.toString() }
|
||||
|
||||
Reference in New Issue
Block a user