Ver Fonte

1.优化接口获取完数据后才展示占位图页面

王鹏鹏 há 2 anos atrás
pai
commit
71f044173f

+ 9 - 1
push/src/main/java/com/yingyang/push/activity/MessgeListActivity.kt

@@ -9,6 +9,7 @@ import com.yingyang.push.entity.PushMessageBean
 import com.yingyang.push.entity.PushMessageTypeBean
 import com.yingyang.push.net.XPushServiceFactory
 import com.yingyangfly.baselib.ext.setOnSingleClickListener
+import com.yingyangfly.baselib.ext.show
 import com.yingyangfly.baselib.ext.toast
 import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
 import com.yingyangfly.baselib.net.BaseObserver
@@ -51,10 +52,13 @@ class MessgeListActivity : BaseMVVMActivity<ActivityMessgeListBinding, PushViewM
             pushTypeAdapter.setData(pushTypeList)
             pushTypeAdapter.onPushClickListener = { bean ->
                 msgType = bean.dictValue
+                binding {
+                    rvPush.show(true)
+                    emptyLayout.show(false)
+                }
                 getMeaageList()
             }
             //消息列表
-            pushListAdapter.showEmptyView = true
             rvPush.adapter = pushListAdapter
             pushListAdapter.onPushClickListener = { bean ->
                 if (TextUtils.equals("0", bean.status).not()) {
@@ -120,6 +124,10 @@ class MessgeListActivity : BaseMVVMActivity<ActivityMessgeListBinding, PushViewM
             if (it.isNullOrEmpty().not()) {
                 pushList.addAll(it)
             }
+            binding {
+                rvPush.show(pushList.isNullOrEmpty().not())
+                emptyLayout.show(pushList.isNullOrEmpty())
+            }
             pushListAdapter.setData(pushList)
         })
     }

+ 14 - 0
push/src/main/res/layout/activity_messge_list.xml

@@ -90,7 +90,21 @@
                     app:layout_constraintRight_toRightOf="parent"
                     app:layout_constraintTop_toBottomOf="@+id/tvTitle" />
 
+                <LinearLayout
+                    android:id="@+id/emptyLayout"
+                    style="@style/empty_linear_layout_style"
+                    android:layout_marginLeft="@dimen/divider_60px"
+                    android:layout_marginTop="@dimen/divider_47px"
+                    android:layout_marginRight="@dimen/divider_60px"
+                    android:visibility="gone"
+                    app:layout_constraintTop_toBottomOf="@+id/tvTitle"
+                    tools:ignore="MissingConstraints">
 
+                    <androidx.appcompat.widget.AppCompatImageView style="@style/empty_image_view_style" />
+
+                    <androidx.appcompat.widget.AppCompatTextView style="@style/empty_text_view_style" />
+
+                </LinearLayout>
             </androidx.constraintlayout.widget.ConstraintLayout>
         </androidx.cardview.widget.CardView>
     </androidx.constraintlayout.widget.ConstraintLayout>

+ 29 - 0
push/src/main/res/values/themes.xml

@@ -0,0 +1,29 @@
+<resources xmlns:tools="http://schemas.android.com/tools">
+    <style name="empty_linear_layout_style" tools:ignore="ResourceName">
+        <item name="android:layout_width">match_parent</item>
+        <item name="android:layout_height">0dp</item>
+        <item name="android:orientation">vertical</item>
+        <item name="layout_constraintBottom_toBottomOf">parent</item>
+        <item name="layout_constraintLeft_toLeftOf">parent</item>
+        <item name="layout_constraintRight_toRightOf">parent</item>
+    </style>
+
+    <style name="empty_image_view_style" tools:ignore="ResourceName">
+        <item name="android:layout_width">wrap_content</item>
+        <item name="android:layout_height">wrap_content</item>
+        <item name="android:layout_gravity">center_horizontal</item>
+        <item name="android:layout_marginTop">@dimen/divider_85px</item>
+        <item name="android:background">@mipmap/icon_empt_data</item>
+    </style>
+
+    <style name="empty_text_view_style" tools:ignore="ResourceName">
+        <item name="android:layout_width">wrap_content</item>
+        <item name="android:layout_height">wrap_content</item>
+        <item name="android:layout_gravity">center_horizontal</item>
+        <item name="android:layout_marginTop">@dimen/divider_32px</item>
+        <item name="android:textSize">@dimen/divider_42px</item>
+        <item name="android:textColor">@color/coloe_D8D8D8</item>
+        <item name="android:paddingEnd">@dimen/divider_18px</item>
+        <item name="android:text">@string/there_is_currently_no_data_available</item>
+    </style>
+</resources>