Remove unnecessary code

This commit is contained in:
Mieszko Wrzeszczyński 2019-01-01 20:03:30 +01:00
parent 7f169e5b61
commit 18547a3c52

View File

@ -25,7 +25,6 @@ import android.util.Log;
import com.annimon.stream.Stream; import com.annimon.stream.Stream;
import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices; import com.google.android.gms.location.LocationServices;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.mapbox.geojson.Point; import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLng;
import com.uam.wmi.findmytutor.model.Coordinate; import com.uam.wmi.findmytutor.model.Coordinate;
@ -33,21 +32,17 @@ import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization; import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
import com.uam.wmi.findmytutor.utils.MapUtils; import com.uam.wmi.findmytutor.utils.MapUtils;
import com.uam.wmi.findmytutor.utils.PrefUtils; import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
import com.uam.wmi.findmytutor.utils.SharingLevel; import com.uam.wmi.findmytutor.utils.SharingLevel;
import org.apache.commons.collections4.queue.CircularFifoQueue; import org.apache.commons.collections4.queue.CircularFifoQueue;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableCompletableObserver; import io.reactivex.observers.DisposableCompletableObserver;
import io.reactivex.observers.DisposableSingleObserver;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import static com.uam.wmi.findmytutor.utils.Const.offlineBackgroundLocationInterval; import static com.uam.wmi.findmytutor.utils.Const.offlineBackgroundLocationInterval;
import static com.uam.wmi.findmytutor.utils.Const.onlineBackgroundLocationInterval; import static com.uam.wmi.findmytutor.utils.Const.onlineBackgroundLocationInterval;
@ -60,18 +55,14 @@ import static java.lang.String.valueOf;
public class BackgroundLocalizationService extends Service { public class BackgroundLocalizationService extends Service {
private static final String TAG = "MyLocationService"; private static final String TAG = "MyLocationService";
private static final float LOCATION_DISTANCE = 1f;
private static long notify_interval = onlineBackgroundLocationInterval; private static long notify_interval = onlineBackgroundLocationInterval;
private static long notify_interval_inside_building = onlineBackgroundLocationInterval; private static long notify_interval_inside_building = onlineBackgroundLocationInterval;
private static long notify_interval_outside_building = offlineBackgroundLocationInterval; private static long notify_interval_outside_building = offlineBackgroundLocationInterval;
private static int coordinatesHistoryLength = 5; private static int coordinatesHistoryLength = 5;
private static final Long LOCATION_INTERVAL = notify_interval;
private Location mLastLocation; private Location mLastLocation;
private Boolean stopService = false; private Boolean stopService = false;
private ArrayList<String> providers = new ArrayList<String>(); private ArrayList<String> providers = new ArrayList<String>();
private LocationListener[] mLocationListeners;
private CircularFifoQueue<Location> coordinatesHistory = new CircularFifoQueue<Location>(coordinatesHistoryLength); private CircularFifoQueue<Location> coordinatesHistory = new CircularFifoQueue<Location>(coordinatesHistoryLength);
private LocationManager mLocationManager = null;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private Runnable mStatusChecker; private Runnable mStatusChecker;
private FusedLocationProviderClient mFusedLocationClient; private FusedLocationProviderClient mFusedLocationClient;
@ -80,12 +71,6 @@ public class BackgroundLocalizationService extends Service {
providers.add(LocationManager.GPS_PROVIDER); providers.add(LocationManager.GPS_PROVIDER);
providers.add(LocationManager.NETWORK_PROVIDER); providers.add(LocationManager.NETWORK_PROVIDER);
providers.add(LocationManager.PASSIVE_PROVIDER); providers.add(LocationManager.PASSIVE_PROVIDER);
mLocationListeners = new LocationListener[]{
new LocationListener(LocationManager.GPS_PROVIDER),
new LocationListener(LocationManager.NETWORK_PROVIDER),
new LocationListener(LocationManager.PASSIVE_PROVIDER)
};
} }
@Override @Override
@ -130,6 +115,7 @@ public class BackgroundLocalizationService extends Service {
try { try {
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this); mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
getLocalizationFromListeners(); getLocalizationFromListeners();
changeBackgroundMode();
} finally { } finally {
mFusedLocationClient = null; mFusedLocationClient = null;
destroyLocationListeners(); destroyLocationListeners();