app / sg.edu.ntu.scse.cz2006.gymbuddies.adapter / ChatAdapter

ChatAdapter

open class ChatAdapter : Adapter<ChatViewHolder!>

Recycler Adapter for Chat Object For sg.edu.ntu.scse.cz2006.gymbuddies.adapter in Gym Buddies! The adapter is used to display list of chat history of a user

Author
Chia Yu

Since
2019-10-19

Types

ChatViewHolder

ViewHolder for Chat it holds reference to frequent update views and provides helper method to bind data information onto views

open class ChatViewHolder : ViewHolder, OnClickListener

Constructors

<init>

Constructor method to initialise ChatAdapter

ChatAdapter(chats: MutableList<Chat!>!, favUserIds: MutableList<String!>!)

Properties

ACTION_CLICK_ON_FAV_ITEM

unique identifier to specify user click on favoured (heart shape) button of display view

static val ACTION_CLICK_ON_FAV_ITEM: Int

ACTION_CLICK_ON_ITEM_BODY

unique identifier to specify user click on item body of display view

static val ACTION_CLICK_ON_ITEM_BODY: Int

ACTION_CLICK_ON_ITEM_PIC

unique identifier to specify user click on profile picture of display view

static val ACTION_CLICK_ON_ITEM_PIC: Int

ACTION_INVALID

unique identifier to specify undefined action

static val ACTION_INVALID: Int

chats

list that holds user's chat chat information

var chats: MutableList<Chat!>!

favUserIds

it store list of other user's id, used to denote that other user is current user's buddy

var favUserIds: MutableList<String!>!

listener

interface that allow activity to observe user interaction with RecyclerView

var listener: OnRecyclerViewInteractedListener<ChatViewHolder!>!

sdf

it is used to format timestamp from long to String

var sdf: SimpleDateFormat!

TAG

TAG is unique identifier to for logging purpose

var TAG: String!

Functions

getItemCount

the method is return number of messages to be display on RecyclerView

open fun getItemCount(): Int

onBindViewHolder

this method make use of view holder to update display information onto the view

open fun onBindViewHolder(holder: ChatViewHolder, position: Int): Unit

onCreateViewHolder

the method based on view type to render a view and associate the view with respective view holder

open fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChatViewHolder

setFavUserIds

setter method to update list of favouried

open fun setFavUserIds(favUserIds: MutableList<String!>!): Unit

setOnRecyclerViewClickedListener

The method provides an interface to allow other class to register itself as observer of user interacting event

open fun setOnRecyclerViewClickedListener(listener: OnRecyclerViewInteractedListener<ChatViewHolder!>!): Unit