ConversationItem.Builder
public final class ConversationItem.Builder
A builder for ConversationItem
Summary
Public constructors |
|---|
This method is deprecated. Returns an empty |
Builder(@NonNull ConversationItem other)Returns a builder from the given |
Builder(Creates a |
Public methods |
|
|---|---|
@NonNull ConversationItem.Builder |
Adds an additional action for the conversation. |
@NonNull ConversationItem |
build()Returns a new |
@NonNull ConversationItem.Builder |
setConversationCallback(Sets a |
@NonNull ConversationItem.Builder |
setGroupConversation(boolean isGroupConversation)Specifies whether this conversation involves 3+ participants (a "group" conversation) |
@NonNull ConversationItem.Builder |
Sets a |
@NonNull ConversationItem.Builder |
Specifies a unique identifier for the conversation |
@NonNull ConversationItem.Builder |
@RequiresCarApi(value = 8)Sets whether this item can be included in indexed lists. |
@NonNull ConversationItem.Builder |
setMessages(@NonNull List<CarMessage> messages)Specifies a list of messages for the conversation |
@NonNull ConversationItem.Builder |
Sets a |
@NonNull ConversationItem.Builder |
Sets the title of the conversation |
Public constructors
Builder
public Builder(@NonNull ConversationItem other)
Returns a builder from the given ConversationItem.
Builder
public Builder(
@NonNull String id,
@NonNull CarText title,
@NonNull Person self,
@NonNull List<CarMessage> messages,
@NonNull ConversationCallback conversationCallback
)
Creates a Builder instance with the provided required params.
| Parameters | |
|---|---|
@NonNull String id |
Specifies a unique identifier for the conversation IDs may be used for a variety of purposes, including...
|
@NonNull CarText title |
Title of the conversation |
@NonNull Person self |
|
@NonNull List<CarMessage> messages |
Specifies a list of messages for the conversation The messages should be sorted from oldest to newest and should not contain any null values. |
@NonNull ConversationCallback conversationCallback |
|
Public methods
addAction
public @NonNull ConversationItem.Builder addAction(@NonNull Action action)
Adds an additional action for the conversation.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
java.lang.IllegalArgumentException |
if |
build
public @NonNull ConversationItem build()
Returns a new ConversationItem instance defined by this builder
setConversationCallback
public @NonNull ConversationItem.Builder setConversationCallback(
@NonNull ConversationCallback conversationCallback
)
Sets a ConversationCallback for the conversation
setGroupConversation
public @NonNull ConversationItem.Builder setGroupConversation(boolean isGroupConversation)
Specifies whether this conversation involves 3+ participants (a "group" conversation)
If unspecified, conversations are assumed to have exactly two participants (a "1:1" conversation)
UX presentation may differ slightly between group and 1:1 conversations. As a historical example, message readout may include sender names for group conversations, but omit them for 1:1 conversations.
setIcon
public @NonNull ConversationItem.Builder setIcon(@NonNull CarIcon icon)
Sets a CarIcon for the conversation
setId
public @NonNull ConversationItem.Builder setId(@NonNull String id)
Specifies a unique identifier for the conversation
IDs may be used for a variety of purposes, including...
- Distinguishing new
ConversationItems from updatedConversationItems in the UI, when data is refreshed - Identifying
ConversationItems in "mark as read" / "reply" callbacks
setIndexable
@RequiresCarApi(value = 8)
public @NonNull ConversationItem.Builder setIndexable(boolean indexable)
Sets whether this item can be included in indexed lists. By default, this is set to true.
The host creates indexed lists to help users navigate through long lists more easily by sorting, filtering, or some other means.
For example, a messaging app may show conversations by last message received. If the app provides these conversations via the SectionedItemTemplate and enables #isAlphabeticalIndexingAllowed, the user will be able to jump to their conversations that start with a given letter they chose. The messaging app can choose to hide, for example, service messages from this filtered list by setting this
#setIndexable(false).
Individual items can be set to be included or excluded from filtered lists, but it's also possible to enable/disable the creation of filtered lists as a whole via the template's API (eg. SectionedItemTemplate
.Builder#setAlphabeticalIndexingAllowed(Boolean)).
setMessages
public @NonNull ConversationItem.Builder setMessages(@NonNull List<CarMessage> messages)
Specifies a list of messages for the conversation
The messages should be sorted from oldest to newest and should not contain any null values.