package hu.naturlecso.naturshutd.ui.adapter

import android.content.Context
import android.databinding.ViewDataBinding

import java.util.ArrayList

import hu.naturlecso.naturshutd.R
import hu.naturlecso.naturshutd.databinding.HostItemBinding
import hu.naturlecso.naturshutd.host.Host
import hu.naturlecso.naturshutd.ui.viewmodel.HostItemViewModel

class HostListAdapter(private val context: Context) : BaseMvvmRecyclerAdapter<Host>(R.layout.host_item) {
    private var items: List<Host> = emptyList()

    override fun bind(binding: ViewDataBinding, position: Int, item: Host) {
        (binding as HostItemBinding).viewmodel = HostItemViewModel(context, item)
    }

    override fun getItemCount(): Int = items.size

    override fun getItemId(position: Int): Long {
        return -1L //TODO items.get(position).id;
    }

    override fun getItem(position: Int): Host = items[position]

    fun swap(items: List<Host>) {
        this.items = items
        notifyDataSetChanged()
    }
}
