fix: 蓝牙图标初始状态不正确
bluetoothOn 默认 true,如果蓝牙一开始就是关的不会触发状态变化事件 在 initBatteryStatus 中主动读取 BluetoothAdapter.isEnabled 初始化 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -308,8 +308,9 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 主动获取当前电量(不依赖 EventBus 广播) */
|
||||
/** 主动获取当前电量和蓝牙状态(不依赖 EventBus 广播) */
|
||||
private fun initBatteryStatus() {
|
||||
// 电量
|
||||
val batteryIntent = requireContext().registerReceiver(
|
||||
null, android.content.IntentFilter(android.content.Intent.ACTION_BATTERY_CHANGED)
|
||||
)
|
||||
@@ -323,6 +324,10 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
|
||||
statusBar.updateBattery(percent, isCharging)
|
||||
updateConfigBattery(percent, isCharging)
|
||||
}
|
||||
// 蓝牙当前状态(解决初始显示不正确的问题)
|
||||
val btAdapter = android.bluetooth.BluetoothAdapter.getDefaultAdapter()
|
||||
val btOn = btAdapter?.isEnabled ?: false
|
||||
statusBar.updateBluetooth(btOn)
|
||||
}
|
||||
|
||||
/** 初始化主页数据 */
|
||||
|
||||
Reference in New Issue
Block a user