android,遙控器控制CCT燈,APP上無法同步顯示調整
阿新 • • 發佈:2018-12-06
預置條件:遙控器控制CCT燈
操作步驟:變化色溫顯示
預期結果:APP上色溫條會同步顯示變化
實際結果:APP上色溫條無反應
一看到這個bug就知道是資料問題,首先我找了個遙控器跟燈,試了一下,發現亮度是會有同步,而色溫卻沒有同步。
解決思路:1先找到對應頁面 2斷點檢視下為什麼沒有值
找到了DeviceCtrlFragment頁面 發現色溫條 tempSeekbar取的是
getAct().selectedDevice.getTemperature()
就去取看setTemperature的值 發現只有一個地方呼叫
而setBrightness卻有兩個地方呼叫
for (OnlineStatusNotificationParser.DeviceNotificationInfo notificationInfo : notificationInfoList) { Log.e("weichongbin1"," brightness = "+notificationInfo.brightness+" connectionStatus = "+notificationInfo.connectionStatus+" meshAddress = "+notificationInfo.meshAddress+" reserve = "+notificationInfo.reserve+" status = "+notificationInfo.status); int meshAddress = notificationInfo.meshAddress; int brightness = notificationInfo.brightness; int temperature = notificationInfo.reserve; Device device = DeviceMange.getInstance().getDeviceByMesh(meshAddress); if (device != null) { device.setMeshAddress(meshAddress); if (notificationInfo.connectionStatus != ConnectionStatus.OFF) { device.setBrightness(brightness); device.setTemperature(temperature); Log.e("weichongbin1","裝置上報狀態設定"); } device.setConnectionStatus(notificationInfo.connectionStatus); CtrlDeviceHandler.handler.removeMessages(meshAddress); } }
發現這邊原來裝置上報狀態的時候,只儲存了亮度沒儲存色溫 新增後驗證 就沒問題了