I am porting an Java Code to Kotlin and It's throwing an Type Miss matched error.
Java Code :
private FirebaseRecyclerAdapter<ChatObject, ChatVoiceViewHolders> firebaseRecyclerAdapterChats;
firebaseRecyclerAdapterChats = new FirebaseRecyclerAdapter<ChatObject, ChatVoiceViewHolders>(
ChatObject.class,
R.layout.item_messages_video_call,
ChatVoiceViewHolders.class,
dbMessagingMy
) {}
Kotlin Code :
private var firebaseRecyclerAdapterChats: FirebaseRecyclerAdapter<ChatObject, ChatVoiceViewHolders>? = null
firebaseRecyclerAdapterChats = object : FirebaseRecyclerAdapter<ChatObject?, ChatVoiceViewHolders?>(
ChatObject::class.java,
R.layout.item_messages_video_call,
ChatVoiceViewHolders::class.java,
dbMessagingMy
) {}
but my Koltin code is throwing an error :
Type mismatch.
Required:
FirebaseRecyclerAdapter<ChatObject, ChatVoiceViewHolders>?
Found:
None of the following functions can be called with the arguments supplied.
(Class<ChatObject?>!, Int, Class<ChatVoiceViewHolders?>!, FirebaseArray!) ??
where T = ChatObject?, VH = ChatVoiceViewHolders? for
constructor FirebaseRecyclerAdapter<T : Any!, VH : RecyclerView.ViewHolder!>(modelClass: Class<T!>!, modelLayout: Int, viewHolderClass: Class<VH!>!, snapshots: FirebaseArray!)
defined in com.firebase.ui.database.FirebaseRecyclerAdapter
(Class<ChatObject?>!, Int, Class<ChatVoiceViewHolders?>!, Query!) ??
where T = ChatObject?, VH = ChatVoiceViewHolders? for ??
constructor FirebaseRecyclerAdapter<T : Any!, VH : RecyclerView.ViewHolder!>(modelClass: Class<T!>!, modelLayout: Int, viewHolderClass: Class<VH!>!, ref: Query!) defined in com.firebase.ui.database.FirebaseRecyclerAdapter
One more point, In my Java code I am working with AppcompatActivity and In my Kotlin Code I am working with BaseActivity..
Is there anything I am doing wrong?
how can I solve this?
thanks.