8000 MotionLayout + bindingcollectionadapter = 💔 · Issue #200 · evant/binding-collection-adapter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
MotionLayout + bindingcollectionadapter = 💔 #200
Open
@c-b-h

Description

@c-b-h

Is this a general databinding issue or question? You are more likely to get a
response from somewhere like
StackOverflow.

Issue

Our team uses me.tatarka.bindingcollectionadapter2:bindingcollectionadapter-recyclerview:4.0.0 extensively and hasn't encountered any major issues until recently. We have started to investigate how to use MotionLayout in our apps and faced a challenge when the widget is combined with this library.

I have created a tiny Android project that should be self-explanatory where a switch of the container of quiz__multiple from ConstraintLayout to MotionLayout causes the RecyclerView's elements not to be shown.

Some background

We are both feeding a ViewPager2 with a collection of a custom SubViewModels while each SubViewModel in turn has binding data that RecyclerView is fed with.

We are using ViewStub to conditionally inflate various (heavy) layouts. The inflated layouts are also data bound and need to explicitly be assigned a LifecycleOwner and we do that by hooking into ViewStub's data binding adapters:

override fun onInflate(stub: ViewStub, inflated: View) {
    inflated.doOnAttach { view ->
        DataBindingUtil.getBinding<ViewDataBinding>(view)!!.apply {
            lifecycleOwner = ViewTreeLifecycleOwner.get(root)
            setVariable(BR.subViewModel, this@SubViewModel)
        }
    }
}

The issue is that if the user doesn't interact with the (hidden) RecyclerView its content will not be shown.

buttons_not_appearing

My best guess is that this is due to the OnRebindCallback that BindingRecyclerViewAdapter registers. Note that the issue does not occur if the MotionLayout is swapped with ConstraintLayout. The animation seems to be the culprit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0