Skip to content

Instantly share code, notes, and snippets.

@imablanco
Last active August 16, 2018 23:21
Show Gist options
  • Save imablanco/27fa1bdb78e5d07b5fc93834453117df to your computer and use it in GitHub Desktop.
Save imablanco/27fa1bdb78e5d07b5fc93834453117df to your computer and use it in GitHub Desktop.
class DialogFragmentPresenter(val context: FragmentActivity) : DefaultLifecycleObserver {
private var canShowDialogs: Boolean = false
override fun onResume(owner: LifecycleOwner) {
canShowDialogs = true
}
override fun onPause(owner: LifecycleOwner) {
canShowDialogs = false
}
fun show(dialogFragment: DialogFragment, tag: String? = null) {
if (canShowDialogs) {
dialogFragment.show(context.supportFragmentManager, tag)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment