package com.casic.br.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.casic.br.R

class MotionLogAdapter(
    context: Context, private val dataRows: MutableList<String>
) : RecyclerView.Adapter<MotionLogAdapter.ItemViewHolder>() {

    private var layoutInflater: LayoutInflater = LayoutInflater.from(context)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = ItemViewHolder(
        layoutInflater.inflate(R.layout.item_motion_rv_l, parent, false)
    )

    override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {
        //绑定数据
        holder.logTimeView.text = dataRows[position]
    }

    override fun getItemCount(): Int = dataRows.size

    class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val logTimeView: TextView = itemView.findViewById(R.id.logTimeView)
    }
}