|
@@ -3,6 +3,7 @@ package com.yingyang.workbenches.leisurebrain
|
|
|
import androidx.recyclerview.widget.GridLayoutManager
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
|
+import com.yingyang.workbenches.R
|
|
|
import com.yingyang.workbenches.adapter.LeisureBrainListAdapter
|
|
|
import com.yingyang.workbenches.adapter.LeisureBrainTypeAdapter
|
|
|
import com.yingyang.workbenches.databinding.ActivityLeisureBrainBinding
|
|
@@ -32,6 +33,7 @@ class LeisureBrainActivity :
|
|
|
/**
|
|
|
* 休闲健脑列表
|
|
|
*/
|
|
|
+ private var gridLayoutManager: GridLayoutManager? = null
|
|
|
private var leisureBrainList = mutableListOf<LeisureBrainBean>()
|
|
|
private val leisureBrainListAdapter by lazy { LeisureBrainListAdapter() }
|
|
|
|
|
@@ -53,21 +55,22 @@ class LeisureBrainActivity :
|
|
|
videoType = bean.dictValue
|
|
|
binding {
|
|
|
rvLeisureBrain.show(true)
|
|
|
- emptyLayout.show(false)
|
|
|
}
|
|
|
+ leisureBrainListAdapter.showEmptyView = false
|
|
|
getLeisureBrainList()
|
|
|
}
|
|
|
|
|
|
//休闲健脑列表
|
|
|
- rvLeisureBrain.layoutManager = GridLayoutManager(this@LeisureBrainActivity, 4)
|
|
|
+ gridLayoutManager = GridLayoutManager(this@LeisureBrainActivity, 4)
|
|
|
+ rvLeisureBrain.layoutManager = gridLayoutManager
|
|
|
rvLeisureBrain.adapter = leisureBrainListAdapter
|
|
|
leisureBrainListAdapter.onLeisureBrainTypeClickListener = { bean ->
|
|
|
ARouter.getInstance().build(RouterUrlCommon.videoPlayer)
|
|
|
.withString("url", bean.videoUrl)
|
|
|
.withString("title", bean.videoName)
|
|
|
.withTransition(
|
|
|
- com.yingyangfly.baselib.R.anim.leftin,
|
|
|
- com.yingyangfly.baselib.R.anim.leftout
|
|
|
+ R.anim.leftin,
|
|
|
+ R.anim.leftout
|
|
|
)
|
|
|
.navigation(mContext)
|
|
|
}
|
|
@@ -106,7 +109,6 @@ class LeisureBrainActivity :
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
override fun onResume() {
|
|
|
super.onResume()
|
|
|
getLeisureBrainList()
|
|
@@ -125,8 +127,12 @@ class LeisureBrainActivity :
|
|
|
if (it.isNullOrEmpty().not()) {
|
|
|
leisureBrainList.addAll(it!!)
|
|
|
}
|
|
|
- binding.rvLeisureBrain.show(leisureBrainList.isNullOrEmpty().not())
|
|
|
- binding.emptyLayout.show(leisureBrainList.isNullOrEmpty())
|
|
|
+ if (leisureBrainList.isNullOrEmpty()) {
|
|
|
+ gridLayoutManager?.spanCount = 1
|
|
|
+ } else {
|
|
|
+ gridLayoutManager?.spanCount = 4
|
|
|
+ }
|
|
|
+ leisureBrainListAdapter.showEmptyView = leisureBrainList.isNullOrEmpty()
|
|
|
leisureBrainListAdapter.setData(leisureBrainList)
|
|
|
})
|
|
|
}
|