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()
}
}
}
}
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: