-
- All Implemented Interfaces:
-
androidx.lifecycle.ViewModelProvider.Factory
public final class ChannelViewModelFactory 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 ChannelViewModelFactory(Context context, String channelId, String messageId, String parentMessageId, Boolean autoTranslationEnabled, ChatClient chatClient, ClientState clientState, StreamMediaRecorder mediaRecorder, UserLookupHandler userLookupHandler, Function1<File, String> fileToUriConverter, ClipboardHandler clipboardHandler, MessageListOptions messageListOptions, ComposerOptions composerOptions)
-
Method Summary
-
-
Constructor Detail
-
ChannelViewModelFactory
ChannelViewModelFactory(Context context, String channelId, String messageId, String parentMessageId, Boolean autoTranslationEnabled, ChatClient chatClient, ClientState clientState, StreamMediaRecorder mediaRecorder, UserLookupHandler userLookupHandler, Function1<File, String> fileToUriConverter, ClipboardHandler clipboardHandler, MessageListOptions messageListOptions, ComposerOptions composerOptions)
- Parameters:
context- Android context used to access system services and device storage.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 to open the screen directly in a thread: the message list is scoped to that thread and the composer starts in thread mode.autoTranslationEnabled- Whether auto-translation of messages is enabled.chatClient- The client to use for API calls.clientState- The current state of the SDK.mediaRecorder- The media recorder for async voice messages.userLookupHandler- Handler used to look up users for mention autocomplete.fileToUriConverter- Converts a local File to a URI string used as an attachment source.clipboardHandler- ClipboardHandler used to copy messages.messageListOptions- Configuration for the message list behavior.composerOptions- Configuration for the message composer behavior.
-
-
Method Detail
-
create
<T extends ViewModel> T create(Class<T> modelClass, CreationExtras extras)
Creates the required ViewModel for our use case.
Supports MessageComposerViewModel, MessageListViewModel, and AttachmentsPickerViewModel. MessageComposerViewModel and AttachmentsPickerViewModel will receive a SavedStateHandle sourced from extras, allowing them to survive Activity recreation. Throws IllegalArgumentException for any other class.
- Parameters:
modelClass- The class of the ViewModel to create.extras- CreationExtras provided by the androidx.lifecycle.ViewModelStoreOwner.
-
create
<T extends ViewModel> T create(Class<T> modelClass)
Creates the required ViewModel for our use case.
Supports MessageComposerViewModel, MessageListViewModel, and AttachmentsPickerViewModel. Throws IllegalArgumentException for any other class.
Prefer create with CreationExtras so that MessageComposerViewModel and AttachmentsPickerViewModel can survive Activity recreation.
- Parameters:
modelClass- The class of the ViewModel to create.
-
-
-
-