trubesv
08/26/2017, 7:15 PMCoroutine
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:
class MyAdapter() : RecyclerView.Adapter<MyViewHolder>()
{
fun add() {}
fun remove() {}
[...]
/* 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()
}
Thanks for the help! 🙂vlastachu
08/27/2017, 10:29 AMCoroutine
-related things?radityagumay
08/27/2017, 12:10 PMtrubesv
08/27/2017, 12:37 PMCoroutineScope
, IntelliJ suggests me to create an extension function it so I can call function
, like fun CoroutineScope.function() {}
kevinherron
08/27/2017, 1:37 PMMyViewHolder
an inner class
trubesv
08/27/2017, 1:39 PMkevinherron
08/27/2017, 1:39 PMkevinherron
08/27/2017, 1:39 PMtrubesv
08/27/2017, 1:45 PM