-
- All Implemented Interfaces:
-
androidx.lifecycle.ViewModelProvider.Factory
public final class MessagesViewModelFactory implements ViewModelProvider.Factory
Holds all the dependencies needed to build the ViewModels for the Messages Screen. Currently builds the MessageComposerViewModel, MessageListViewModel and AttachmentsPickerViewModel.
-
-
Constructor Summary
Constructors Constructor Description MessagesViewModelFactory(Context context, String channelId, String messageId, String parentMessageId, Boolean autoTranslationEnabled, ChatClient chatClient, ClientState clientState, StreamMediaRecorder mediaRecorder, UserLookupHandler userLookupHandler, Function1<File, String> fileToUriConverter, Integer messageLimit, ClipboardHandler clipboardHandler, Boolean enforceUniqueReactions, Integer maxAttachmentCount, Boolean showSystemMessages, DeletedMessageVisibility deletedMessageVisibility, MessageFooterVisibility messageFooterVisibility, DateSeparatorHandler dateSeparatorHandler, DateSeparatorHandler threadDateSeparatorHandler, MessagePositionHandler messagePositionHandler, Boolean showDateSeparatorInEmptyThread, Boolean showThreadSeparatorInEmptyThread, Boolean threadLoadOlderToNewer, Boolean isComposerLinkPreviewEnabled, Boolean isComposerDraftMessageEnabled)
-
Method Summary
Modifier and Type Method Description <T extends ViewModel> Tcreate(Class<T> modelClass)Creates the required ViewModel for our use case, based on the factories we provided. <T extends ViewModel> Tcreate(Class<T> modelClass, CreationExtras extras)Creates the required ViewModel with access to CreationExtras, which provides a SavedStateHandle for persisting state across process death. -
-
Constructor Detail
-
MessagesViewModelFactory
MessagesViewModelFactory(Context context, String channelId, String messageId, String parentMessageId, Boolean autoTranslationEnabled, ChatClient chatClient, ClientState clientState, StreamMediaRecorder mediaRecorder, UserLookupHandler userLookupHandler, Function1<File, String> fileToUriConverter, Integer messageLimit, ClipboardHandler clipboardHandler, Boolean enforceUniqueReactions, Integer maxAttachmentCount, Boolean showSystemMessages, DeletedMessageVisibility deletedMessageVisibility, MessageFooterVisibility messageFooterVisibility, DateSeparatorHandler dateSeparatorHandler, DateSeparatorHandler threadDateSeparatorHandler, MessagePositionHandler messagePositionHandler, Boolean showDateSeparatorInEmptyThread, Boolean showThreadSeparatorInEmptyThread, Boolean threadLoadOlderToNewer, Boolean isComposerLinkPreviewEnabled, Boolean isComposerDraftMessageEnabled)
- Parameters:
context- Used to build the ClipboardManager.channelId- The current channel ID, to load the messages from.messageId- The message id to which we want to scroll to when opening the message list.parentMessageId- The ID of the parent Message if the message we want to scroll to is in a thread.chatClient- The client to use for API calls.clientState- The current state of the SDK.mediaRecorder- The media recorder for async voice messages.messageLimit- The number of messages to load in a single page.clipboardHandler- ClipboardHandler used to copy messages.enforceUniqueReactions- Flag to enforce unique reactions or enable multiple from the same user.maxAttachmentCount- The maximum number of attachments that can be sent in a single message.showSystemMessages- If we should show system message items in the list.deletedMessageVisibility- The behavior of deleted messages in the list and if they're visible or not.messageFooterVisibility- The behavior of message footers in the list and their visibility.dateSeparatorHandler- Handler that determines when the date separators should be visible.threadDateSeparatorHandler- Handler that determines when the thread date separators should be visible.messagePositionHandler- Determines the position of the message inside a group.showDateSeparatorInEmptyThread- Configures if we show a date separator when threads are empty.showThreadSeparatorInEmptyThread- Configures if we show a thread separator when threads are empty.threadLoadOlderToNewer- Configures if the thread should load older messages to newer messages.isComposerLinkPreviewEnabled- If the link preview is enabled in the composer.isComposerDraftMessageEnabled- If the draft message is enabled in the composer.
-
-
Method Detail
-
create
<T extends ViewModel> T create(Class<T> modelClass)
Creates the required ViewModel for our use case, based on the factories we provided.
-
create
<T extends ViewModel> T create(Class<T> modelClass, CreationExtras extras)
Creates the required ViewModel with access to CreationExtras, which provides a SavedStateHandle for persisting state across process death.
Called by Compose's
viewModel()helper. Falls back to create for ViewModels that do not require a SavedStateHandle.
-
-
-
-