I'm trying to wrap my head around implementation of shared view transitions between fragments
The challenge is coming from the MVVP restricitons:
- Adapter of
RecycleView
has knowledge of selected element and view attached via callback fromView
- Adapter is passing information about click to
ViewModel
stripping out all information about view, as it can't hold it. That's because of rule - no android imports inViewModel
except of*arch
ViewModel
sends event toFragment
to open anotherFragment
- At this point
Fragment
doesn't know what view to use to start transition in.addSharedElement(..)
How to address this issue?
I was thinking about saving reference to clicked View
inside Fragment
instance but it looks like a cheating
Any ideas and suggestions are very welcome