-
Notifications
You must be signed in to change notification settings - Fork 5
Customizing chat bubbles
MonkeyAdapter has methods that you can override to customize the views that are displayed in the RecyclerView.
The method bindCommonMonkeyHolder is called everytime a MonkeyItem is bound to a MonkeyHolder regardless of the type. The default implementation makes the view show the message's date and status. You can override this method to customize every MonkeyHolder. For specific types of messages you can override the following methods:
-
bindMonkeyTextHolderBinds a MonkeyHolder with a message of type text. -
bindMonkeyPhotoHolderBinds a MonkeyHolder with a message of type photo. -
bindMonkeyAudioHolderBinds a MonkeyHolder with a message of type audio.
Sometimes manipulating the ViewHolder at binding may not be enough for your customization needs. Maybe you want a completely different layout, or you want to use your own custom MonkeyHolder subclass. You can do all of that by overriding any of the following methods that create MonkeyHolder objects:
-
createMonkeyTextHolderCreates a newMonkeyHolderobject for messages of type text. -
createMonkeyAudioHolderCreates a newMonkeyHolderobject for messages of type audio. -
createMonkeyPhotoHolderCreates a newMonkeyHolderobject for messages of type photo.
Everytime the RecyclerView needs a new ViewHolder it calls any of these methods depending on the type.
The only constraint of overriding any of these is that you must return a ViewHolder that extends MonkeyHolder.
MonkeyAdapter calls a few MonkeyHolder methods to display data that is common to all types. By overriding the following methods you can create a custom MonkeyHolder subclass that displays data the way you want it:
-
updateReadStatusmethod called to show the user whether this message has been read or not. -
updateSendingStatusmethod called to show the user whether this message still in route to server, or it has already been successfully delivered. -
setSenderNamemethod called to show the user the name of the sender of this message. -
setMessageDatemethod called to show the user the date in which this message was sent.
By extending MonkeyHolder you can easily control the way the user percieves data about the messages that he/she receives.