Skip to content

invalidate() method not working? #723

@gao746700783

Description

@gao746700783

when I use a fragment by replace method,like this:

childFragmentManager.commitTransaction(allowStateLoss)

by replace methods, do actions below:
childFragment1 -> childFragment2->childFragment1

childFragment1 's invalidate()method will not work,my childFragment1 like this:

@AndroidEntryPoint
class AMapRadarFragment : VectorBaseFragment<LayoutRadarSearchBinding>() {

    private val viewModel: AmapFragViewModel by parentFragmentViewModel()

    private lateinit var mAdapter: CommonBindingAdapter<PoiSearchItem?>

    override fun getBinding(
        inflater: LayoutInflater,
        container: ViewGroup?
    ): LayoutRadarSearchBinding {
        return LayoutRadarSearchBinding.inflate(inflater, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        setupToolbar()
        setupSearchAction()
        setupSearchUi()
    }

    @OptIn(FlowPreview::class)
    private fun setupToolbar() {
//        setupToolbar(views.toolbar).allowBack()
        views.ivPanelBack.debouncedClicks {
            Timber.d("onPanelBackClick...")
            viewModel.handle(AmapFragAction.ChangePanelState(false))
        }
    }

    @OptIn(FlowPreview::class)
    private fun setupSearchAction() {
    }

    private fun setupSearchUi() {
    }

    @SuppressLint("NotifyDataSetChanged")
    override fun invalidate() = withState(viewModel) { state ->
        state.panelState.let {
            Timber.d("it:$it")
            if (it.not()) {
                views.searchView.clearFocus()
                views.searchView.hideKeyboard()
            }
        }
    }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions