File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
extensionslib/src/main/java/com/omega_r/libs/extensions/fragment Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,27 @@ package com.omega_r.libs.extensions.fragment
33import androidx.fragment.app.FragmentManager
44import androidx.fragment.app.FragmentTransaction
55
6- inline fun FragmentManager.edit (block : FragmentTransaction .() -> Unit ) {
6+ inline fun FragmentManager.edit (
7+ commitNow : Boolean = false,
8+ allowingStateLoss : Boolean = false,
9+ block : FragmentTransaction .() -> Unit
10+ ) {
711 beginTransaction()
812 .apply (block)
9- .commit()
13+ .apply {
14+ commitAllowingStateLoss()
15+ if (commitNow) {
16+ if (allowingStateLoss) {
17+ commitNowAllowingStateLoss()
18+ } else {
19+ commitNow()
20+ }
21+ } else {
22+ if (allowingStateLoss) {
23+ commitAllowingStateLoss()
24+ } else {
25+ commit()
26+ }
27+ }
28+ }
1029}
You can’t perform that action at this time.
0 commit comments