Last active
August 16, 2018 23:21
-
-
Save imablanco/27fa1bdb78e5d07b5fc93834453117df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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