Fragments: use commitTransaction instead of commitNow

This commit is contained in:
ganfra 2020-07-09 17:46:59 +02:00
parent 548879bd9f
commit da7c971927
3 changed files with 14 additions and 13 deletions

View File

@ -23,21 +23,21 @@ import androidx.fragment.app.FragmentTransaction
import im.vector.riotx.core.platform.VectorBaseActivity
fun VectorBaseActivity.addFragment(frameId: Int, fragment: Fragment) {
supportFragmentManager.commitTransactionNow { add(frameId, fragment) }
supportFragmentManager.commitTransaction { add(frameId, fragment) }
}
fun <T : Fragment> VectorBaseActivity.addFragment(frameId: Int, fragmentClass: Class<T>, params: Parcelable? = null, tag: String? = null) {
supportFragmentManager.commitTransactionNow {
supportFragmentManager.commitTransaction {
add(frameId, fragmentClass, params.toMvRxBundle(), tag)
}
}
fun VectorBaseActivity.replaceFragment(frameId: Int, fragment: Fragment, tag: String? = null) {
supportFragmentManager.commitTransactionNow { replace(frameId, fragment, tag) }
supportFragmentManager.commitTransaction { replace(frameId, fragment, tag) }
}
fun <T : Fragment> VectorBaseActivity.replaceFragment(frameId: Int, fragmentClass: Class<T>, params: Parcelable? = null, tag: String? = null) {
supportFragmentManager.commitTransactionNow {
supportFragmentManager.commitTransaction {
replace(frameId, fragmentClass, params.toMvRxBundle(), tag)
}
}

View File

@ -21,21 +21,21 @@ import androidx.fragment.app.Fragment
import im.vector.riotx.core.platform.VectorBaseFragment
fun VectorBaseFragment.addFragment(frameId: Int, fragment: Fragment) {
parentFragmentManager.commitTransactionNow { add(frameId, fragment) }
parentFragmentManager.commitTransaction { add(frameId, fragment) }
}
fun <T : Fragment> VectorBaseFragment.addFragment(frameId: Int, fragmentClass: Class<T>, params: Parcelable? = null, tag: String? = null) {
parentFragmentManager.commitTransactionNow {
parentFragmentManager.commitTransaction {
add(frameId, fragmentClass, params.toMvRxBundle(), tag)
}
}
fun VectorBaseFragment.replaceFragment(frameId: Int, fragment: Fragment) {
parentFragmentManager.commitTransactionNow { replace(frameId, fragment) }
parentFragmentManager.commitTransaction { replace(frameId, fragment) }
}
fun <T : Fragment> VectorBaseFragment.replaceFragment(frameId: Int, fragmentClass: Class<T>, params: Parcelable? = null, tag: String? = null) {
parentFragmentManager.commitTransactionNow {
parentFragmentManager.commitTransaction {
replace(frameId, fragmentClass, params.toMvRxBundle(), tag)
}
}
@ -51,21 +51,21 @@ fun <T : Fragment> VectorBaseFragment.addFragmentToBackstack(frameId: Int, fragm
}
fun VectorBaseFragment.addChildFragment(frameId: Int, fragment: Fragment, tag: String? = null) {
childFragmentManager.commitTransactionNow { add(frameId, fragment, tag) }
childFragmentManager.commitTransaction { add(frameId, fragment, tag) }
}
fun <T : Fragment> VectorBaseFragment.addChildFragment(frameId: Int, fragmentClass: Class<T>, params: Parcelable? = null, tag: String? = null) {
childFragmentManager.commitTransactionNow {
childFragmentManager.commitTransaction {
add(frameId, fragmentClass, params.toMvRxBundle(), tag)
}
}
fun VectorBaseFragment.replaceChildFragment(frameId: Int, fragment: Fragment, tag: String? = null) {
childFragmentManager.commitTransactionNow { replace(frameId, fragment, tag) }
childFragmentManager.commitTransaction { replace(frameId, fragment, tag) }
}
fun <T : Fragment> VectorBaseFragment.replaceChildFragment(frameId: Int, fragmentClass: Class<T>, params: Parcelable? = null, tag: String? = null) {
childFragmentManager.commitTransactionNow {
childFragmentManager.commitTransaction {
replace(frameId, fragmentClass, params.toMvRxBundle(), tag)
}
}

View File

@ -32,6 +32,7 @@ import im.vector.matrix.android.api.session.group.model.GroupSummary
import im.vector.matrix.android.api.util.toMatrixItem
import im.vector.matrix.android.internal.crypto.model.rest.DeviceInfo
import im.vector.riotx.R
import im.vector.riotx.core.extensions.commitTransaction
import im.vector.riotx.core.extensions.commitTransactionNow
import im.vector.riotx.core.glide.GlideApp
import im.vector.riotx.core.platform.ToolbarConfigurable
@ -275,7 +276,7 @@ class HomeDetailFragment @Inject constructor(
private fun updateSelectedFragment(displayMode: RoomListDisplayMode) {
val fragmentTag = "FRAGMENT_TAG_${displayMode.name}"
val fragmentToShow = childFragmentManager.findFragmentByTag(fragmentTag)
childFragmentManager.commitTransactionNow {
childFragmentManager.commitTransaction {
childFragmentManager.fragments
.filter { it != fragmentToShow }
.forEach {