Hi guys! I have a question regarding MVVM. Let’s ...
# android-architecture
j
Hi guys! I have a question regarding MVVM. Let’s say I have a ViewPager that has 3 pages and has automatic scrolling feature. (this viewpager goes back to page 1 when reaching page 3). The auto scrolling feature is PAUSED everytime the viewpager receives a touch action. Now, should the logic of setting view pager’s current item to 1 if it reaches 3, and the pausing of auto scroll when view pager receives touch event RESIDE in ViewModel? In my understanding. Purely UI logic can stay in activity/fragment. Logic that can reside in ViewModel can include enabling/disabling buttons (depending on the input), validating inputs, etc. Any inputs are greatly appreciated! 🙂
a
Now it possible in
ViewPager2
to enable/disable swiping by using
myViewPager2.setUserInputEnabled(false)
method. Here is the link https://developer.android.com/jetpack/androidx/releases/viewpager2#1.0.0-alpha02
😲 1
u
Id model it in viewmodel ... emit State(currentPage, isEnabled) to the view