|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.yinuo.safetywatcher.watcher.ui.adapter
|
|
|
|
|
|
|
|
|
|
import android.view.KeyEvent
|
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
|
import android.view.ViewGroup
|
|
|
|
|
import com.yinuo.safetywatcher.databinding.LayoutItemHistoryBinding
|
|
|
|
@ -7,18 +8,28 @@ import com.yinuo.safetywatcher.watcher.base.BaseRvAdapter
|
|
|
|
|
import com.common.commonlib.db.entity.Video
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.DateUtils
|
|
|
|
|
|
|
|
|
|
class HistoryVideoAdapter :
|
|
|
|
|
class HistoryVideoAdapter(private val leftRightClick: (() -> Unit?)? = null) :
|
|
|
|
|
BaseRvAdapter<Video, LayoutItemHistoryBinding, HistoryVideoAdapter.HViewHolder>() {
|
|
|
|
|
|
|
|
|
|
class HViewHolder(
|
|
|
|
|
val binding: LayoutItemHistoryBinding,
|
|
|
|
|
val mItemClickListener: OnItemClickListener?
|
|
|
|
|
val mItemClickListener: OnItemClickListener?,
|
|
|
|
|
val leftRightClick: (() -> Unit?)? = null
|
|
|
|
|
) :
|
|
|
|
|
BaseRvAdapter.BaseViewHolder<Video, LayoutItemHistoryBinding>(binding) {
|
|
|
|
|
override fun bindView(data: Video) {
|
|
|
|
|
binding.tvTime.text = formatTime(data.time)
|
|
|
|
|
binding.tvSensor.text = data.name
|
|
|
|
|
|
|
|
|
|
binding.root.setOnKeyListener { v, keyCode, event ->
|
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
|
|
|
|
|
if (event.action == KeyEvent.ACTION_DOWN) {
|
|
|
|
|
leftRightClick?.let { it() }
|
|
|
|
|
return@setOnKeyListener true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return@setOnKeyListener false
|
|
|
|
|
}
|
|
|
|
|
binding.root.setOnClickListener {
|
|
|
|
|
mItemClickListener?.onItemClick(data)
|
|
|
|
|
}
|
|
|
|
@ -32,7 +43,7 @@ class HistoryVideoAdapter :
|
|
|
|
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HViewHolder {
|
|
|
|
|
val binding =
|
|
|
|
|
LayoutItemHistoryBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
|
|
|
|
return HViewHolder(binding, mItemClickListener)
|
|
|
|
|
return HViewHolder(binding, mItemClickListener, leftRightClick)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var mItemClickListener: OnItemClickListener? = null
|
|
|
|
|