|
|
@@ -52,8 +52,11 @@ class LiveBroadcastListActivity :
|
|
|
private val liveBroadcastAdapter by lazy { LiveBroadcastAdapter() }
|
|
|
|
|
|
override fun initViews() {
|
|
|
- enableLoadMore(true)
|
|
|
- enableRefresh(true)
|
|
|
+ binding {
|
|
|
+ liveSwipe.setEnableLoadMore(true)
|
|
|
+ liveSwipe.setEnableRefresh(true)
|
|
|
+ }
|
|
|
+
|
|
|
binding {
|
|
|
gridLayoutManager = GridLayoutManager(mContext, 2)
|
|
|
rvLiveBroadcast.layoutManager = gridLayoutManager
|
|
|
@@ -87,35 +90,23 @@ class LiveBroadcastListActivity :
|
|
|
R.id.rdb_appointment -> {
|
|
|
method = "1"
|
|
|
liveBroadcastAdapter.setType("预约直播")
|
|
|
- loadData(true)
|
|
|
+ loadData(true, true)
|
|
|
}
|
|
|
R.id.rdb_live -> {
|
|
|
method = "2"
|
|
|
liveBroadcastAdapter.setType("直播中")
|
|
|
- loadData(true)
|
|
|
+ loadData(true, true)
|
|
|
}
|
|
|
else -> {
|
|
|
method = "3"
|
|
|
liveBroadcastAdapter.setType("直播回放")
|
|
|
- loadData(true)
|
|
|
+ loadData(true, true)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- override fun onRefresh(refreshLayout: RefreshLayout) {
|
|
|
- super.onRefresh(refreshLayout)
|
|
|
- loadData(true)
|
|
|
- liveBroadcastAdapter.clearData()
|
|
|
- liveBroadcastAdapter.showEmptyView = false
|
|
|
- }
|
|
|
-
|
|
|
- override fun onLoadMore(refreshLayout: RefreshLayout) {
|
|
|
- super.onLoadMore(refreshLayout)
|
|
|
- loadData(false)
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 预约直播
|
|
|
*/
|
|
|
@@ -123,7 +114,7 @@ class LiveBroadcastListActivity :
|
|
|
viewModel.reservationLive(method, fail = {
|
|
|
it.show()
|
|
|
}, success = {
|
|
|
- loadData(true)
|
|
|
+ loadData(true, true)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -133,6 +124,15 @@ class LiveBroadcastListActivity :
|
|
|
JumpUtil.jumpActivity(RouterUrlCommon.home, mContext)
|
|
|
finish()
|
|
|
}
|
|
|
+
|
|
|
+ liveSwipe.setOnRefreshListener {
|
|
|
+ liveBroadcastAdapter.clearData()
|
|
|
+ liveBroadcastAdapter.showEmptyView = false
|
|
|
+ loadData(true, false)
|
|
|
+ }
|
|
|
+ liveSwipe.setOnLoadMoreListener {
|
|
|
+ loadData(false, false)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -140,22 +140,22 @@ class LiveBroadcastListActivity :
|
|
|
liveBroadcastAdapter.setType("预约直播")
|
|
|
liveBroadcastAdapter.clearData()
|
|
|
liveBroadcastAdapter.showEmptyView = false
|
|
|
- loadData(true)
|
|
|
+ loadData(true, true)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取直播列表
|
|
|
*/
|
|
|
- private fun loadData(isRefresh: Boolean) {
|
|
|
+ private fun loadData(isRefresh: Boolean, showLoading: Boolean) {
|
|
|
if (isRefresh) {
|
|
|
liveBroadcastList.clear()
|
|
|
liveBroadcastAdapter.clearData()
|
|
|
- resetNoMoreData()
|
|
|
+ binding.liveSwipe.resetNoMoreData()
|
|
|
page = 1
|
|
|
} else {
|
|
|
page++
|
|
|
}
|
|
|
- viewModel.getLiveList(method, page, fail = {
|
|
|
+ viewModel.getLiveList(showLoading, method, page, fail = {
|
|
|
endRefresh()
|
|
|
it.toast()
|
|
|
}, success = {
|
|
|
@@ -165,7 +165,7 @@ class LiveBroadcastListActivity :
|
|
|
liveBroadcastList.addAll(it.records)
|
|
|
}
|
|
|
if (page >= it.pages) {
|
|
|
- finishLoadMoreWithNoMoreData()
|
|
|
+ binding.liveSwipe.finishLoadMoreWithNoMoreData()
|
|
|
}
|
|
|
}
|
|
|
if (liveBroadcastList.isNullOrEmpty()) {
|
|
|
@@ -182,8 +182,10 @@ class LiveBroadcastListActivity :
|
|
|
* 结束刷新状态
|
|
|
*/
|
|
|
private fun endRefresh() {
|
|
|
- finishRefresh()
|
|
|
- finishLoadMore()
|
|
|
+ binding {
|
|
|
+ liveSwipe.finishRefresh()
|
|
|
+ liveSwipe.finishLoadMore()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|