Skip to content

Instantly share code, notes, and snippets.

@n8ebel
Last active January 25, 2018 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n8ebel/fa980ee2331fccf54d1a9862161746df to your computer and use it in GitHub Desktop.
Save n8ebel/fa980ee2331fccf54d1a9862161746df to your computer and use it in GitHub Desktop.
typealias SnackFinishedListener = () -> Unit
typealias SnackActionListener = () -> Unit
/**
* Representation of [Snackbar] data that can be exposed by a view model, observed, and bound to
* the current UI
*/
sealed class SnackData
/**
* Indicates that a [Snackbar] should be hidden
*/
object NoSnack : SnackData()
/**
* Indicates a [Snackbar] that should not be automatically dismissed and is shown
* with [Snackbar.LENGTH_INDEFINITE]
*/
open class StickySnack(
@StringRes val msgId:Int, val dismissListener: SnackFinishedListener = {},
@StringRes val actionMsgId:Int = 0, val actionListener: SnackFinishedListener = {}) : SnackData()
/**
* Indicates a [Snackbar] that should be shown with [Snackbar.LENGTH_SHORT]
*/
data class ShortSnack(@StringRes val msgId:Int, val dismissListener: SnackFinishedListener = {},
@StringRes val actionMsgId:Int = 0, val actionListener: SnackFinishedListener = {}) : SnackData()
/**
* Indicates a [Snackbar] that should be shown with [Snackbar.LENGTH_LONG]
*/
data class LongSnack(@StringRes val msgId:Int, val dismissListener: SnackFinishedListener = {},
@StringRes val actionMsgId:Int = 0, val actionListener: SnackFinishedListener = {}) : SnackData()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment