Fix closing welcome bottom sheet
This commit is contained in:
@@ -428,10 +428,16 @@ class AppRouter private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun closeWelcomeSheet(): Boolean {
|
fun closeWelcomeSheet(): Boolean {
|
||||||
val fm = fragment?.parentFragmentManager ?: activity?.supportFragmentManager ?: return false
|
val tag = fragmentTag<WelcomeSheet>()
|
||||||
val sheet = fm.findFragmentByTag(fragmentTag<WelcomeSheet>()) as? WelcomeSheet ?: return false
|
val sheet = fragment?.findFragmentByTagRecursive(tag)
|
||||||
sheet.dismissAllowingStateLoss()
|
?: activity?.supportFragmentManager?.findFragmentByTag(tag)
|
||||||
return true
|
?: return false
|
||||||
|
return if (sheet is WelcomeSheet) {
|
||||||
|
sheet.dismissAllowingStateLoss()
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Private utils **/
|
/** Private utils **/
|
||||||
@@ -478,6 +484,18 @@ class AppRouter private constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun Fragment.findFragmentByTagRecursive(fragmentTag: String): Fragment? {
|
||||||
|
childFragmentManager.findFragmentByTag(fragmentTag)?.let {
|
||||||
|
return it
|
||||||
|
}
|
||||||
|
val parent = parentFragment
|
||||||
|
return if (parent != null) {
|
||||||
|
parent.findFragmentByTagRecursive(fragmentTag)
|
||||||
|
} else {
|
||||||
|
parentFragmentManager.findFragmentByTag(fragmentTag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun from(view: View): AppRouter? = runCatching {
|
fun from(view: View): AppRouter? = runCatching {
|
||||||
|
|||||||
Reference in New Issue
Block a user