From 3e4f923cedc17a0d56d045cb9afda8d6f903b988 Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期四, 06 三月 2025 15:04:39 +0800
Subject: [PATCH] fix: 热力图矩阵

---
 app/src/main/res/layout/layout_year_stats.xml                            |  136 ++++++++++++++++++----------------
 app/src/main/java/com/example/firstapp/ui/dashboard/DashboardFragment.kt |   10 +-
 app/src/main/res/layout/layout_week_stats.xml                            |   48 +++++------
 3 files changed, 100 insertions(+), 94 deletions(-)

diff --git a/app/src/main/java/com/example/firstapp/ui/dashboard/DashboardFragment.kt b/app/src/main/java/com/example/firstapp/ui/dashboard/DashboardFragment.kt
index dadbe96..8a67903 100644
--- a/app/src/main/java/com/example/firstapp/ui/dashboard/DashboardFragment.kt
+++ b/app/src/main/java/com/example/firstapp/ui/dashboard/DashboardFragment.kt
@@ -504,7 +504,7 @@
                 binding.recyclerPackages.visibility = View.VISIBLE
                 binding.layoutWeekStats.root.visibility = View.GONE
                 binding.layoutYearStats.root.visibility = View.GONE
-                binding.cardPackageStats.visibility = View.VISIBLE  // 显示包裹统计卡片
+                binding.cardPackageStats.visibility = View.VISIBLE
             }
             DateType.WEEK, DateType.MONTH -> {
                 // 周和月视图显示柱状图和饼图,隐藏包裹列表
@@ -513,7 +513,7 @@
                 binding.layoutYearStats.root.visibility = View.GONE
                 binding.layoutWeekStats.chartDailyPackages.visibility = View.VISIBLE
                 binding.layoutWeekStats.heatmapYearly.visibility = View.GONE
-                binding.cardPackageStats.visibility = View.VISIBLE  // 显示包裹统计卡片
+                binding.cardPackageStats.visibility = View.VISIBLE
                 updateBarChartData()
                 updatePieChartData()
             }
@@ -522,12 +522,12 @@
                 binding.recyclerPackages.visibility = View.GONE
                 binding.layoutWeekStats.root.visibility = View.VISIBLE
                 binding.layoutYearStats.root.visibility = View.VISIBLE
-                binding.layoutWeekStats.chartDailyPackages.visibility = View.GONE
+                (binding.layoutWeekStats.chartDailyPackages.parent as? View)?.visibility = View.GONE
                 binding.layoutWeekStats.heatmapYearly.visibility = View.VISIBLE
-                binding.cardPackageStats.visibility = View.GONE  // 隐藏包裹统计卡片
+                binding.cardPackageStats.visibility = View.GONE
                 updateHeatmapData()
                 updatePieChartData()
-                updateYearlyStats()  // 更新年度统计数据
+                updateYearlyStats()
             }
         }
     }
diff --git a/app/src/main/res/layout/layout_week_stats.xml b/app/src/main/res/layout/layout_week_stats.xml
index e0cb566..ba1c006 100644
--- a/app/src/main/res/layout/layout_week_stats.xml
+++ b/app/src/main/res/layout/layout_week_stats.xml
@@ -19,6 +19,28 @@
             android:padding="16dp" />
     </androidx.cardview.widget.CardView>
 
+    <!-- 热力图容器 -->
+    <androidx.cardview.widget.CardView
+        android:id="@+id/heatmap_yearly"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginHorizontal="16dp"
+        android:layout_marginBottom="16dp">
+
+        <HorizontalScrollView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:padding="16dp">
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal">
+                <!-- 热力图将在这里动态添加 -->
+            </LinearLayout>
+        </HorizontalScrollView>
+    </androidx.cardview.widget.CardView>
+
     <!-- 饼图容器 -->
     <androidx.cardview.widget.CardView
         android:layout_width="match_parent"
@@ -33,28 +55,4 @@
             android:padding="16dp" />
     </androidx.cardview.widget.CardView>
 
-    <!-- 热力图容器 -->
-    <androidx.cardview.widget.CardView
-        android:id="@+id/heatmap_yearly"
-        android:layout_width="match_parent"
-        android:layout_height="280dp"
-        android:layout_marginHorizontal="16dp"
-        android:layout_marginTop="8dp"
-        android:layout_marginBottom="16dp"
-        android:visibility="gone">
-
-        <HorizontalScrollView
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:padding="16dp">
-
-            <LinearLayout
-                android:layout_width="wrap_content"
-                android:layout_height="match_parent"
-                android:orientation="horizontal">
-                <!-- 热力图将在这里动态添加 -->
-            </LinearLayout>
-        </HorizontalScrollView>
-    </androidx.cardview.widget.CardView>
-
-</LinearLayout> 
\ No newline at end of file
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/layout_year_stats.xml b/app/src/main/res/layout/layout_year_stats.xml
index aa8a654..45e26af 100644
--- a/app/src/main/res/layout/layout_year_stats.xml
+++ b/app/src/main/res/layout/layout_year_stats.xml
@@ -1,76 +1,84 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="horizontal"
-    android:padding="16dp">
+    android:layout_marginHorizontal="16dp"
+    android:layout_marginTop="8dp"
+    android:layout_marginBottom="16dp">
 
-    <!-- 年度包裹总数 -->
     <LinearLayout
-        android:layout_width="0dp"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_weight="1"
-        android:orientation="vertical"
-        android:gravity="center">
+        android:orientation="horizontal"
+        android:padding="16dp">
 
-        <TextView
-            android:id="@+id/text_total_packages"
-            android:layout_width="wrap_content"
+        <!-- 年度包裹总数 -->
+        <LinearLayout
+            android:layout_width="0dp"
             android:layout_height="wrap_content"
-            android:textSize="24sp"
-            android:textStyle="bold"
-            android:textColor="@color/purple_500"
-            android:text="4"/>
+            android:layout_weight="1"
+            android:orientation="vertical"
+            android:gravity="center">
 
-        <TextView
-            android:layout_width="wrap_content"
+            <TextView
+                android:id="@+id/text_total_packages"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="24sp"
+                android:textStyle="bold"
+                android:textColor="@color/purple_500"
+                android:text="4"/>
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="4dp"
+                android:text="年度包裹总数"
+                android:textSize="12sp"/>
+
+            <ImageView
+                android:layout_width="24dp"
+                android:layout_height="24dp"
+                android:layout_marginTop="8dp"
+                android:src="@drawable/resource_package"/>
+        </LinearLayout>
+
+        <!-- 分隔线 -->
+        <View
+            android:layout_width="1dp"
+            android:layout_height="match_parent"
+            android:background="#E0E0E0"/>
+
+        <!-- 平均每天包裹数 -->
+        <LinearLayout
+            android:layout_width="0dp"
             android:layout_height="wrap_content"
-            android:layout_marginTop="4dp"
-            android:text="年度包裹总数"
-            android:textSize="12sp"/>
+            android:layout_weight="1"
+            android:orientation="vertical"
+            android:gravity="center">
 
-        <ImageView
-            android:layout_width="24dp"
-            android:layout_height="24dp"
-            android:layout_marginTop="8dp"
-            android:src="@drawable/resource_package"/>
+            <TextView
+                android:id="@+id/text_daily_average"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="24sp"
+                android:textStyle="bold"
+                android:textColor="@color/purple_500"
+                android:text="0.29"/>
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="4dp"
+                android:text="平均每天包裹数"
+                android:textSize="12sp"/>
+
+            <ImageView
+                android:layout_width="24dp"
+                android:layout_height="24dp"
+                android:layout_marginTop="8dp"
+                android:src="@drawable/avg_package"/>
+        </LinearLayout>
+
     </LinearLayout>
-
-    <!-- 分隔线 -->
-    <View
-        android:layout_width="1dp"
-        android:layout_height="match_parent"
-        android:background="#E0E0E0"/>
-
-    <!-- 平均每天包裹数 -->
-    <LinearLayout
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        android:layout_weight="1"
-        android:orientation="vertical"
-        android:gravity="center">
-
-        <TextView
-            android:id="@+id/text_daily_average"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textSize="24sp"
-            android:textStyle="bold"
-            android:textColor="@color/purple_500"
-            android:text="0.29"/>
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="4dp"
-            android:text="平均每天包裹数"
-            android:textSize="12sp"/>
-
-        <ImageView
-            android:layout_width="24dp"
-            android:layout_height="24dp"
-            android:layout_marginTop="8dp"
-            android:src="@drawable/avg_package"/>
-    </LinearLayout>
-
-</LinearLayout> 
\ No newline at end of file
+</androidx.cardview.widget.CardView> 
\ No newline at end of file

--
Gitblit v1.9.3