List open channels
A channel list shows a complete list of open channels available for the current user. Once a connection with Sendbird server is established, you can display and manage the channel list without complex implementation. All chat services built with Sendbird UIKit begin from the channel list.
Channel list screen
A channel list screen is composed of three components: header, channel list, and channel list status.
Header
The header component shows the title of the channel list screen and shows a button on the top right corner, by default, that allows you to choose the type of channel you wish to create. After the channel type is selected, you will be able to create the channel in the corresponding key function. The view of the channel list header is created and customized in the HeaderComponent
of the OpenChannelListModule
.
Channel list
The channel list component shows a list of all channels that the current user is part of. The channel list creates a RecyclerView in the OpenChannelListComponent
as all UIs in the form of a list in UIKit for Sendbird are implemented as a RecyclerView. To create the view of each channel list item, you need to use OpenChannelListAdapter
and bind channel data to the view. When the current user taps on one of the channels in the list, they'll be able to enter the channel in Chat in a open channel screen depending on the channel type.
Channel list status
The channel list status component shows the result of the data request for a channel list. The StatusComponent
exists in the OpenChannelListModule
and lets the user know if the list is loading or if the list could not be called.
Usage
UIKit for Android provides both activity and fragment to create a channel list screen. You can choose which one to build your app with and you may solely use activity instead of fragment if you wish to. You can build a channel list screen through OpenChannelListActivity
, which uses UIKitFragmentFactory
to create views.
Start an activity
You can start an activity by using intent
to move from one activity to OpenChannelListActivity
as shown below:
Create a fragment
OpenChannelListActivity
allows you to create a basic OpenChannelListFragment
through UIKitFragmentFactory
and OpenChannelListFragment.Builder
. UIKitFragmentFactory
has a set of methods that build each fragment, whereas the builder class provides APIs to customize the UI of the data and event handlers used in OpenChannelListFragment
. To see all APIs of OpenChannelListFragment.Builder
, refer to the API reference page.
Note: To use UIKit's fragments as a nested fragment, refer to the Android Developer Documentation's Nested Fragments.
Customization
In the list channel key function, you can customize OpenChannelListFragment
to change different aspects of the screen. The OpenChannelListFragment.Builder
class allows you to create and customize the basic OpenChannelListFragment
that UIKit provides but you can only change its own APIs, such as setting a layout. If you wish to customize the fragment beyond using the APIs provided in the builder, you must inherit new customization methods.
The following table shows the main classes used in OpenChannelListFragment
to display and customize the channel list screen.
Fragment | Module | Component | Style | RecyclerView |
---|---|---|---|---|
OpenChannelListFragment | OpenChannelListModule | HeaderComponent | Module.OpenChannelList | OpenChannelListAdapter |
Depending on the UI or the feature you wish to customize in the fragment, you can change the classes mentioned in the table. To learn how to customize the fragment, see the Customizations overview page for further details.
Note: The links to the Customization page provide an example of how to customize classes related to
OpenChannelFragment
. In order to make changes to the channel list, you must use the correct classes.