Issue
I'm creating an Android app according to MVVM pattern and I'm not sure if I should start intent from adapter. In adapter I'm creating Intent that has to open given uri in browser after user taps one. Technically it all works but I'm still not sure if it is a good practice to start intent like that, instead of starting it from activity.
Solution
This is not a good practice. Your view (meaning your Fragment
or Activity
) should be handling the navigation. Instead, the accepted way is to pass a clickListener
from your view into your adapter when you instantiate the adapter. This is covered in various articles, so pick the one you like best.
Or you can take a look at my implementation here and here.
It's also covered in this excellent free Udacity course.
Answered By - Gavin Wright
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.