Hi all! I'm having trouble calling a function from...
# android
t
Hi all! I'm having trouble calling a function from a
Coroutine
that is inside a custom
ViewHolder
The function is not recognised, and when I put it in the
ViewHolder
class, of course I can't calll the `add`/`remove` functions anymore.. Could you point me in the right direction please? Here is the basic setup:
Copy code
class MyAdapter() : RecyclerView.Adapter<MyViewHolder>()
{
    [...]

    /* Custom ViewHolder */
    class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
    {
        fun bind(item: Item) = with(itemView)
        {
            /* Handle long click event on row*/
            isLongClickable = true
            onLongClick { function() } // I'M HAVING TROUBLE HERE (Unresolved reference)
       
            [...]
        }
    }

    /* How to call this? */
    fun function() {
        add()
        remove()
    }

    /* MyAdapter functions */
    fun add() {}
    fun remove() {}
Thanks for the help! 🙂 Slack Conversation
e
Where’s the coroutine? I just see normal functions here. Also, whats going on with your
{
-brace being on it’s separate line?