Skip to content

Commit

Permalink
Set fragmentReorderingAllowed=TRUE by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
terrakok committed Nov 5, 2020
1 parent a943aab commit 3da8fe5
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ open class AppNavigator @JvmOverloads constructor(
protected val activity: FragmentActivity,
protected val containerId: Int,
protected val fragmentManager: FragmentManager = activity.supportFragmentManager,
protected val fragmentFactory: FragmentFactory = FragmentFactory()
protected val fragmentFactory: FragmentFactory = fragmentManager.fragmentFactory
) : Navigator {

protected val localStackCopy = mutableListOf<TransactionInfo>()
Expand Down Expand Up @@ -109,6 +109,7 @@ open class AppNavigator @JvmOverloads constructor(
) {
val fragment = screen.createFragment(fragmentFactory)
val transaction = fragmentManager.beginTransaction()
transaction.setReorderingAllowed(true)
setupFragmentTransaction(
transaction,
fragmentManager.findFragmentById(containerId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public Fragment findFragmentById(int id) {
throw new RuntimeException("Stub!");
}

public FragmentFactory getFragmentFactory() {
throw new RuntimeException("Stub!");
}

public interface BackStackEntry {
int getId();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
*/

public class FragmentTransaction {
public FragmentTransaction setReorderingAllowed(boolean reorderingAllowed) {
throw new RuntimeException("Stub!");
}

public FragmentTransaction add(int containerViewId, Fragment fragment, String tag) {
throw new RuntimeException("Stub!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ProfileActivity : AppCompatActivity() {
super.onPause()
}

private val navigator: Navigator = object : AppNavigator(this, R.id.container, supportFragmentManager, supportFragmentManager.fragmentFactory) {
private val navigator: Navigator = object : AppNavigator(this, R.id.container) {

override fun setupFragmentTransaction(fragmentTransaction: FragmentTransaction, currentFragment: Fragment?, nextFragment: Fragment?) {
if (currentFragment is ProfileFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import javax.inject.Inject
class TabContainerFragment : Fragment(), RouterProvider, BackButtonListener {

private val navigator: Navigator by lazy {
AppNavigator(activity!!, R.id.ftc_container, childFragmentManager, childFragmentManager.fragmentFactory)
AppNavigator(activity!!, R.id.ftc_container, childFragmentManager)
}

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MainActivity : MvpAppCompatActivity(), ChainHolder {
@Inject
lateinit var navigatorHolder: NavigatorHolder

private val navigator: Navigator = object : AppNavigator(this, R.id.main_container, supportFragmentManager, supportFragmentManager.fragmentFactory) {
private val navigator: Navigator = object : AppNavigator(this, R.id.main_container) {

override fun applyCommands(commands: Array<out Command>) {
super.applyCommands(commands)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class StartActivity : MvpAppCompatActivity(), StartActivityView {
@InjectPresenter
lateinit var presenter: StartActivityPresenter

private val navigator: Navigator = AppNavigator(this, -1, supportFragmentManager, supportFragmentManager.fragmentFactory)
private val navigator: Navigator = AppNavigator(this, -1)

@ProvidePresenter
fun createStartActivityPresenter() = StartActivityPresenter(router)
Expand Down

0 comments on commit 3da8fe5

Please sign in to comment.