Message bubble

UIKit allows all types of message bubble to be replaced.

Text message bubble

Image massage bubble.

Audio message bubble

Usage

To customise message bubble, implement EkoMessageAdapter.ICustomViewHolder and pass a custom ViewHolder for the corresponding message type.

class MainActivity : AppCompatActivity(), EkoMessageListAdapter.ICustomViewHolder {

   override fun onCreate(savedInstanceState: Bundle?) {
       super.onCreate(savedInstanceState)
       setContentView(R.layout.activity_main)

        val builder = EkoMessageListFragment.Builder("channelId")
        val messageListFragment = builder.build()
        /**
         * Implement [EkoMessageListAdapter.ICustomViewHolder] if customization is required for messageViews
         * set the customView listener using [EkoMessageListFragment] instance
         */
        messageListFragment.addCustomView(this)
        
        val transaction = supportFragmentManager.beginTransaction()
        transaction.replace(R.id.fragmentContainer, messageListFragment)
        transaction.addToBackStack(null)
        transaction.commit()
   }
}

Override method getViewHolder() to pass a custom ViewHolder

override fun getViewHolder(
        inflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): EkoChatMessageBaseViewHolder? {
        return when(viewType) {
            MessageType.MESSAGE_ID_TEXT_RECEIVER -> TextReceiverViewHolder(
                inflater.inflate(R.layout.custom_item_text_receiver, parent, false), EkoChatMessageBaseViewModel())
            MessageType.MESSAGE_ID_TEXT_SENDER -> TextSenderViewHolder(
                inflater.inflate(R.layout.custom_item_text_sender, parent, false), EkoChatMessageBaseViewModel()
            )
            //pass null for all the types where no customisation is required
            //Default UIKIT Ui will be rendered for all those types
            else -> null
        }
    }

Last updated