Service refactoring: move location management to the LocationHandle.

Tests refactoring: location and service tests re-worked.
This commit is contained in:
Román Martínez
2020-07-17 12:29:30 +02:00
committed by GitHub
parent afea79476f
commit 17de8cea6f
13 changed files with 412 additions and 252 deletions
@@ -0,0 +1,47 @@
package de.dennisguse.opentracks.services.handlers;
import android.content.Context;
import android.content.SharedPreferences;
import de.dennisguse.opentracks.content.data.TrackPoint;
public class HandlerServer {
private String TAG = HandlerServer.class.getSimpleName();
private LocationHandler locationHandler;
private HandlerServerInterface service;
public HandlerServer(HandlerServerInterface service) {
this.locationHandler = new LocationHandler(this);
this.service = service;
}
public void start(Context context) {
locationHandler.onStart(context);
locationHandler.onSharedPreferenceChanged(context, null, null);
}
public void stop(Context context) {
locationHandler.onStop(context);
}
public void onSharedPreferenceChanged(Context context, SharedPreferences preferences, String key) {
locationHandler.onSharedPreferenceChanged(context, preferences, key);
}
public void sendTrackPoint(TrackPoint trackPoint, int recordingGpsAccuracy) {
service.newTrackPoint(trackPoint, recordingGpsAccuracy);
}
public interface HandlerServerInterface {
void newTrackPoint(TrackPoint trackPoint, int gpsAccuracy);
}
public interface Handler {
void onStart(Context context);
void onStop(Context context);
void onSharedPreferenceChanged(Context context, SharedPreferences preferences, String key);
}
}