From e5a090685df3d5e96a37b141d9a1d002d36f16f2 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期五, 14 二月 2025 16:53:43 +0800
Subject: [PATCH] 1.web地图添加管网显示。 2.安卓原生添加管网信息的获取。 3.安卓原生添加管网信息的本地持久化(SQLite数据库)。 4.实现图例用户的选择状态按钮的持久化。 5.实现自定义搜索按钮的实现。 6.实现搜索后弹出界面的相关功能开发。

---
 expand_button/src/main/java/com/example/expand_button/ExpandButton.kt |   57 +++++++++++++++++++--------------------------------------
 1 files changed, 19 insertions(+), 38 deletions(-)

diff --git a/expand_button/src/main/java/com/example/expand_button/ExpandButton.kt b/expand_button/src/main/java/com/example/expand_button/ExpandButton.kt
index 3671c76..007713c 100644
--- a/expand_button/src/main/java/com/example/expand_button/ExpandButton.kt
+++ b/expand_button/src/main/java/com/example/expand_button/ExpandButton.kt
@@ -499,49 +499,20 @@
     fun setButtonId(id: String) {
         this.buttonId = id
         // 鍔犺浇淇濆瓨鐨勭姸鎬�
-        loadStates()
+
     }
 
-    /**
-     * 淇濆瓨鎵�鏈夊浘渚嬮」鐨勭姸鎬�
-     */
-    private fun saveStates() {
-        val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
-        val states = legendItems.map { it.isSelected }
-        prefs.edit().putString("${KEY_LEGEND_STATES}_$buttonId", states.joinToString(",")).apply()
-    }
-
-    /**
-     * 鍔犺浇淇濆瓨鐨勭姸鎬�
-     */
-    private fun loadStates() {
-        val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
-        val savedStates = prefs.getString("${KEY_LEGEND_STATES}_$buttonId", null)
-        
-        if (savedStates != null && legendItems.isNotEmpty()) {
-            val states = savedStates.split(",").map { it.toBoolean() }
-            states.forEachIndexed { index, state ->
-                if (index < legendItems.size) {
-                    legendItems[index].isSelected = state
-                }
-            }
-            invalidate()
-        }
-    }
 
     /**
      * 璁剧疆鍥句緥鍐呭
      */
     @JvmName("setLegendsList")
-    fun setLegends(items: List<Triple<Drawable, Drawable, String>>) {
-        legendItems = items.map { (selectedIcon, unselectedIcon, description) ->
+    fun setLegends(items: List<Quadruple<Drawable, Drawable, String, Boolean>>) {
+        legendItems = items.map { (selectedIcon, unselectedIcon, description, isSelected) ->
             selectedIcon.setBounds(0, 0, iconSize, iconSize)
             unselectedIcon.setBounds(0, 0, iconSize, iconSize)
-            LegendItem(selectedIcon, unselectedIcon, description)
+            LegendItem(selectedIcon, unselectedIcon, description, isSelected)
         }
-        
-        // 鍔犺浇淇濆瓨鐨勭姸鎬�
-        loadStates()
         
         if (!isExpanded) {
             text = collapsedText
@@ -553,8 +524,21 @@
 
     // 娣诲姞涓�涓� Java 鍙嬪ソ鐨勬柟娉�
     @JvmName("setLegendsArray")
-    fun setLegends(vararg items: Triple<Drawable, Drawable, String>) {
+    fun setLegends(vararg items: Quadruple<Drawable, Drawable, String, Boolean>) {
         setLegends(items.toList())
+    }
+
+    // 娣诲姞涓�涓暟鎹被鏉ヨ〃绀哄洓鍏冪粍
+    data class Quadruple<A, B, C, D>(
+        val first: A,
+        val second: B,
+        val third: C,
+        val fourth: D
+    )
+
+    // 娣诲姞涓�涓究鎹风殑鎵╁睍鍑芥暟鏉ュ垱寤� Quadruple
+    fun <A, B, C, D> quadrupleOf(first: A, second: B, third: C, fourth: D): Quadruple<A, B, C, D> {
+        return Quadruple(first, second, third, fourth)
     }
 
     /**
@@ -635,10 +619,7 @@
             index, 
             legendItems[index].isSelected
         )
-        
-        // 淇濆瓨鐘舵��
-        saveStates()
-        
+
         invalidate()
     }
 

--
Gitblit v1.8.0