...
|
...
|
@@ -21,11 +21,13 @@ import com.br_technology.securitytrain_master.ui.view.home.bean.NoticeBean |
|
|
import com.br_technology.securitytrain_master.ui.view.home.bean.RecommendBean
|
|
|
import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonBean
|
|
|
import com.br_technology.securitytrain_master.ui.view.home.viewmodel.HomeViewModel
|
|
|
import com.br_technology.securitytrain_master.view.DialogNotice
|
|
|
import com.br_technology.securitytrain_master.view.listener.OnItemClickListener
|
|
|
import com.bumptech.glide.Glide
|
|
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
|
|
import com.bumptech.glide.request.RequestOptions
|
|
|
import com.gyf.immersionbar.components.SimpleImmersionOwner
|
|
|
import com.luck.picture.lib.tools.ToastUtils
|
|
|
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
|
|
|
import com.youth.banner.adapter.BannerImageAdapter
|
|
|
import com.youth.banner.holder.BannerImageHolder
|
...
|
...
|
@@ -46,6 +48,10 @@ class HomeFragment : |
|
|
private var videoLessonList: MutableList<VideoLessonBean.ListBean.DataBean>? = null
|
|
|
private var recommendDataAdapter: RecommendDataAdapter? = null
|
|
|
private var videoCourseAdapter: VideoCourseAdapter? = null
|
|
|
|
|
|
private val dialogNotice by lazy {
|
|
|
DialogNotice(requireContext())
|
|
|
}
|
|
|
override fun initDataObserver() {
|
|
|
//获取banner数据
|
|
|
mViewModel.mBannerBean.observe(this, {
|
...
|
...
|
@@ -56,12 +62,16 @@ class HomeFragment : |
|
|
//获取最新公告
|
|
|
mViewModel.mNoticeBean.observe(this, {
|
|
|
val data = it.data.list
|
|
|
for (news in data) {
|
|
|
for (index in data.indices) {
|
|
|
val textView = TextView(context)
|
|
|
textView.maxLines = 1
|
|
|
textView.text = news.title
|
|
|
textView.text = data[index].title
|
|
|
textView.ellipsize = TextUtils.TruncateAt.END
|
|
|
textView.tag = index
|
|
|
textView.setOnClickListener {
|
|
|
val position = textView.tag as Int
|
|
|
// 公告弹框
|
|
|
dialogNotice.setTitle(data[position].des).show()
|
|
|
}
|
|
|
binding.flipperScan.addView(
|
|
|
textView, ViewGroup.LayoutParams(
|
...
|
...
|
@@ -70,6 +80,22 @@ class HomeFragment : |
|
|
)
|
|
|
)
|
|
|
}
|
|
|
// for (news in data) {
|
|
|
// val textView = TextView(context)
|
|
|
// textView.maxLines = 1
|
|
|
// textView.text = news.title
|
|
|
// textView.ellipsize = TextUtils.TruncateAt.END
|
|
|
// textView.setOnClickListener {
|
|
|
// // 公告弹框
|
|
|
// ToastUtils.s(requireContext(),"aaa")
|
|
|
// }
|
|
|
// binding.flipperScan.addView(
|
|
|
// textView, ViewGroup.LayoutParams(
|
|
|
// ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
// ViewGroup.LayoutParams.WRAP_CONTENT
|
|
|
// )
|
|
|
// )
|
|
|
// }
|
|
|
if (data.size > 1) {
|
|
|
binding.flipperScan.flipInterval = 3000
|
|
|
binding.flipperScan.startFlipping()
|
...
|
...
|
|