I am developing my first android app and since my code is quickly becoming a huge mess I decided to follow the MVP pattern.
My app is divided in Views (Fragments), Presenters, and Contracts (interfaces with the methods a view and it's presenter will use to comunicate).
My problem is that I have a form which has a field with the user's location, which I retrieve using the Google location APIs. I have a LocationHelper class which is responsible for checking/asking permissions, building the google API client, getting the location etc.
However, I do not know where to put the code which uses this class: my first approach was instantiating it in the presenter, since it is more business logic than UI stuff, however many methods need the caller activity as a parameter. For example to build the Google API client:
mGoogleApiClient = new GoogleApiClient.Builder(context)
.addConnectionCallbacks((GoogleApiClient.ConnectionCallbacks) current_activity)
.addOnConnectionFailedListener((GoogleApiClient.OnConnectionFailedListener) current_activity)
.addApi(LocationServices.API).build();
Or the location settings request:
status.startResolutionForResult(current_activity,REQUEST_CHECK_SETTINGS);
However, from what I've understood in MVP the presenter should have no context/android code. What would be the best practice in this case?