Skip to content

Create a new Node Component

Francisco Riádigos edited this page Aug 30, 2018 · 14 revisions

Before to continue, you must be familiar with RecyclerView and Recyclerview.ViewHolder patterns and implementations.

You can create components from any of the following models:


Creating a message-like component

You will create a class with metadata and populate onto a layout.

  • Inherit and implement from ChatNode.
  • Inherit and implement from ChatNodeText if it also handles text. (optional)
  • Create an inner Builder static class with fluent interface.
  • Implement equals() and hashCode() methods.
  • Follow the interfaces contract.

About the ViewType - Unique ID resource, which will be handled by RecyclerView.Adapter#getViewType()

<item type="id" name="my_own_component_unique_view_type" />

About the ViewHolderBuilder - Implementation of ChatViewHolderBuilder, that will be consumed by RecyclerView.Adapter#onBindViewHolder

return MyOwnComponentUniqueViewHolderBuilder.build();

Have a look at ChatMessageText and ChatMessageTextViewHolderBuilder to learn more.


Creating an action-like component

You will create a class with metadata and apply onto a View.

  • Inherit and implement from ChatAction.
  • Create an inner Builder static class with fluent interface.
  • Implement compareTo(), equals() and hashCode() methods.
  • Follow the interfaces contract.

About the ViewBuilder - Essentially you have to return a View, which is one of the items of a list of Actions.

About the ActionFeedback - You will build and return an ActionFeedback based on the Action the user has selected.

Have a look at ChatActionText and ChatActionTextViewBuilder to learn more.


Creating a feedback-like component

You will build a class with the Action metadata and populate onto a layout.

It is very similar on how you create a message-like component.

Have a look at ChatActionFeedbackText and ChatActionFeedbackTextViewHolderBuilder to learn more.


If you have any question, please open an issue.

Clone this wiki locally