I'm using MVVM clean architecture and need to get current position using fused location provider, so before getting the current position i need to check if user has given permission to access the location and the internet.
I'm retrieving the location from repository by implementing a data source, but i'm not sure where should i ask for permission. In repository when i request the location or in activity, first ask for permission and then request the position?
In first case the flow would be:
1)User clicks the button(view)
2)Viewmodel requests for location (viewmodel->usecase->repository)
3)Repository checks permissions and requests location
4)Observable is returned which emits location(s) or error if no permission were granted (or other error)
In second case:
1)User clicks the button and permission are checked/requested inside activity
2)If permission are granted, viewmodel requests position otherwise view shows an error
3)Repository requests and returns the location
The first method looks more straightforward and logical to me. The presentation layer simply requests the position and then the repository returns the location or error, however maybe it's too much logic inside data layer ?