https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
j

jermainedilao

08/09/2019, 9:59 AM
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

Aslam Hossin

08/09/2019, 1:31 PM
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

ursus

08/11/2019, 2:27 PM
Id model it in viewmodel ... emit State(currentPage, isEnabled) to the view
6 Views