Channel List View

LAST EDIT Apr 26 2021

ChannelListView is responsible for displaying list of channels. It also supports loading and empty states. By default, a single list item shows the channel name, user's read state, last message, and the time of the last message. It also implements swiping behaviour which allows handling different actions on the channel: 

You can use the view in your layout as shown below:

Binding with a ViewModel


ChannelListView allows you to display different channels list states and handle common user's interactions, but it doesn't contain logic for getting channels from the Stream API. The Android SDK comes with ChannelListViewModel which contains default logic for this view, which can be easily bound to it using bindView:

This call connects the ViewModel with the view and from that point, different channels view states, as well as channel's pagination, will be handled automatically.

It's worth mentioning that you don't need to query channels by yourself. The first call will be done during the creation of ChannelListViewModel and the list will be kept updated automatically based on received events.

Handling Channel Actions


ChannelListView comes with a set of channel actions out of the box. You can:

  • See channel members

  • Delete the channel if you have sufficient permissions

  • Leave the channel if it's a group channel

There are some actions (e.g. clicking on member or Viewing Info) that require additional handling:

Handling User Interactions


ChannelListView exposes multiple methods for setting listeners for user interactions handling, that includes different user clicks handling:

A full list of available listeners to set can be found here.

Customizing Default Views


The view allows setting custom loading and empty views, as well as and separators via code:

Custom ViewHolder Factory


ChannelListView provides a mechanism for completely changing the default view holders, as well as introducing different types of views. All you need to do is to provide your own ChannelListItemViewHolderFactory implementation:

NOTE: The View Holder Factory needs to be set before ChannelListView initializes its adapter.

Other Customizations


The view is configurable either by attributes (a list of available attributes can be found here) and can be configured programmatically using TransformStyle.channelListStyleTransformer (a list of supported customizations can be found here):

NOTE: The style transformer should be set before the view is rendered to make sure that the new style was applied.