结算页面、设置页面
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package com.sw.dualscreen.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.chad.library.adapter4.BaseQuickAdapter
|
||||
import com.chad.library.adapter4.viewholder.QuickViewHolder
|
||||
import com.sw.dualscreen.databinding.ListItemSearchFoodBinding
|
||||
import com.sw.dualscreen.ext.format2String
|
||||
import com.sw.dualscreen.model.response.FoodInfo
|
||||
|
||||
class SearchFoodAdapter(var list: MutableList<FoodInfo>) :
|
||||
BaseQuickAdapter<FoodInfo, SearchFoodAdapter.VH>(list) {
|
||||
|
||||
inner class VH(var binding: ListItemSearchFoodBinding) : QuickViewHolder(binding.root)
|
||||
|
||||
override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val binding = ListItemSearchFoodBinding.inflate(inflater, parent, false)
|
||||
return VH(binding)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: VH, position: Int, item: FoodInfo?) {
|
||||
holder.binding.tvFoodName.run {
|
||||
if (item!!.score == 0) {
|
||||
text = item.foodName
|
||||
} else {
|
||||
val score = (item.score / 100.0).format2String(2)
|
||||
text = "${item.foodName}\n${score}%"
|
||||
}
|
||||
isChecked = item.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user