i have three model class of username, user and a post just like this
data class User( val uid:String = "" )
data class username( val usernames:String="", )
`data class Post(
val text:String = "",
val createdBy: User = User(),
val createdAt:Long = 0L,
val creates:username = username()
)`
and I have them connected to firebase. Now i want to use both of these models in a single recyclerView adapter. How will i do this? my adapter looks like this
class postadapter(options: FirestoreRecyclerOptions<Post>, val listener: MainActivity) :
FirestoreRecyclerAdapter<Post, postadapter.postviewholder>(
options
) {
class postviewholder(itemview: View):RecyclerView.ViewHolder(itemview) {
val username: TextView = itemview.findViewById(R.id.userrrrrr)
val createdat: TextView = itemview.findViewById(R.id.createdAt)
val Text: TextView = itemview.findViewById(R.id.postedText)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): postviewholder {
val viewholder = postviewholder(LayoutInflater.from(parent.context).inflate(R.layout.feed,parent,false))
return viewholder
}
override fun onBindViewHolder(holder: postviewholder, position: Int ,model: Post) {
holder.username.text = model.createdBy.uid
holder.Text.text = model.text
holder.createdat.text = utils.getTimeAgo(model.createdAt)
}
}
i also want to pass the value of the username model to the post model of 'creates' also, in the onbindviewholder i want to pass the value of the username i created in the data class.