RoomSuggestionsAdapter.kt 1.52 KB
Newer Older
1 2 3 4 5 6 7 8
package chat.rocket.android.chatroom.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import chat.rocket.android.R
import chat.rocket.android.chatroom.adapter.RoomSuggestionsAdapter.RoomSuggestionsViewHolder
9
import chat.rocket.android.chatroom.uimodel.suggestion.ChatRoomSuggestionUiModel
10 11 12
import chat.rocket.android.suggestions.model.SuggestionModel
import chat.rocket.android.suggestions.ui.BaseSuggestionViewHolder
import chat.rocket.android.suggestions.ui.SuggestionsAdapter
13 14 15 16 17 18 19 20 21 22 23 24

class RoomSuggestionsAdapter : SuggestionsAdapter<RoomSuggestionsViewHolder>("#") {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RoomSuggestionsViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.suggestion_room_item, parent,
                false)
        return RoomSuggestionsViewHolder(view)
    }

    class RoomSuggestionsViewHolder(view: View) : BaseSuggestionViewHolder(view) {

        override fun bind(item: SuggestionModel, itemClickListener: SuggestionsAdapter.ItemClickListener?) {
25
            item as ChatRoomSuggestionUiModel
26
            with(itemView) {
karthyks's avatar
karthyks committed
27 28
                val fullname = findViewById<TextView>(R.id.text_fullname)
                val name = findViewById<TextView>(R.id.text_name)
29 30 31 32 33 34 35 36 37
                name.text = item.name
                fullname.text = item.fullName
                setOnClickListener {
                    itemClickListener?.onClick(item)
                }
            }
        }
    }
}