I have an adapter
class and in which I initialise
a map as follows:
internal class MyAdapter(private var itemList: List<Items>) :
RecyclerView.Adapter<MyAdapter.MyViewHolder>() {
private var itemStates: MutableMap<Int, ArrayList<Boolean>> = mutableMapOf()
init {
itemList.forEachIndexed { index, itemObject->
val capacity = if(itemObject.getItemTYPE() == Item.ITEM_TYPE.FOOD) 3 else 5
itemStates[index] = ArrayList(initialCapacity = capacity) //error is shown here
}
}
Everything else seems fine, but when I run this, I get the following error:
None of the following functions can be called with the arguments supplied:
public final fun (): kotlin.collections.ArrayList /* = java.util.ArrayList */ defined in kotlin.collections.ArrayList
public final fun (p0: (MutableCollection<out Boolean!>..Collection<Boolean!>?)): kotlin.collections.ArrayList /* = java.util.ArrayList */ defined in kotlin.collections.ArrayList
public final fun (p0: Int): kotlin.collections.ArrayList /* = java.util.ArrayList */ defined in kotlin.collections.ArrayList
Any help or suggestion will be highly appreciated.