Live UIKit Android v1
Live UIKit Android
Live UIKit
Android
Version 1

Customize LiveUIKitFragmentFactory

Copy link

LiveUIKitFragmentFactory is a class that provides and manages all fragments used in Sendbird UIKit. While an activity creates the basic UI screen and allows the user to navigate between different screens, the fragment within the activity is what allows you to customize components and manage data. The LiveUIKitFragmentFactory class creates the fragment used in each activity.

If you wish to customize a fragment, you need to inherit the LiveUIKitFragmentFactory class and override the method that creates the fragment. Then, you must return the customized fragment in order to apply the customization throughout the UIKit. Before creating the fragment, you need to also send data from the activity to the customized fragment through the Bundle class. The fragment will then use the data to build a view.

Note: If you're only using fragments to build a screen in the UIKit instead of using an activity, you can skip the following steps.

  1. You need to first override the methods of the fragment you wish to customize by inheriting the LiveUIKitFragmentFactory class. Refer to the code below as an example.
class CustomFragmentFactory : LiveUIKitFragmentFactory() {

    // Override the methods that create the fragment you wish to customize.

    override fun newLiveEventHostFragment(liveEventId: String, args: Bundle): Fragment {
        // TODO: Return the customized LiveEventHostFragment here.
        val fragment = CustomLiveEventHostFragment()
        // You can send data from activity to the custom fragment through Bundle.
        args.putString("KEY_LIVE_EVENT_ID", liveEventId)
        fragment.arguments = args
        return fragment
    }
}
  1. Apply the customized LiveUIKitFragmentFactory to Application using SendbirdLiveUIKit.setLiveUIKitFragmentFactory(LiveUIKitFragmentFactory).
class MyApplication : Application {
    override fun onCreate() {
        SendbirdLiveUIKit.setLiveUIKitFragmentFactory(new CustomFragmentFactory());
    }
}