Browse Source

1.修改recycleview数据为为空时页面展示

王鹏鹏 2 years ago
parent
commit
b495484682

+ 0 - 2
baselib/build.gradle

@@ -93,8 +93,6 @@ dependencies {
     api(rootProject.ext.androidx.multidex)
     //SmartRefreshLayout:下拉刷新, 上拉加载更多  https://github.com/scwang90/SmartRefreshLayout
     api(rootProject.ext.dependencies.smartRefreshLayout)
-    api(rootProject.ext.dependencies.refresh_header_classics)
-    api(rootProject.ext.dependencies.refresh_footer_classics)
     // jsbridge :https://github.com/lzyzsd/JsBridge
     api(rootProject.ext.dependencies.jsbridge)
     // 基础依赖包,必须要依赖   https://github.com/gyf-dev/ImmersionBar

+ 2 - 2
baselib/src/main/java/com/yingyangfly/baselib/base/BaseActivity.kt

@@ -15,8 +15,8 @@ import androidx.appcompat.app.AppCompatActivity
 import androidx.databinding.ViewDataBinding
 import androidx.fragment.app.Fragment
 import com.alibaba.android.arouter.launcher.ARouter
-import com.scwang.smart.refresh.layout.api.RefreshLayout
-import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener
+import com.scwang.smartrefresh.layout.api.RefreshLayout
+import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener
 import com.yingyangfly.baselib.R
 import com.yingyangfly.baselib.databinding.ActivityBaseBinding
 import com.yingyangfly.baselib.dialog.LoadingDialog

+ 2 - 2
baselib/src/main/java/com/yingyangfly/baselib/base/BaseFragment.kt

@@ -9,8 +9,8 @@ import android.widget.LinearLayout
 import androidx.databinding.ViewDataBinding
 import androidx.fragment.app.Fragment
 import com.alibaba.android.arouter.launcher.ARouter
-import com.scwang.smart.refresh.layout.api.RefreshLayout
-import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener
+import com.scwang.smartrefresh.layout.api.RefreshLayout
+import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener
 import com.yingyangfly.baselib.R
 import com.yingyangfly.baselib.databinding.ActivityBaseBinding
 import com.yingyangfly.baselib.dialog.LoadingDialog

+ 2 - 2
baselib/src/main/java/com/yingyangfly/baselib/base/BaseFragmentActivity.kt

@@ -18,8 +18,8 @@ import androidx.databinding.ViewDataBinding
 import androidx.fragment.app.Fragment
 import androidx.fragment.app.FragmentActivity
 import com.alibaba.android.arouter.launcher.ARouter
-import com.scwang.smart.refresh.layout.api.RefreshLayout
-import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener
+import com.scwang.smartrefresh.layout.api.RefreshLayout
+import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener
 import com.yingyangfly.baselib.R
 import com.yingyangfly.baselib.databinding.ActivityBaseBinding
 import com.yingyangfly.baselib.dialog.LoadingDialog

+ 3 - 11
baselib/src/main/res/layout/activity_base.xml

@@ -8,25 +8,17 @@
         android:background="@android:color/white"
         android:orientation="vertical">
 
-        <com.scwang.smart.refresh.layout.SmartRefreshLayout
+        <com.scwang.smartrefresh.layout.SmartRefreshLayout
             android:id="@+id/smartRefreshLayout"
             android:layout_width="match_parent"
             android:layout_height="match_parent">
 
-            <com.scwang.smart.refresh.header.ClassicsHeader
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content" />
-
             <LinearLayout
                 android:id="@+id/llyt_content"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
-                android:orientation="vertical"/>
-
-            <com.scwang.smart.refresh.footer.ClassicsFooter
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content" />
-        </com.scwang.smart.refresh.layout.SmartRefreshLayout>
+                android:orientation="vertical" />
+        </com.scwang.smartrefresh.layout.SmartRefreshLayout>
 
     </LinearLayout>
 </layout>

+ 1 - 3
config.gradle

@@ -93,9 +93,7 @@ ext {
             //  多渠道打包
             "walle"                    : "com.meituan.android.walle:library:1.1.6",
             //SmartRefreshLayout:下拉刷新, 上拉加载更多  https://github.com/scwang90/SmartRefreshLayout
-            "smartRefreshLayout"       : 'io.github.scwang90:refresh-layout-kernel:2.0.6',
-            "refresh_header_classics"  : 'io.github.scwang90:refresh-header-classics:2.0.6',    //经典刷新头
-            "refresh_footer_classics"  : 'io.github.scwang90:refresh-footer-classics:2.0.6',    //经典加载
+            "smartRefreshLayout"       : 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0',
 
             //RxJava2.0
             "rxjava"                   : 'io.reactivex.rxjava2:rxjava:2.2.20',

+ 22 - 14
livebroadcast/src/main/java/com/yingyang/livebroadcast/activity/list/LiveBroadcastListActivity.kt

@@ -3,6 +3,7 @@ package com.yingyang.livebroadcast.activity.list
 import androidx.recyclerview.widget.GridLayoutManager
 import com.alibaba.android.arouter.facade.annotation.Route
 import com.alibaba.android.arouter.launcher.ARouter
+import com.scwang.smartrefresh.layout.api.RefreshLayout
 import com.yingyang.livebroadcast.R
 import com.yingyang.livebroadcast.adapter.LiveBroadcastAdapter
 import com.yingyang.livebroadcast.databinding.ActivityLiveBroadcastListBinding
@@ -11,6 +12,7 @@ import com.yingyang.livebroadcast.entity.ReservationLiveBean
 import com.yingyang.livebroadcast.net.XLivebroadcastServiceFactory
 import com.yingyangfly.baselib.dialog.TipDialogFragment
 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
@@ -55,6 +57,8 @@ class LiveBroadcastListActivity :
     private val liveBroadcastAdapter by lazy { LiveBroadcastAdapter() }
 
     override fun initViews() {
+        enableLoadMore(true)
+        enableRefresh(true)
         binding {
             rvLiveBroadcast.layoutManager = GridLayoutManager(mContext, 2)
             rvLiveBroadcast.adapter = liveBroadcastAdapter
@@ -102,6 +106,16 @@ class LiveBroadcastListActivity :
         }
     }
 
+    override fun onRefresh(refreshLayout: RefreshLayout) {
+        super.onRefresh(refreshLayout)
+        loadData(true)
+    }
+
+    override fun onLoadMore(refreshLayout: RefreshLayout) {
+        super.onLoadMore(refreshLayout)
+        loadData(false)
+    }
+
     /**
      * 预约直播
      */
@@ -131,14 +145,6 @@ class LiveBroadcastListActivity :
                 JumpUtil.jumpActivity(RouterUrlCommon.home, mContext)
                 finish()
             }
-            //下拉刷新列表
-            swipeLiveBroadcast.setOnRefreshListener {
-                loadData(true)
-            }
-            //上拉加载更多列表
-            swipeLiveBroadcast.setOnLoadMoreListener {
-                loadData(false)
-            }
         }
     }
 
@@ -153,7 +159,7 @@ class LiveBroadcastListActivity :
     private fun loadData(isRefresh: Boolean) {
         if (isRefresh) {
             liveBroadcastList.clear()
-            binding.swipeLiveBroadcast.resetNoMoreData()
+            resetNoMoreData()
             page = 1
         } else {
             page++
@@ -167,7 +173,11 @@ class LiveBroadcastListActivity :
                 liveBroadcastList.addAll(it.records)
             }
             if (page >= it.pages) {
-                binding.swipeLiveBroadcast.finishLoadMoreWithNoMoreData()
+                finishLoadMoreWithNoMoreData()
+            }
+            binding {
+                rvLiveBroadcast.show(liveBroadcastList.isNullOrEmpty().not())
+                emptyLayout.show(liveBroadcastList.isNullOrEmpty())
             }
             liveBroadcastAdapter.setData(liveBroadcastList)
         })
@@ -177,10 +187,8 @@ class LiveBroadcastListActivity :
      * 结束刷新状态
      */
     private fun endRefresh() {
-        binding {
-            swipeLiveBroadcast.finishRefresh()
-            swipeLiveBroadcast.finishLoadMore()
-        }
+        finishRefresh()
+        finishLoadMore()
     }
 
     /**

+ 15 - 14
livebroadcast/src/main/res/layout/activity_live_broadcast_list.xml

@@ -72,8 +72,8 @@
                 android:text="@string/live_playback" />
         </RadioGroup>
 
-        <com.scwang.smart.refresh.layout.SmartRefreshLayout
-            android:id="@+id/swipeLiveBroadcast"
+        <androidx.recyclerview.widget.RecyclerView
+            android:id="@+id/rvLiveBroadcast"
             android:layout_width="match_parent"
             android:layout_height="0dp"
             android:layout_marginLeft="@dimen/divider_60px"
@@ -82,22 +82,23 @@
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintLeft_toLeftOf="parent"
             app:layout_constraintRight_toRightOf="parent"
-            app:layout_constraintTop_toBottomOf="@+id/radioLive">
+            app:layout_constraintTop_toBottomOf="@+id/radioLive" />
 
-            <com.scwang.smart.refresh.header.ClassicsHeader
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content" />
+        <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/radioLive"
+            tools:ignore="MissingConstraints">
 
-            <androidx.recyclerview.widget.RecyclerView
-                android:id="@+id/rvLiveBroadcast"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent" />
+            <androidx.appcompat.widget.AppCompatImageView style="@style/empty_image_view_style" />
 
-            <com.scwang.smart.refresh.footer.ClassicsFooter
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content" />
+            <androidx.appcompat.widget.AppCompatTextView style="@style/empty_text_view_style" />
 
-        </com.scwang.smart.refresh.layout.SmartRefreshLayout>
+        </LinearLayout>
 
 
     </androidx.constraintlayout.widget.ConstraintLayout>

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

@@ -77,29 +77,19 @@
                     app:layout_constraintRight_toRightOf="parent"
                     app:layout_constraintTop_toTopOf="parent" />
 
-                <com.scwang.smart.refresh.layout.SmartRefreshLayout
-                    android:id="@+id/layoutPush"
+                <androidx.recyclerview.widget.RecyclerView
+                    android:id="@+id/rvPush"
                     android:layout_width="match_parent"
                     android:layout_height="0dp"
                     android:layout_marginStart="@dimen/divider_36px"
                     android:layout_marginTop="@dimen/divider_12px"
                     android:layout_marginEnd="@dimen/divider_36px"
+                    app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                     app:layout_constraintBottom_toBottomOf="parent"
                     app:layout_constraintLeft_toLeftOf="parent"
                     app:layout_constraintRight_toRightOf="parent"
-                    app:layout_constraintTop_toBottomOf="@+id/tvTitle">
+                    app:layout_constraintTop_toBottomOf="@+id/tvTitle" />
 
-                    <com.scwang.smart.refresh.header.ClassicsHeader
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content" />
-
-                    <androidx.recyclerview.widget.RecyclerView
-                        android:id="@+id/rvPush"
-                        android:layout_width="match_parent"
-                        android:layout_height="match_parent"
-                        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
-
-                </com.scwang.smart.refresh.layout.SmartRefreshLayout>
 
             </androidx.constraintlayout.widget.ConstraintLayout>
         </androidx.cardview.widget.CardView>