Created
December 31, 2020 06:10
-
-
Save raxhaxor/961e3831cfd236fb102127a93882d1c5 to your computer and use it in GitHub Desktop.
commitAllowingStateLoss on DialogFragment
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
override fun show(manager: FragmentManager, tag: String?) { | |
try { | |
val superClass = this::class.java.superclass | |
val dismissedField = superClass?.getDeclaredField("mDismissed") | |
val isShownByMeField = superClass?.getDeclaredField("mShownByMe") | |
dismissedField?.isAccessible = true | |
isShownByMeField?.isAccessible = true | |
dismissedField?.setBoolean(this, false) | |
isShownByMeField?.setBoolean(this, true) | |
dismissedField?.isAccessible = false | |
isShownByMeField?.isAccessible = false | |
val ft = manager.beginTransaction() | |
ft.add(this, tag) | |
ft.commitAllowingStateLoss() | |
}catch(e: Exception){ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment