Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SearchView] TransitionListener not work after fragment resume #4145

Open
onlymash opened this issue Apr 15, 2024 · 1 comment
Open

[SearchView] TransitionListener not work after fragment resume #4145

onlymash opened this issue Apr 15, 2024 · 1 comment

Comments

@onlymash
Copy link

Description:

I put SearchView in a fragment and hide or show the BottomNavigationView according to the state of the searchview. Once I switch to another fragment and back, the TransitionListener is not called

Expected behavior:

video_2024-04-16_01-08-14.mp4

Source code:

    private val transitionListener = SearchView.TransitionListener { _, _, newState ->
            Log.w("HomeFragment", "newState: ${newState.name}")
            if (newState == SearchView.TransitionState.SHOWING) {
                (activity as? MainActivity)?.hideNavView()
            } else if (newState == SearchView.TransitionState.HIDDEN) {
                (activity as? MainActivity)?.showNavView()
            }
        }

    override fun onResume() {
        super.onResume()
        searchViewBinding.searchView.addTransitionListener(transitionListener)
    }

    override fun onPause() {
        super.onPause()
        searchViewBinding.searchView.removeTransitionListener(transitionListener)
    }

Minimal sample app repro: Please consider attaching a minimal sample app that reproduces the issue. This will help narrow down the conditions required for reproducing the issue, and it will speed up the bug fix process. You may attach a zip file of the sample app or link to a GitHub repo that contains the sample app.

Android API version: 34

Material Library version: 1.11.0

Device: OnePlus 12

@onlymash
Copy link
Author

It seems that searchview can only be used in activity. If it is placed in fragment, windowinsets will be invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants