/ UIKit / Android View
UIKit
Chat UIKit Android View v3
Chat UIKit Android View
Chat UIKit
Android View
Version 3

List channels

Copy link

A channel list shows a complete list of group channels that the current user is a member of. 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

Copy link

A channel list screen is composed of three components: header, channel list, and channel list status.

Header

Copy link

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 ChannelListModule.

Channel list

Copy link

The channel list component shows a list of all channels that the current user is part of. The channel list creates a ReyclerView in the ChannelListComponent 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 ChannelListAdapter 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 group channel screen depending on the channel type.

Channel list status

Copy link

The channel list status component shows the result of the data request for a channel list. The StatusComponent exists in the ChannelListModule and lets the user know if the list is loading or if the list could not be called.


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 ChannelListActivity, which uses UIKitFragmentFactory to create views.

Start an activity

Copy link

You can start an activity by using intent to move from one activity to ChannelListActivity as shown below:

KotlinJava
val intent = ChannelListActivity.newIntent(context)
startActivity(intent)

Create a fragment

Copy link

ChannelListActivity allows you to create a basic ChannelListFragment through UIKitFragmentFactory and ChannelListFragment.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 ChannelListFragment. To see all APIs of ChannelListFragment.Builder, refer to the API reference page.

KotlinJava
val fragment = ChannelListFragment.Builder().build()

Note: To use UIKit's fragments as a nested fragment, refer to the Android Developer Documentation's Nested Fragments.

Implement push notifications

Copy link

You can also implement push notifications so users can access ChannelListActivity from other activities in the client app. Users should be able to access ChannelListActivity from a channel that they entered upon tapping on a push notification. The unique URL of the channel must be passed as an argument to a parameter when creating intent.

KotlinJava
val intent = ChannelListActivity.newRedirectToChannelIntent(context, CHANNEL_URL).apply {
    addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
}
val pendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    PendingIntent.getActivity(context, channelUrl.hashCode(), intent, PendingIntent.FLAG_IMMUTABLE)
} else {
    PendingIntent.getActivity(context, channelUrl.hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT)
}

Customization

Copy link

In the list channel key function, you can customize ChannelListFragment to change different aspects of the screen. The ChannelListFragment.Builder class allows you to create and customize the basic ChannelListFragment 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 ChannelListFragment to display and customize the channel list screen.

FragmentModuleComponentStyleRecyclerView

ChannelListFragment

ChannelListModule

HeaderComponent

ChannelListComponent

StatusComponent

Module.ChannelList

ChannelListAdapter

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 ChannelFragment. In order to make changes to the channel list, you must use the correct classes.