-
public final class ChannelKt
-
-
Method Summary
Modifier and Type Method Description final StringgetInitials()final static BooleanisDirectMessaging(Channel $self)Checks if the channel is a direct messaging channel. final static MessagegetPreviewMessage(Channel $self, User currentUser)Returns channel's last regular or system message if exists (including pending messages). final static StringgetDisplayName(Channel $self, Context context, User currentUser, @StringRes() Integer fallback, Integer maxMembers)Returns the channel name if exists, or the list of member names if the channel is distinct. final static StringgetMembersStatusText(Channel $self, Context context, User currentUser, Boolean countCurrentUserAsOnlineMember, Boolean countOtherUsersAsOnlineMembers, @StringRes() Integer userOnlineResId, @StringRes() Integer userLastSeenJustNowResId, @StringRes() Integer userLastSeenResId, @PluralsRes() Integer memberCountResId, @StringRes() Integer memberCountWithOnlineResId)Returns a string describing the member status of the channel: either a member count for a group channel or the last seen text for a direct one-to-one conversation with the current user. final static BooleanisOneToOne(Channel $self, User currentUser)Checks if the channel is a direct conversation between the current user and some other user. -
-
Method Detail
-
getInitials
final String getInitials()
-
isDirectMessaging
final static Boolean isDirectMessaging(Channel $self)
Checks if the channel is a direct messaging channel.
For a channel to be considered as direct messaging, it must satisfy two conditions:
It should have exactly two members.
One of the members must be the current user.
-
getPreviewMessage
final static Message getPreviewMessage(Channel $self, User currentUser)
Returns channel's last regular or system message if exists (including pending messages). Deleted and messages from shadow-banned users, are not taken into account.
-
getDisplayName
final static String getDisplayName(Channel $self, Context context, User currentUser, @StringRes() Integer fallback, Integer maxMembers)
Returns the channel name if exists, or the list of member names if the channel is distinct.
- Parameters:
context- The context to load string resources.currentUser- The currently logged-in user.fallback- The resource identifier of a fallback string if the Channel object lacks information to construct a valid display name string.maxMembers- The maximum number of members used to generate a name for a distinct channel.
-
getMembersStatusText
final static String getMembersStatusText(Channel $self, Context context, User currentUser, Boolean countCurrentUserAsOnlineMember, Boolean countOtherUsersAsOnlineMembers, @StringRes() Integer userOnlineResId, @StringRes() Integer userLastSeenJustNowResId, @StringRes() Integer userLastSeenResId, @PluralsRes() Integer memberCountResId, @StringRes() Integer memberCountWithOnlineResId)
Returns a string describing the member status of the channel: either a member count for a group channel or the last seen text for a direct one-to-one conversation with the current user.
- Parameters:
context- The context to load string resources.currentUser- The currently logged in user.countCurrentUserAsOnlineMember- Iftrue, the current user will be counted as an online member.countOtherUsersAsOnlineMembers- Iftrue, other users will be counted as online members.userOnlineResId- The resource identifier of the string representing an online user.userLastSeenJustNowResId- The resource identifier of the string representing a user who was last seen just now.userLastSeenResId- The resource identifier of the string representing a user who was last seen.memberCountResId- The resource identifier of the string representing the member count.
-
isOneToOne
final static Boolean isOneToOne(Channel $self, User currentUser)
Checks if the channel is a direct conversation between the current user and some other user.
A one-to-one chat is basically a corner case of a distinct channel with only 2 members.
- Parameters:
currentUser- The currently logged in user.
-
-
-
-