ListItemContentViewModel

open class ListItemContentViewModel(itemId: Any, headImage: ImageDescriptor?, primaryTextArea: ListItemContentViewModel.TextAreaViewModel, secondaryTextArea: ListItemContentViewModel.TextAreaViewModel, tertiaryTextArea: ListItemContentViewModel.TextAreaViewModel, onClick: () -> Unit?, ratingBarValue: Float?, ratingBarMaximumValue: Int, ratingBarText: StringResolver?, tailText: StringResolver?, tailIcon: DrawableResolver?, onTailSectionClick: () -> Unit?) : ListItemViewModel

The ViewModel for populating the content of a non-header item in a TtListRecyclerView.

An item consists of a Head section, a Main section and a Tail section. The schematic overview of the item looks as below:

 _____________________________________________________________
| ______ | O Primary text | |
| | | | O Secondary text | ____ |
| | | | O Tertiary text | Tail text | | |
| |_____| | ***** Rating bar text | |___| |
|___________|____________________________|___________________|
Head Main Tail
section section section

Clients can inherit this ViewModel to provide more controls for the item, e.g. additional properties can be used to change the appearances of sections dynamically through the layout data-binding.

Parameters

itemId

A unique stable ID for the content item. See ListItemViewModel.itemId.

headImage

The image shown in the Head section. This can be a layered image with a radius.

primaryTextArea

The text area showing the Primary icon and the Primary text within the Main section.

secondaryTextArea

The text area showing the Secondary icon and the Secondary text within the Main section.

tertiaryTextArea

The text area showing the Tertiary icon and the Tertiary text within the Main section.

onClick

The callback function for when the Head section or Main section is clicked.

ratingBarValue

The value represents the current rating.

ratingBarMaximumValue

The maximum number to ratingBarValue.

ratingBarText

The additional text displayed together with the rating bar.

tailText

The text shown within the Tail section.

tailIcon

The image shown within the Tail section.

onTailSectionClick

The callback function for when specifically the Tail section is clicked.

Constructors

Link copied to clipboard
fun ListItemContentViewModel(itemId: Any, headImage: DrawableResolver? = null, primaryIcon: DrawableResolver? = null, primaryText: StringResolver? = null, secondaryIcon: DrawableResolver? = null, secondaryText: StringResolver? = null, tertiaryIcon: DrawableResolver? = null, tertiaryText: StringResolver? = null, onClick: () -> Unit? = null, ratingBarValue: Float? = null, ratingBarMaximumValue: Int = RATING_BAR_MAXIMUM_VALUE, ratingBarText: StringResolver? = null, tailText: StringResolver? = null, tailIcon: DrawableResolver? = null, onTailSectionClick: () -> Unit? = null)

A convenience constructor to populate the ViewModel where its headImage's ImageDescriptor.image is the headImage and the ImageType is ImageType.TINTABLE_ICON.

Link copied to clipboard
fun ListItemContentViewModel(itemId: Any, headImage: ImageDescriptor? = null, primaryTextArea: ListItemContentViewModel.TextAreaViewModel = TextAreaViewModel(), secondaryTextArea: ListItemContentViewModel.TextAreaViewModel = TextAreaViewModel(), tertiaryTextArea: ListItemContentViewModel.TextAreaViewModel = TextAreaViewModel(), onClick: () -> Unit? = null, ratingBarValue: Float? = null, ratingBarMaximumValue: Int = RATING_BAR_MAXIMUM_VALUE, ratingBarText: StringResolver? = null, tailText: StringResolver? = null, tailIcon: DrawableResolver? = null, onTailSectionClick: () -> Unit? = null)

Types

Link copied to clipboard
data class TextAreaViewModel(text: StringResolver?, icon: DrawableResolver?)

ViewModel used to populate primaryTextArea, secondaryTextArea and tertiaryTextArea.

Properties

Link copied to clipboard
val headImage: ImageDescriptor? = null
Link copied to clipboard
open override val itemId: Any
Link copied to clipboard
val onClick: () -> Unit? = null
Link copied to clipboard
val onTailSectionClick: () -> Unit? = null
Link copied to clipboard
Link copied to clipboard
val ratingBarMaximumValue: Int
Link copied to clipboard
val ratingBarText: StringResolver? = null
Link copied to clipboard
val ratingBarValue: Float? = null
Link copied to clipboard
Link copied to clipboard
val tailIcon: DrawableResolver? = null
Link copied to clipboard
val tailText: StringResolver? = null
Link copied to clipboard

Functions

Link copied to clipboard
open override fun getDrawableResolver(): DrawableResolver?

Returns the source image of headImage.

Link copied to clipboard
open override fun getStringResolver(): StringResolver?

Returns the text value from one of primaryTextArea, secondaryTextArea and tertiaryTextArea. Among these 3, primaryTextArea has the highest priority and tertiaryTextArea has the lowest priority. This means if the text value of primaryTextArea, secondaryTextArea and tertiaryTextArea are all set, this method returns the value of primaryTextArea.