Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5717541 authored by Zekan Qian's avatar Zekan Qian
Browse files

Disable the async preference when it is loading

Bug: 244122804
Test: manual - build gallery
Change-Id: I1918f3e172b039ae3688a43c148ae53706e186a8
parent 9d93ab7a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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()
+4 −6
Original line number Diff line number Diff line
@@ -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() }