...
|
...
|
@@ -3,6 +3,7 @@ package com.br_technology.securitytrain_master.ui.view.home.activity |
|
|
import android.content.Intent
|
|
|
import android.os.Bundle
|
|
|
import android.view.View
|
|
|
import android.widget.Toast
|
|
|
import androidx.core.content.ContextCompat
|
|
|
import com.br_technology.securitytrain_master.R
|
|
|
import com.br_technology.securitytrain_master.base.common.ConstantParamKey
|
...
|
...
|
@@ -21,6 +22,7 @@ import com.br_technology.securitytrain_master.util.sp_job_name_select |
|
|
import com.br_technology.securitytrain_master.view.ClassifyPop
|
|
|
import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener
|
|
|
import com.chad.library.adapter.base.listener.OnLoadMoreListener
|
|
|
import com.luck.picture.lib.tools.ToastUtils
|
|
|
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -72,9 +74,9 @@ class OnlineActivity : |
|
|
VideoCourseAdapter(R.layout.adapter_video_course, videoLessonList)
|
|
|
videoLessonList = mutableListOf()
|
|
|
onlineRecycler.adapter = videoCourseAdapter
|
|
|
videoCourseAdapter?.setOnItemClickListener { adapter, view, position ->
|
|
|
videoCourseAdapter?.setOnClick{
|
|
|
val course = CourseParam()
|
|
|
val data = videoLessonList!![position]
|
|
|
val data = it
|
|
|
course.mLessonId = "${data.id}"
|
|
|
course.isTrainClass = false
|
|
|
course.type = TrainCourseDetailItemType.TYPE_COURSE_DETAIL_ITEM_VIDEO
|
...
|
...
|
@@ -86,30 +88,72 @@ class OnlineActivity : |
|
|
.putExtra(ConstantParamKey.COURSE_LESSON, data)
|
|
|
)
|
|
|
}
|
|
|
videoCourseAdapter?.setOnItemClickListener { adapter, view, position ->
|
|
|
val course = CourseParam()
|
|
|
if(videoLessonList?.size!! > position+1){
|
|
|
val data = videoLessonList!![position]
|
|
|
course.mLessonId = "${data.id}"
|
|
|
course.isTrainClass = false
|
|
|
course.type = TrainCourseDetailItemType.TYPE_COURSE_DETAIL_ITEM_VIDEO
|
|
|
startActivity(
|
|
|
Intent(
|
|
|
this@OnlineActivity,
|
|
|
CourseDetailActivity::class.java
|
|
|
).putExtra(ConstantParamKey.COURSE_BEAN, course)
|
|
|
.putExtra(ConstantParamKey.COURSE_LESSON, data)
|
|
|
)
|
|
|
}else{
|
|
|
Toast.makeText(this@OnlineActivity,"暂无视频",Toast.LENGTH_SHORT).show()
|
|
|
}
|
|
|
}
|
|
|
initLoadMore()
|
|
|
swipeRefreshlayout.setOnRefreshListener {
|
|
|
videoCourseAdapter?.loadMoreModule?.isEnableLoadMore = false
|
|
|
// swipeRefreshlayout.setOnRefreshListener {
|
|
|
// videoCourseAdapter?.loadMoreModule?.isEnableLoadMore = false
|
|
|
// page = 1
|
|
|
// loadData()
|
|
|
// }
|
|
|
initRefresh()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 加载刷新
|
|
|
*/
|
|
|
private fun initRefresh() {
|
|
|
binding.srBottle.apply {
|
|
|
setEnableAutoLoadMore(true)
|
|
|
setOnRefreshListener {
|
|
|
page = 1
|
|
|
loadData()
|
|
|
}
|
|
|
setOnLoadMoreListener {
|
|
|
page += 1
|
|
|
loadData()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
override fun initDataObserver() {
|
|
|
mViewModel.mVideoLessonBean.observe(this, {
|
|
|
binding.swipeRefreshlayout.isRefreshing = false
|
|
|
videoCourseAdapter?.loadMoreModule?.isEnableLoadMore = !(it.data.list.data.size < 10)
|
|
|
if(it.code==1){
|
|
|
// videoCourseAdapter?.loadMoreModule?.isEnableLoadMore = !(it.data.list.data.size < 10)
|
|
|
|
|
|
videoLessonList?.clear()
|
|
|
videoLessonList?.addAll(it.data.list.data)
|
|
|
videoLessonList?.clear()
|
|
|
videoLessonList?.addAll(it.data.list.data)
|
|
|
|
|
|
if (page == 1) {
|
|
|
videoCourseAdapter?.setList(videoLessonList)
|
|
|
} else {
|
|
|
videoLessonList?.let { it1 -> videoCourseAdapter?.addData(it1) }
|
|
|
if (page == 1) {
|
|
|
videoCourseAdapter?.setList(videoLessonList)
|
|
|
} else {
|
|
|
videoLessonList?.let { it1 -> videoCourseAdapter?.addData(it1) }
|
|
|
}
|
|
|
binding.srBottle.finishRefresh(true)
|
|
|
binding.srBottle.finishLoadMore(true)
|
|
|
}else{
|
|
|
binding.srBottle.finishRefresh(false)
|
|
|
binding.srBottle.finishLoadMore(false)
|
|
|
}
|
|
|
++page
|
|
|
// binding.swipeRefreshlayout.isRefreshing = false
|
|
|
|
|
|
// ++page
|
|
|
})
|
|
|
mViewModel.mWorkTypeBean.observe(this, {
|
|
|
classifyPop.setList(it.data.list)
|
...
|
...
|
@@ -124,13 +168,13 @@ class OnlineActivity : |
|
|
}
|
|
|
|
|
|
fun initLoadMore() {
|
|
|
videoCourseAdapter?.loadMoreModule?.setOnLoadMoreListener(object : OnLoadMoreListener {
|
|
|
override fun onLoadMore() {
|
|
|
binding.swipeRefreshlayout.isRefreshing = false
|
|
|
loadData()
|
|
|
}
|
|
|
})
|
|
|
videoCourseAdapter?.loadMoreModule?.isAutoLoadMore = true
|
|
|
videoCourseAdapter?.loadMoreModule?.isEnableLoadMoreIfNotFullPage = false
|
|
|
// videoCourseAdapter?.loadMoreModule?.setOnLoadMoreListener(object : OnLoadMoreListener {
|
|
|
// override fun onLoadMore() {
|
|
|
//// binding.swipeRefreshlayout.isRefreshing = false
|
|
|
// loadData()
|
|
|
// }
|
|
|
// })
|
|
|
// videoCourseAdapter?.loadMoreModule?.isAutoLoadMore = true
|
|
|
// videoCourseAdapter?.loadMoreModule?.isEnableLoadMoreIfNotFullPage = false
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|