Sfoglia il codice sorgente

feat: 兼容后端异常逻辑

XiaodongLin 7 mesi fa
parent
commit
2be8e4e2d6

+ 15 - 6
module/wallet/src/main/java/com/adealink/weparty/wallet/component/RechargeDailyComp.kt

@@ -80,7 +80,12 @@ class RechargeDailyComp(
 
 
     fun initDataWithOnlyWeekly() {
-        rechargeDailyViewModel?.getWeeklyRechargeProgress()?.observe(viewLifecycleOwner) {
+        rechargeDailyViewModel?.getWeeklyRechargeProgress()?.observe(viewLifecycleOwner) { it->
+            if (it==null){
+                binding.onlyWeeklyLayout.gone()
+                return@observe
+            }
+            binding.onlyWeeklyLayout.show()
             val countDownTime = it?.countdown ?: 0
             if (countDownTime > 1) {
                 binding.onlyWeeklyCountDownView.show()
@@ -144,9 +149,15 @@ class RechargeDailyComp(
                     .show(requireActivity().supportFragmentManager)
 
             }
+            binding.dailyLayout.show()
         }
 
-        rechargeDailyViewModel?.getWeeklyRechargeProgress()?.observe(viewLifecycleOwner) {
+        rechargeDailyViewModel?.getWeeklyRechargeProgress()?.observe(viewLifecycleOwner) { it ->
+            if (it==null){
+                binding.weeklyLayout.gone()
+                return@observe
+            }
+            binding.weeklyLayout.show()
             val countDownTime = it?.countdown ?: 0
             if (countDownTime > 1) {
                 binding.weeklyCountDownView.show()
@@ -185,6 +196,7 @@ class RechargeDailyComp(
                     .show(requireActivity().supportFragmentManager)
 
             }
+            binding.weeklyLayout.show()
         }
     }
 
@@ -205,14 +217,11 @@ class RechargeDailyComp(
         }
         rechargeDailyViewModel?.allowDailyRechargeLD?.observe(viewLifecycleOwner) {
             if (it) {
-                binding.dailyLayout.show()
-                binding.weeklyLayout.show()
-                binding.onlyWeeklyLayout.gone()
                 initDataWithDaylyAndWeekly()
+                binding.onlyWeeklyLayout.gone()
             } else {
                 binding.dailyLayout.gone()
                 binding.weeklyLayout.gone()
-                binding.onlyWeeklyLayout.show()
                 initDataWithOnlyWeekly()
             }
             binding.root.show()

+ 4 - 7
module/wallet/src/main/res/layout/layout_recharge_daily.xml

@@ -50,6 +50,7 @@
         android:layout_height="76dp"
         android:layout_marginStart="10dp"
         android:layout_marginBottom="13dp"
+        android:visibility="gone"
         android:background="@drawable/wallet_recharge_item_task_bg"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toStartOf="@+id/weekly_layout"
@@ -138,6 +139,7 @@
         android:layout_height="76dp"
         android:layout_marginStart="8dp"
         android:layout_marginBottom="13dp"
+        android:visibility="gone"
         android:background="@drawable/wallet_recharge_item_task_bg"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
@@ -219,17 +221,12 @@
 
     </androidx.constraintlayout.widget.ConstraintLayout>
 
-    <androidx.constraintlayout.widget.Group
-        android:id="@+id/day_and_weekly_group"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:visibility="gone"
-        app:constraint_referenced_ids="daily_layout,weekly_layout" />
-
     <androidx.constraintlayout.widget.ConstraintLayout
         android:id="@+id/only_weekly_layout"
         android:layout_width="327dp"
         android:layout_height="87dp"
+        android:visibility="gone"
+        tools:visibility="visible"
         android:layout_marginHorizontal="12dp"
         android:layout_marginBottom="13dp"
         android:background="@drawable/wallet_recharge_only_week_task_bg"