Chat UIKit Android v3
Chat UIKit Android
Chat UIKit
Android
Version 3

Bind event handlers to the view

Copy link

In all UIKit fragments, you can override the onBeforeReady() method. In order to receive events that occur in the view of a component, a binding method is called. Each component has a binding method, such as onBindMessageInputComponent, which is called to bind event handlers to the fragment. If you inherited the fragment, we recommend that you set the event handlers of the component within the onBeforeReady() method or the binding method.

Note: In the code below, the tap event of the left button in MessageInputComponent is used as an example but you can replace it with any other events.

KotlinJava
class CustomChannelFragment : ChannelFragment() {

    // TODO : Override `onBeforeReady()` or `onBindMessageInputComponent`.
    
    override fun onBindMessageInputComponent(
        inputComponent: MessageInputComponent,
        viewModel: ChannelViewModel,
        channel: GroupChannel?
    ) {
        super.onBindMessageInputComponent(inputComponent, viewModel, channel)
        // TODO : Customize the event handler using a setter method of the `MessageInputComponent`.
        inputComponent.setOnInputLeftButtonClickListener { showMediaSelectDialog() }
    }
}

Note: We recommend you to bind the event handlers of a component after the onCreateView() of the module is called.