Skip to content

Crashes if call goBack() after navigateTo() #29

@nvhaiwork

Description

@nvhaiwork

Case:
Fragment1 navigateTo() Fragment2
Fragment2 check condition, if data is invalid -> backTo() Fragment1 => crashes

It works if I use Handle.postDelay()

Fragment 1 Code: onViewCreated()

     getView()?.findViewById<TextView>(R.id.text)?.setOnClickListener {
        getView()?.findViewById<TextView>(R.id.text)?.text = "Clicked"
        val options = FragmentNavigator.NavOptions(
            transaction = FragmentNavigator.TransactionType.REPLACE,
            animation = AnimationDefinition.Zoom
        )
        (activity as MainActivity).navigate.navigateTo(Fragment2(),options)
    }

Fragment 2 code: onViewCreated()

     getView()?.findViewById<TextView>(R.id.text)?.setOnClickListener {
        getView()?.findViewById<TextView>(R.id.text)?.text = "Clicked"
        val options = FragmentNavigator.NavOptions(
            transaction = FragmentNavigator.TransactionType.ADD,
            animation = AnimationDefinition.Zoom
        )
        (activity as MainActivity).navigate.navigateTo(Fragment3(),options)
    }

    //Handler().postDelayed({
        (activity as MainActivity).navigate.goBack()
    //}, 1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions