Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] - update lost to 2.0.0, gradle cleanup (#7494)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun authored Dec 21, 2016
1 parent a6b1773 commit 2b38af8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 27 deletions.
4 changes: 2 additions & 2 deletions platform/android/MapboxGLAndroidSDK/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.library'

ext {
supportLibVersion = '25.0.0'
supportLibVersion = '25.1.0'
}

dependencies {
compile "com.android.support:support-annotations:${supportLibVersion}"
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

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>
Expand All @@ -31,7 +33,8 @@
* 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;

Expand All @@ -50,7 +53,7 @@ private LocationServices(Context context) {
super();
this.context = context;
// Setup location services
locationClient = new LostApiClient.Builder(context).build();
locationClient = new LostApiClient.Builder(context).addConnectionCallbacks(this).build();
locationListeners = new CopyOnWriteArrayList<>();
}

Expand Down Expand Up @@ -81,38 +84,46 @@ public void toggleGPS(boolean enableGPS) {
// 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() {
}

/**
Expand Down Expand Up @@ -190,4 +201,12 @@ public boolean areLocationPermissionsGranted() {
}
return true;
}

@Override
public void onProviderDisabled(String provider) {
}

@Override
public void onProviderEnabled(String provider) {
}
}
27 changes: 12 additions & 15 deletions platform/android/MapboxGLAndroidSDKTestApp/build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -14,7 +17,6 @@ android {
targetSdkVersion 25
versionCode 11
versionName "5.0.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 2b38af8

Please sign in to comment.