None of the following functions can be called with the arguments supplied - AsyncListDiffer

33 views Asked by At

I was creating a RecyclerView adapter. but then I got AsyncListDiffer issue.

None of the following functions can be called with the arguments supplied - AsyncListDiffer

how to fix it ?

NoteAdapter.kt


import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.AsyncListDiffer
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import com.mahi.notesapp.databinding.NoteLayoutBinding
import com.mahi.notesapp.model.Note

class NoteAdapter: RecyclerView.Adapter<NoteAdapter.NoteViewHolder>()
{

    class NoteViewHolder(val itemBinding: NoteLayoutBinding): RecyclerView.ViewHolder(itemBinding.root)
    {

        private val differCallback = object : DiffUtil.ItemCallback<Note>(){
            override fun areItemsTheSame(oldItem: Note, newItem: Note): Boolean
            {
                return oldItem.id == newItem.id &&
                        oldItem.noteBody == newItem.noteBody &&
                        oldItem.noteTitle == newItem.noteTitle
            }

            override fun areContentsTheSame(oldItem: Note, newItem: Note): Boolean {
                return oldItem == newItem
            }
        }


    val differ = AsyncListDiffer(this, differCallback )

    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NoteViewHolder
    {
        return NoteViewHolder(NoteLayoutBinding.inflate(LayoutInflater.from(parent.context), parent, false))
    }

    override fun getItemCount(): Int {
        TODO("Not yet implemented")
    }

    override fun onBindViewHolder(holder: NoteViewHolder, position: Int)
    {
//        val currentNote = differ.currentList[position]
//
//        holder.itemBinding.tvNoteTitle
    }
}

0

There are 0 answers