I have an app with few fragments. There are one fragment, which is host for ViewPager 2
, and there are 4 fragments, that are "swipeable". There's one more fragment, which is not present in ViewPager
. It is accessible via NavigationComponents
.
These fragments, that are using ViewPager
, has it owns toolbar. I'd like to send fragment's TAG
to the host fragment, so it will know, where to redirect ViewPager
later on. After receiving the TAG
, it should move to fragment, which is accessible only via Navigation Components
.
The problem is, I'm not sure how I should approach it. Should I create a ViewModel for host fragment, and there should I set LiveData
with TAG
, or should I make an Singleton object
inside the host fragment, send the TAG
from fragment inside of ViewPager
, and then, trigger Navigation Components
?
I need to pass the TAG
of the fragment inside of ViewPager, because I want program to know, where it should back after some stuff done in fragment from Navigation Components.