From 4f7f99c6ea914bcd38de78bd8371be566026b905 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期三, 26 二月 2025 15:54:14 +0800
Subject: [PATCH] -为按钮和列表项添加波纹效果,以获得更好的视觉反馈 -改进MapFragment中的底部布局动画 -在MapFragment中添加设备状态和RTU地址显示 -更新BaseListResult以支持泛型类型 -为设备数据添加IntakeListResult和IntakeResult -通过数据库支持增强标记位置更新功能 -添加电话拨号意图以分隔标记详细信息 -通过过期检查改进磁贴缓存 -添加问题报告的确认对话框 -更新登录活动以限制用户名长度 -为波纹效果和UI元素添加新颜色 -重构XML布局以使用新的波纹图 -改进MapFragment中的错误处理和用户反馈
---
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