UIKit Android v3
UIKit Android
UIKit
Android
Home
/
UIKit
/
Android
This is the new Docs for UIKit v3 for Android. To see the previous Docs, click here.

Invite users

Users can invite new users to a channel through InviteUserActivity or InviteUserFragment. All users are listed through pagination and members who already belong to the channel can't be selected. The user list can be customized to only include specific users.


Invite user screen

An invite user screen is composed of three components: header, user list, and user list status.

Header

The header component shows the title of the invite user screen, which says Invite users by default. It also has two buttons on the left and right corner of the header. When the left button is tapped, the finish() method of the activity is called to exit the current screen. When the right button is tapped, the selected users are invited to the channel. The view of the header is created and customized in the SelectUserHeaderComponent of the InviteUserModule.

User list

The user list component shows a list of users' profile images, names, and selectable checkboxes. By default, all users registered to the Sendbird application are retrieved in reverse chronological order of creation. However, members that already belong to the channel are disabled on the list. The view of the user list is created and customized in the InviteUserListComponent of the InviteUserModule. You can also change or add a new user to the list using InviteUserListAdapter.

User list status

The user list status component shows the result of the data request for a user list. The StatusComponent exists in the InviteUserModule 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 an invite user 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 an invite user screen through InviteUserActivity, which uses UIKitFragmentFactory to create views.

Start an activity

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

Intent intent = InviteUserActivity.newIntent(context, "channel_url");
startActivity(intent);

Create a fragment

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

InviteUserFragment fragment = new InviteUserFragment.Builder("channel_url").build();

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


Customization

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

FragmentModuleComponentStyleRecyclerView

InviteUserFragment

InviteUserModule

SelectUserHeaderComponent

InviteUserListComponent

StatusComponent

Module.InviteUser

InviteUserListAdapter

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, follow the links to Customization listed below:

Customize the layout of the view Customize style of the view Bind event handlers to the view Add new APIs to the fragment Update or change an item in a list

Note: The links to the above customization pages provide an example of how to customize classes related to ChannelFragment. In order to make changes to the invite user screen, you must use the correct classes.