1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
| when (title) { "text_basic_setting" -> { add(Section().apply { setHeader(SectionHeaderItem(getString(R.string.text_setting_basic))) when (item.id) { "text_setting_basic_device_name" -> { add(nameItem) } "text_setting_basic_device_info" -> { add( StatusItem( getString(R.string.text_setting_basic_device_info), actionId = ACTION_NAV_ID_DEVICE_INFO ) ) } "text_setting_basic_device_network" -> { add( StatusItem( getString(R.string.text_setting_basic_device_network), actionId = ACTION_NAV_ID_DEVICE_NETWORK ) ) } "Synchronize" -> { add( SwitchItem( getString(R.string.text_allow_metered_sync), subTitle = getString(R.string.text_allow_metered_sync_tip), backgroundResId = R.drawable.bg_round_bottom, showSeparator = false, loadBlock = { item -> val useMeteredData = preference.getAllowMeteredDataCompute() logger.d(TAG, "load, useMeteredData, $useMeteredData") (item as? SwitchItem)?.isChecked = useMeteredData }, checkedListener = { button, isChecked -> logger.d( TAG, "cellular sync change, $isChecked, $button" ) preference.setAllowMeteredDataCompute(isChecked) } )) } } })
} "text_setting_device" -> { add(Section().apply { setHeader(SectionHeaderItem(getString(R.string.text_setting_device))) when (item.id) { "text_setting_ipc_flip_state" -> { add( SwitchItem( getString(R.string.text_setting_ipc_flip_state), subTitle = getString(R.string.text_setting_ipc_flip_state_tip), backgroundResId = R.drawable.bg_round_bottom, showSeparator = false, loadBlock = { item -> logger.d(TAG, "loadBlock, flip, $item") val state = deviceThingInfo?.run { performOnIOWithDefault(null) { sdk.getDeviceFlipStatusWithCache(this).await() } } ?: DpFlipState.NORMAL logger.d(TAG, "loadBlock, flip state, $state") (item as? SwitchItem)?.isChecked = (state == DpFlipState.UP_SIDE_DOWN) }, checkedListener = { button, isChecked -> logger.d( TAG, "checkedListener, flip, $isChecked, $button" ) val state = if (isChecked) DpFlipState.UP_SIDE_DOWN else DpFlipState.NORMAL viewModelScope.launch { performOnIOWithDefault(null) { deviceThingInfo?.let { sdk.setDeviceFlipStatusWithCache(it, state) .await() } } } } )) }
}
}) } }
|