|
|
@@ -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()
|
|
|
}
|
|
|
|
|
|
/**
|