Skip to content

Instantly share code, notes, and snippets.

@mrahimygk
Created June 17, 2020 08:52
Show Gist options
  • Select an option

  • Save mrahimygk/ae2bc2d0a4b6978f42d81599ad65e7a9 to your computer and use it in GitHub Desktop.

Select an option

Save mrahimygk/ae2bc2d0a4b6978f42d81599ad65e7a9 to your computer and use it in GitHub Desktop.

Revisions

  1. mrahimygk created this gist Jun 17, 2020.
    34 changes: 34 additions & 0 deletions BaseFragment.kt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    private fun bindParentObservables() {
    viewModel.snackMessageCommand.observe(viewLifecycleOwner, EventObserver { command ->
    when (command) {
    is SnackCommand.StringResSnackCommand ->
    view?.showSnackBar(
    command.message,
    duration = command.duration
    )

    is SnackCommand.StringSnackCommand ->
    view?.showSnackBar(
    command.message,
    duration = command.duration
    )


    is SnackCommand.ActionedStringSnackCommand -> {
    view?.showSnackBar(
    command.message,
    duration = command.duration,
    action = command.action.paired()
    )
    }

    is SnackCommand.ActionedStringResSnackCommand -> {
    view?.showSnackBar(
    command.message,
    duration = command.duration,
    action = command.action.paired()
    )
    }
    }
    })
    }