Kotlin Realm recyclerview and bind view problems

I’ve been updating my entire app to a more recent version within Kotlin in the past 2 days. Unfortunately I have had a big problem because since my views are no longer synthetic but bind view updating my lists no longer works properly.

Within my whole app I use realm adapter recyclerview to display lists. The advantage is that with every change in the database the list is automatically updated. I don’t have to place listeners myself. This has always worked. Since I’ve applied the Bind view, this doesn’t work properly any more.

When deleting an invite, for example, it still remains visible in the recycler view while it has already been deleted in the database.

I’ve installed a listener just to be sure and it seems to work. But I can’t believe I have to push the listeners throughout the app. Then this update is more of a setback than progress for me and the days have been for nothing. Does anyone have more experience in this? I am slowly starting to panic.

This is an example code.

class InvitesStatus : Fragment() {

    private var _binding: FragmentInvitesStatusBinding? = null
    private val binding get() = _binding!!
    private val appRealm = Realm.getInstance(Config.DB())

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {

        _binding = FragmentInvitesStatusBinding.inflate(inflater, container,false)
        return binding.root

    }


    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        binding.inviteCheckContainer.layoutManager = LinearLayoutManager(activity)
        binding.inviteCheckContainer.setHasFixedSize(true)

        updateLists()

    }


    private fun deleteInvite(id:String){

        appRealm.executeTransactionAsync({ bgRealm ->
            val invite = bgRealm.where<SchemeInvites>().contains("invite_id", id).findFirst()
            invite!!.deleteFromRealm()
        }, {

        }, { error ->
            Log.d("log", "DELETE INVITE ERROR:" + error)
        })

    }

    
    private fun updateLists() {
        var invites: RealmResults<SchemeInvites>?  = null
        val builder = AlertDialog.Builder(requireActivity()).setCancelable(false)

        invites = appRealm.where<SchemeInvites>()
            .equalTo("invite_type", Utility.SEND_INVITE)
            .sort("invite_date", Sort.DESCENDING).findAllAsync()

        binding.inviteCheckContainer.adapter = InvitesStatusAdapter(invites,false, object :
            InvitesStatusAdapter.ContactItemClickListener {

            override fun onAdd(invite: SchemeInvites?) {

            }

            override fun onRemove(invite: SchemeInvites?) {
                builder.setMessage("Are you sure you want to Delete?")
                    .setPositiveButton("Yes") { _, _ ->
                        deleteInvite(invite?.invite_id!!)
                    }
                    .setNegativeButton("No") { dialog, id ->
                        dialog.dismiss()
                    }

                val alert = builder.create()
                alert.show()
                alert.window!!.setLayout(800, ActionBar.LayoutParams.WRAP_CONTENT);
            }


        })

        invites?.addChangeListener(OrderedRealmCollectionChangeListener { invites, changeSet ->

            if(binding.notfound != null){
                if (invites.size > 0) {
                    binding.notfound.root.visibility = View.GONE
                }else{
                    binding.notfound.root.visibility = View.VISIBLE
                }
            }

        })
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }



}


indent preformatted text by 4 spaces

Adapter Class

class InvitesStatusAdapter(
    var listVar: RealmResults<SchemeInvites>?,
    val autoUpdate: Boolean,
    val clickListener: InvitesStatusAdapter.ContactItemClickListener,
) : RealmRecyclerViewAdapter<SchemeInvites, RecyclerView.ViewHolder>(listVar, autoUpdate) {


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {

            val binding = UserStatusBinding.inflate(LayoutInflater.from(parent.context), parent, false)
            return DataHolder(binding)

    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {

        val currentItem: SchemeInvites? = listVar?.get(position)

        (holder as DataHolder).bindView(currentItem)

       // holder.bindView(currentItem)

        holder.binding.actionCancel.setOnClickListener {
                clickListener.onRemove(currentItem)
        }


    }



    class DataHolder(val binding: UserStatusBinding) : RecyclerView.ViewHolder(binding.root){

        val current = LocalDateTime.now().dayOfYear

        fun bindView(item: SchemeInvites?) {

            val date = LocalDateTime.parse(item?.invite_date)
            val hour: String = date.hour.toString()
            val min: String = String.format("%02d", date.minute)
            binding.chatContact.text = item?.invite_name
           // binding.chatStatus.text = "domein".uppercase(Locale.getDefault())

            var text: String = ""
            when (date.dayOfYear) {
                current -> {
                    binding.chatDate.text = String.format("%s:%s", hour, min)
                  //  text = itemView.resources.getString(R.string.today).replaceFirstChar(Char::titlecase)
                }
                current-1 -> {
                  //  text = itemView.resources.getString(R.string.yesterday).replaceFirstChar(Char::titlecase)
                }
                current-2 -> {
                   // text = itemView.resources.getString(R.string.before_yesterday).replaceFirstChar(Char::titlecase)
                }
                else -> {
                    val day: String = String.format("%02d", date.dayOfMonth)
                    val month: String = String.format("%02d", date.monthValue)
                    val year: String = date.year.toString()
                    text = String.format("%s-%s-%s", day, month, year)
                }
            }

            binding.chatDate.text = String.format(text+" - %s:%s", hour, min)

        }

    }


    interface ContactItemClickListener {
        fun onAdd(invite: SchemeInvites?)
        fun onRemove(invite: SchemeInvites?)
    }
}

Thanks in advance