package xyz.r0r5chach.dermy_app

import android.graphics.BitmapFactory
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.commit
import androidx.recyclerview.widget.RecyclerView
import xyz.r0r5chach.dermy_app.db.DermyDatabase
import xyz.r0r5chach.dermy_app.db.Entities
import xyz.r0r5chach.dermy_app.fragments.MoleFragment
import java.io.File

class LogsAdapter(private val dataSet: List<Entities.Entity?>?, private val filesDir: File): RecyclerView.Adapter<LogsAdapter.ViewHolder>() {
    class ViewHolder(view: View): RecyclerView.ViewHolder(view) {
        val textView: TextView = view.findViewById(R.id.mole_list_image)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(parent.context)
            .inflate(R.layout.mole_list_item, parent, false)
        return ViewHolder(view)
    }

    override fun getItemCount() = dataSet!!.size

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val log = (dataSet!![position]!! as Entities.LogEntry)

        holder.textView.setOnClickListener {
            //TODO: item displays date created
            //TODO: On log item pressed: Popup -> show contents

        }


        holder.textView.text = log.dateCreated.toString()
    }

}
