MediaContentViewModel

class MediaContentViewModel(mediaItems: LiveData<List<IviMediaItem>>, mediaService: MediaServiceApi, @WorkerThread mediaItemMatcher: MediaItemMatcher, onItemClickAction: ClickAction, isLoading: LiveData<Boolean> = ImmutableLiveData(false), layoutPolicy: LiveData<LayoutPolicy> = ImmutableLiveData(LinearLayoutPolicy()), groupByHeaders: LiveData<Boolean> = ImmutableLiveData(true), dispatcher: CoroutineDispatcher = Dispatchers.Default)

ViewModel for displaying media items. Provides a list of MediaContentItemViewModel which is updated according to input LiveData parameters.

Parameters

mediaItems

A list of incoming IviMediaItem, which is transformed into items.

mediaService

A media service that is used to get MediaServiceState: information about the currently active item, source, and playback state.

mediaItemMatcher

Used to match an item to the currently active item. This is needed to determine the item's IviPlaybackState.

onItemClickAction

An action that should be called when clicking an item from items list.

isLoading

If true, an empty list if items is returned. This is used to reduce visual glitches during content loading.

layoutPolicy

Used to determine ListGroupItem.ItemType for items.

groupByHeaders

If true, the items would be grouped by ItemType.HEADER based on the IviMediaItem.groupTitleHint.

dispatcher

A dispatcher which is used during items mapping. Could be substituted for testing purposes.

Constructors

Link copied to clipboard
constructor(mediaItems: LiveData<List<IviMediaItem>>, mediaService: MediaServiceApi, @WorkerThread mediaItemMatcher: MediaItemMatcher, onItemClickAction: ClickAction, isLoading: LiveData<Boolean> = ImmutableLiveData(false), layoutPolicy: LiveData<LayoutPolicy> = ImmutableLiveData(LinearLayoutPolicy()), groupByHeaders: LiveData<Boolean> = ImmutableLiveData(true), dispatcher: CoroutineDispatcher = Dispatchers.Default)

Properties

Link copied to clipboard
Link copied to clipboard

Whether any of items is currently of ItemType.HEADER type.

Link copied to clipboard
Link copied to clipboard

List of items to be displayed by MediaContentView.