From b7ee99a71e88a08a09fe9daada6675a175d09be1 Mon Sep 17 00:00:00 2001
From: zhuguifei <zhuguifei@zhuguifeideiMac.local>
Date: 星期三, 14 一月 2026 10:35:27 +0800
Subject: [PATCH] 部分优化

---
 app/src/main/java/com/shlb/comb/activity/AdvancedSettingActivity.java |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/app/src/main/java/com/shlb/comb/activity/AdvancedSettingActivity.java b/app/src/main/java/com/shlb/comb/activity/AdvancedSettingActivity.java
index b61f980..2abfc59 100644
--- a/app/src/main/java/com/shlb/comb/activity/AdvancedSettingActivity.java
+++ b/app/src/main/java/com/shlb/comb/activity/AdvancedSettingActivity.java
@@ -37,6 +37,8 @@
     private TextView tv_sensor_status;
     private StringBuilder logBuilder = new StringBuilder();
     private String currentExecutingCmd = "";
+    private View currentOperatingButton;
+
 
     @Override
     protected void contentView() {
@@ -96,18 +98,26 @@
                 int id = v.getId();
                 String action = "";
                 if (id == R.id.btn_mainboard_read) {
+                    currentOperatingButton = btn_mainboard_read;
+                    updateButtonState(currentOperatingButton, false);
                     action = "璇诲彇涓绘澘鐗堟湰";
                     currentExecutingCmd = CMD.READ_BOARD_VERSION;
                     sendCmdWithCrc(CMD.READ_BOARD_VERSION);
                 } else if (id == R.id.btn_display_read) {
+                    currentOperatingButton = btn_display_read;
+                    updateButtonState(currentOperatingButton, false);
                     action = "璇诲彇浼犳劅鍣ㄧ増鏈�";
                     currentExecutingCmd = CMD.READ_SENSOR_VERSION;
                     sendCmdWithCrc(CMD.READ_SENSOR_VERSION);
                 } else if (id == R.id.btn_start_addressing) {
+                    currentOperatingButton = btn_start_addressing;
+                    updateButtonState(currentOperatingButton, false);
                     action = "寮�濮嬬紪鍧�";
                     currentExecutingCmd = CMD.WRITE_START_ADDRESS;
                     sendCmdWithCrc(CMD.WRITE_START_ADDRESS);
                 } else if (id == R.id.btn_end_addressing) {
+                    currentOperatingButton = btn_end_addressing;
+                    updateButtonState(currentOperatingButton, false);
                     action = "缁撴潫缂栧潃";
                     currentExecutingCmd = CMD.WRITE_END_ADDRESS;
                     sendCmdWithCrc(CMD.WRITE_END_ADDRESS);
@@ -265,6 +275,24 @@
         }
     }
 
+    private void updateButtonState(View btn, boolean enable) {
+        if (btn == null) return;
+        btn.setEnabled(enable);
+        if (enable) {
+            btn.getBackground().clearColorFilter();
+        } else {
+            btn.getBackground().setColorFilter(android.graphics.Color.GRAY, android.graphics.PorterDuff.Mode.MULTIPLY);
+        }
+    }
+
+    private void restoreCurrentButton() {
+        if (currentOperatingButton != null) {
+            updateButtonState(currentOperatingButton, true);
+            currentOperatingButton = null;
+        }
+    }
+
+
     @Subscribe(threadMode = ThreadMode.MAIN)
     public void onEvent(UpdateEvent event) {
         if (event.getType() == UpdateEvent.Type.CONN_STATU) {
@@ -284,12 +312,14 @@
 
         // 鍐欏叆鎸囦护鐨勮繑鍥� (A55A06寮�澶�)
         if (hex.startsWith("A55A06") && hex.length() >= 12) {
+            restoreCurrentButton();
             parseWriteResponse(hex);
             return;
         }
 
         // 璇诲彇鎸囦护鐨勮繑鍥� (A55A03寮�澶�)
         if (hex.startsWith("A55A03") && hex.length() >= 8) {
+             restoreCurrentButton();
              parseReadResponse(hex);
         }
     }

--
Gitblit v1.9.3