TtToast

class TtToast

Toasts are used to provide non-critical feedback to a user. They show a brief message with an optional action a user can take. A toast will, when requested to be shown, search for a TtToastContainer and attach itself. This search for a TtToastContainer starts from a provided View and will traverse the parents of the provided view all through the view hierarchy.

Parameters

drawable

A image to be displayed in the front of the toast. When set to null, no drawable is shown.

drawableImageType

The ImageType of the displayed image in front of the toast. The default value is ImageType.DEFAULT.

primaryText

The primary text displayed in the toast.

secondaryText

The secondary text displayed in the toast.

actionLabel

A clickable label shown at the end of the toast. When clicked, onActionLabelClicked will be called.

onActionLabelClicked

The action to perform when clicked on actionLabel.

dismissesAfterTimeout

If true the toast will be dismissed after showing for a brief period of time. If false the toast will not be dismissed automatically, requiring either the user or the component showing it to dismiss it.

Types

Link copied to clipboard
class Builder

This class is used to construct TtToast objects.

Link copied to clipboard
object Companion
Link copied to clipboard

An interface for listeners that wish to receive a callback when a toast is dismissed.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val onActionLabelClicked: (toast: TtToast) -> Unit? = null
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun dismiss()

Dismiss this TtToast. This will call all the registered dismiss listeners indicating this toast has been dismissed.

Link copied to clipboard

Registers a listener that will be called whenever dismiss is called. If the listener is already registered, nothing happens.

Link copied to clipboard
fun show(view: View)

Shows this toast by adding it to the TtToastContainer closest to view. Starting from view it will traverse the parents of the provided view all through the view hierarchy searching for the first TtToastContainer it finds.

Link copied to clipboard
fun showInRoot(view: View)

Shows this toast by adding it to the TtToastContainer closest to the root in the view hierarchy of view. Starting from view it will traverse the parents of the provided view all through the view hierarchy searching the TtToastContainer closest to the root in the view hierarchy.

Link copied to clipboard

Unregisters a listener for dismiss calls. If the listener was not registered, nothing is unregistered.