[android] - update lost to 2.0.0, gradle cleanup (#7494)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
ext {
|
||||
supportLibVersion = '25.0.0'
|
||||
supportLibVersion = '25.1.0'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -9,7 +9,7 @@ dependencies {
|
||||
compile "com.android.support:support-v4:${supportLibVersion}"
|
||||
compile "com.android.support:design:${supportLibVersion}"
|
||||
compile 'com.squareup.okhttp3:okhttp:3.5.0'
|
||||
compile 'com.mapzen.android:lost:1.1.1'
|
||||
compile 'com.mapzen.android:lost:2.0.0'
|
||||
compile 'com.jakewharton.timber:timber:4.3.1'
|
||||
|
||||
// Mapbox Android Services
|
||||
|
||||
@@ -17,6 +17,8 @@ import com.mapzen.android.lost.api.LostApiClient;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import static com.mapzen.android.lost.api.LocationServices.FusedLocationApi;
|
||||
|
||||
/**
|
||||
* Manages locational updates. Contains methods to register and unregister location listeners.
|
||||
* <ul>
|
||||
@@ -31,7 +33,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
* in the history stack.
|
||||
* </p>
|
||||
*/
|
||||
public class LocationServices implements com.mapzen.android.lost.api.LocationListener {
|
||||
public class LocationServices implements LostApiClient.ConnectionCallbacks,
|
||||
com.mapzen.android.lost.api.LocationListener {
|
||||
|
||||
private static LocationServices instance;
|
||||
|
||||
@@ -50,7 +53,7 @@ public class LocationServices implements com.mapzen.android.lost.api.LocationLis
|
||||
super();
|
||||
this.context = context;
|
||||
// Setup location services
|
||||
locationClient = new LostApiClient.Builder(context).build();
|
||||
locationClient = new LostApiClient.Builder(context).addConnectionCallbacks(this).build();
|
||||
locationListeners = new CopyOnWriteArrayList<>();
|
||||
}
|
||||
|
||||
@@ -81,38 +84,46 @@ public class LocationServices implements com.mapzen.android.lost.api.LocationLis
|
||||
// Disconnect
|
||||
if (locationClient.isConnected()) {
|
||||
// Disconnect first to ensure that the new requests are GPS
|
||||
com.mapzen.android.lost.api.LocationServices.FusedLocationApi.removeLocationUpdates(this);
|
||||
FusedLocationApi.removeLocationUpdates(locationClient, this);
|
||||
locationClient.disconnect();
|
||||
}
|
||||
isGpsEnabled = enableGPS;
|
||||
|
||||
// Setup Fresh
|
||||
locationClient.connect();
|
||||
Location lastLocation = com.mapzen.android.lost.api.LocationServices.FusedLocationApi.getLastLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected() {
|
||||
//noinspection MissingPermission
|
||||
Location lastLocation = FusedLocationApi.getLastLocation(locationClient);
|
||||
if (lastLocation != null) {
|
||||
this.lastLocation = lastLocation;
|
||||
}
|
||||
|
||||
LocationRequest locationRequest;
|
||||
|
||||
if (enableGPS) {
|
||||
if (isGpsEnabled) {
|
||||
// LocationRequest Tuned for GPS
|
||||
locationRequest = LocationRequest.create()
|
||||
.setFastestInterval(1000)
|
||||
.setSmallestDisplacement(3.0f)
|
||||
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
||||
|
||||
com.mapzen.android.lost.api.LocationServices.FusedLocationApi.requestLocationUpdates(locationRequest, this);
|
||||
//noinspection MissingPermission
|
||||
FusedLocationApi.requestLocationUpdates(locationClient, locationRequest, this);
|
||||
} else {
|
||||
// LocationRequest Tuned for PASSIVE
|
||||
locationRequest = LocationRequest.create()
|
||||
.setFastestInterval(1000)
|
||||
.setSmallestDisplacement(3.0f)
|
||||
.setPriority(LocationRequest.PRIORITY_NO_POWER);
|
||||
|
||||
com.mapzen.android.lost.api.LocationServices.FusedLocationApi.requestLocationUpdates(locationRequest, this);
|
||||
//noinspection MissingPermission
|
||||
FusedLocationApi.requestLocationUpdates(locationClient, locationRequest, this);
|
||||
}
|
||||
}
|
||||
|
||||
isGpsEnabled = enableGPS;
|
||||
@Override
|
||||
public void onConnectionSuspended() {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,4 +201,12 @@ public class LocationServices implements com.mapzen.android.lost.api.LocationLis
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
ext {
|
||||
supportLibVersion = '25.0.1'
|
||||
supportLibVersion = '25.1.0'
|
||||
espressoVersion = '2.2.2'
|
||||
testRunnerVersion = '0.5'
|
||||
leakCanaryVersion = '1.5'
|
||||
}
|
||||
|
||||
android {
|
||||
@@ -14,7 +17,6 @@ android {
|
||||
targetSdkVersion 25
|
||||
versionCode 11
|
||||
versionName "5.0.0"
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -66,24 +68,19 @@ dependencies {
|
||||
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
|
||||
|
||||
// Leak Canary
|
||||
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
|
||||
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
|
||||
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
|
||||
|
||||
// Mapbox Android Services
|
||||
compile('com.mapbox.mapboxsdk:mapbox-android-services:1.3.0@aar') {
|
||||
transitive = true
|
||||
}
|
||||
debugCompile "com.squareup.leakcanary:leakcanary-android:${leakCanaryVersion}"
|
||||
releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:${leakCanaryVersion}"
|
||||
testCompile "com.squareup.leakcanary:leakcanary-android-no-op:${leakCanaryVersion}"
|
||||
|
||||
// Testing dependencies
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'org.mockito:mockito-core:2.2.27'
|
||||
androidTestCompile "com.android.support:support-annotations:${supportLibVersion}"
|
||||
androidTestCompile 'com.android.support.test:runner:0.5'
|
||||
androidTestCompile 'com.android.support.test:rules:0.5'
|
||||
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
|
||||
androidTestCompile 'com.squareup.spoon:spoon-client:1.6.2'
|
||||
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'
|
||||
androidTestCompile "com.android.support:support-annotations:${supportLibVersion}"
|
||||
androidTestCompile "com.android.support.test:runner:${testRunnerVersion}"
|
||||
androidTestCompile "com.android.support.test:rules:${testRunnerVersion}"
|
||||
androidTestCompile "com.android.support.test.espresso:espresso-core:${espressoVersion}"
|
||||
androidTestCompile "com.android.support.test.espresso:espresso-intents:${espressoVersion}"
|
||||
}
|
||||
|
||||
apply from: 'gradle-make.gradle'
|
||||
|
||||
Reference in New Issue
Block a user