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

Filter channel list

Copy link

You can statically filter a channel list when retrieving them by creating custom instances of GroupChannelListQuery. Currently, dynamic filtering is not supported. To change the filtering criteria, you must recreate GroupChannelListQuery.


Set GroupChannelListQuery within ViewModel

Copy link

The ChannelListViewModel is responsible for retrieving and managing a channel list. You can filter a channel list by modifying the properties of GroupChannelListQueryParams of ChannelListViewModel.

To apply a filter, inherit from ChannelListViewModel and implement the createGroupChannelListQuery() method. If you call the super.createGroupChannelListQuery() method, you can utilize the default GroupChannelListQuery.

class ChannelListFilteringSampleViewModel() : ChannelListViewModel(null) {
    override fun createGroupChannelListQuery(): GroupChannelListQuery {
        return GroupChannel.createMyGroupChannelListQuery(
            GroupChannelListQueryParams().apply {
                order = GroupChannelListQueryOrder.CHANNEL_NAME_ALPHABETICAL
                superChannelFilter = SuperChannelFilter.NONSUPER_CHANNEL_ONLY
                /*
                includeEmpty = false
                includeFrozen = true
                unreadChannelFilter = UnreadChannelFilter.ALL
                hiddenChannelFilter = HiddenChannelFilter.ALL
                myMemberStateFilter = MyMemberStateFilter.ALL
                ...
                  */
            }
        )
    }
}

Set GroupChannelListQuery using fragment builder

Copy link

The ChannelListFragment.Builder also provides an interface to customize the GroupChannelListQuery. In this case, however, the default setting used by the UIKit can't be retrieved.

val fragment = ChannelListFragment.Builder()
    .setGroupChannelListQuery(
        GroupChannel.createMyGroupChannelListQuery(
            GroupChannelListQueryParams().apply {
                order = GroupChannelListQueryOrder.CHANNEL_NAME_ALPHABETICAL
                superChannelFilter = SuperChannelFilter.NONSUPER_CHANNEL_ONLY
                /*
                includeEmpty = false
                includeFrozen = true
                unreadChannelFilter = UnreadChannelFilter.ALL
                hiddenChannelFilter = HiddenChannelFilter.ALL
                myMemberStateFilter = MyMemberStateFilter.ALL
                ...
                  */
            }
        )
    ).build()

For an in-depth practical demonstration, see our sample code.