作者 zhangji

提交缺少文教

... ... @@ -21,14 +21,29 @@ abstract class BaseMultiAdapter<T, VB : ViewBinding> : RecyclerView.Adapter<Base
protected val list: MutableList<T> = ArrayList()
private var listener: OnItemClickListener<T>? = null
abstract override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<VB>
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<VB> {
return BaseViewHolder(
getViewBinding(
parent.context,
parent,
viewType,
LayoutInflater.from(parent.context)
)
)
}
abstract fun getViewBinding(
context: Context,
parent: ViewGroup,
viewType: Int,
from: LayoutInflater
): VB
override fun onBindViewHolder(holder: BaseViewHolder<VB>, position: Int) {
if (list.isEmpty()) return
onBind(holder.item, position, list[position])
holder.itemView.setOnClickListener {
listener?.onClick(position,list[position])
listener?.onClick(position, list[position])
}
}
... ...
... ... @@ -168,7 +168,7 @@ class DatabaseActivity :
}
})
databaseRecycler.adapter = resultAdapter
resultAdapter.addList(recommendList)
// resultAdapter.addList(recommendList)
}
... ...
... ... @@ -8,7 +8,7 @@ import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
/**
* createTime:2021/7/29 17:50
* auth:张继
* des:
* des:H
*/
class TextDetailActivity:BaseLifeCycleActivity<TextDetailViewModel,ActivityTextDetailBinding>(ActivityTextDetailBinding::inflate) {
override fun onCreate(savedInstanceState: Bundle?) {
... ... @@ -29,7 +29,6 @@ class TextDetailActivity:BaseLifeCycleActivity<TextDetailViewModel,ActivityTextD
"能够有效降低疫情传入农村的风险,保障大家度过一个健康、平安的春节。</p ><p>二、工作方案所指返乡人员包括哪些人群?</p ><p>工作方案" +
"所指返乡人员是指从外地返回农村地区的人员,主要包括:一是跨省份返乡人员;二是来自本省内中高风险区域所在地市的返乡人员(中高风险区" +
"域内部人员原则上不流动);三是本省内的进口冷链食品从业人员、口岸直接接触进口货物从业人员、隔离场所工作人员、交通运输工具从业人员等重点人群。"
content.loadDataWithBaseURL(null, dataImg, "text/html", "utf-8", null)
}
}
... ...
package com.br_technology.securitytrain_master.ui.home.adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
... ... @@ -18,7 +19,6 @@ import com.br_technology.securitytrain_master.ui.home.pojo.RecommendData
class ResultAdapter : BaseMultiAdapter<RecommendData, ViewBinding>() {
override fun onBind(holder: ViewBinding, position: Int, data: RecommendData) {
if (holder is AdapterRecommendDataBinding) {
holder.pic.glideRound(data.pic, 16)
... ... @@ -35,22 +35,23 @@ class ResultAdapter : BaseMultiAdapter<RecommendData, ViewBinding>() {
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<ViewBinding> {
override fun getViewBinding(
context: Context,
parent: ViewGroup,
viewType: Int,
from: LayoutInflater
): ViewBinding {
return if (viewType == 0) {
BaseViewHolder(
LayoutEmptyBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false
)
LayoutEmptyBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false
)
} else {
BaseViewHolder(
AdapterRecommendDataBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false
)
AdapterRecommendDataBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false
)
}
}
... ...
... ... @@ -87,7 +87,10 @@ class HomeFragment : Fragment() {
view.findViewById<TextView>(R.id.txt_course).setOnClickListener {
startActivity(TextCourseActivity::class.java)
}
// 在线课程
view.findViewById<TextView>(R.id.online_course).setOnClickListener {
// startActivity()
}
// 视频课程
val videoCourse: RecyclerView = view.findViewById(R.id.video_course)
... ...
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="4dp"
android:bottomRightRadius="4dp" />
<gradient
android:endColor="#00E8A2"
android:startColor="#00E5F3"
android:type="linear" />
</shape>
\ No newline at end of file
... ...