Skip to content

Commit 7302f9d

Browse files
bump lost version to 3.0.4 (#636)
1 parent 4e882a7 commit 7302f9d

6 files changed

Lines changed: 79 additions & 35 deletions

File tree

mapbox/app/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ dependencies {
6060
compile rootProject.ext.dep.gmsLocation
6161

6262
// LOST
63-
compile(rootProject.ext.dep.lost) {
64-
exclude group: 'com.google.guava'
65-
}
63+
compile rootProject.ext.dep.lost
6664

6765
// Picasso (Static Image)
6866
compile rootProject.ext.dep.picasso

mapbox/dependencies.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ext {
1818
supportCardView : "com.android.support:cardview-v7:${supportLibVersion}",
1919

2020
// mapbox
21-
mapbox : 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.2.0-SNAPSHOT@aar',
21+
mapbox : 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.2.0-20171110.170407-225@aar',
2222

2323
// gson
2424
gson : 'com.google.code.gson:gson:2.8.0',
@@ -37,7 +37,7 @@ ext {
3737
okhttp3Mockwebserver : 'com.squareup.okhttp3:mockwebserver:3.6.0',
3838

3939
// lost
40-
lost : 'com.mapzen.android:lost:1.1.1',
40+
lost : 'com.mapzen.android:lost:3.0.4',
4141

4242
// play services
4343
gmsLocation : 'com.google.android.gms:play-services-location:10.2.0',

mapbox/libandroid-services/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ dependencies {
4343
compile rootProject.ext.dep.timber
4444

4545
// LOST
46-
compile(rootProject.ext.dep.lost) {
47-
exclude group: 'com.google.guava'
48-
}
46+
compile rootProject.ext.dep.lost
4947

5048
// Testing
5149
testCompile rootProject.ext.dep.mockito

mapbox/libandroid-services/src/main/java/com/mapbox/services/android/location/LostLocationEngine.java

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* Sample LocationEngine using the Open Source Lost library
1919
*/
20-
public class LostLocationEngine extends LocationEngine implements LocationListener {
20+
public class LostLocationEngine extends LocationEngine implements LostApiClient.ConnectionCallbacks, LocationListener {
2121

2222
private static LocationEngine instance;
2323

@@ -27,7 +27,9 @@ public class LostLocationEngine extends LocationEngine implements LocationListen
2727
public LostLocationEngine(Context context) {
2828
super();
2929
this.context = new WeakReference<>(context);
30-
lostApiClient = new LostApiClient.Builder(this.context.get()).build();
30+
lostApiClient = new LostApiClient.Builder(this.context.get())
31+
.addConnectionCallbacks(this)
32+
.build();
3133
}
3234

3335
public static synchronized LocationEngine getLocationEngine(Context context) {
@@ -44,12 +46,7 @@ public static synchronized LocationEngine getLocationEngine(Context context) {
4446
*/
4547
@Override
4648
public void activate() {
47-
if (!lostApiClient.isConnected()) {
48-
lostApiClient.connect();
49-
}
50-
for (LocationEngineListener listener : locationListeners) {
51-
listener.onConnected();
52-
}
49+
connect();
5350
}
5451

5552
/**
@@ -59,7 +56,7 @@ public void activate() {
5956
*/
6057
@Override
6158
public void deactivate() {
62-
if (lostApiClient.isConnected()) {
59+
if (lostApiClient != null && lostApiClient.isConnected()) {
6360
lostApiClient.disconnect();
6461
}
6562
}
@@ -75,6 +72,24 @@ public boolean isConnected() {
7572
return lostApiClient.isConnected();
7673
}
7774

75+
/**
76+
* Invoked when the location provider has connected.
77+
*/
78+
@Override
79+
public void onConnected() {
80+
for (LocationEngineListener listener : locationListeners) {
81+
listener.onConnected();
82+
}
83+
}
84+
85+
/**
86+
* Invoked when the location provider connection has been suspended.
87+
*/
88+
@Override
89+
public void onConnectionSuspended() {
90+
// Empty
91+
}
92+
7893
/**
7994
* Returns the Last known location if the location provider is connected and location permissions are granted.
8095
*
@@ -85,7 +100,7 @@ public boolean isConnected() {
85100
public Location getLastLocation() {
86101
if (lostApiClient.isConnected()) {
87102
//noinspection MissingPermission
88-
return LocationServices.FusedLocationApi.getLastLocation();
103+
return LocationServices.FusedLocationApi.getLastLocation(lostApiClient);
89104
}
90105
return null;
91106
}
@@ -120,7 +135,7 @@ public void requestLocationUpdates() {
120135

121136
if (lostApiClient.isConnected()) {
122137
//noinspection MissingPermission
123-
LocationServices.FusedLocationApi.requestLocationUpdates(request, this);
138+
LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this);
124139
}
125140
}
126141

@@ -135,7 +150,7 @@ public Type obtainType() {
135150
@Override
136151
public void removeLocationUpdates() {
137152
if (lostApiClient.isConnected()) {
138-
LocationServices.FusedLocationApi.removeLocationUpdates(this);
153+
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
139154
}
140155
}
141156

@@ -150,4 +165,14 @@ public void onLocationChanged(Location location) {
150165
listener.onLocationChanged(location);
151166
}
152167
}
168+
169+
private void connect() {
170+
if (lostApiClient != null) {
171+
if (lostApiClient.isConnected()) {
172+
onConnected();
173+
} else {
174+
lostApiClient.connect();
175+
}
176+
}
177+
}
153178
}

mapbox/libandroid-telemetry/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ dependencies {
3636
provided rootProject.ext.dep.gmsLocation
3737

3838
// LOST
39-
provided(rootProject.ext.dep.lost) {
40-
exclude group: 'com.google.guava'
41-
}
39+
provided rootProject.ext.dep.lost
4240

4341
// Testing
4442
testCompile rootProject.ext.dep.junit

mapbox/libandroid-telemetry/src/main/java/com/mapbox/services/android/telemetry/location/LostLocationEngine.java

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* Sample LocationEngine using the Open Source Lost library
1616
*/
17-
public class LostLocationEngine extends LocationEngine implements LocationListener {
17+
public class LostLocationEngine extends LocationEngine implements LostApiClient.ConnectionCallbacks, LocationListener {
1818

1919
private static LocationEngine instance;
2020

@@ -24,7 +24,9 @@ public class LostLocationEngine extends LocationEngine implements LocationListen
2424
public LostLocationEngine(Context context) {
2525
super();
2626
this.context = new WeakReference<>(context);
27-
lostApiClient = new LostApiClient.Builder(this.context.get()).build();
27+
lostApiClient = new LostApiClient.Builder(this.context.get())
28+
.addConnectionCallbacks(this)
29+
.build();
2830
}
2931

3032
public static synchronized LocationEngine getLocationEngine(Context context) {
@@ -41,12 +43,7 @@ public static synchronized LocationEngine getLocationEngine(Context context) {
4143
*/
4244
@Override
4345
public void activate() {
44-
if (!lostApiClient.isConnected()) {
45-
lostApiClient.connect();
46-
}
47-
for (LocationEngineListener listener : locationListeners) {
48-
listener.onConnected();
49-
}
46+
connect();
5047
}
5148

5249
/**
@@ -56,7 +53,7 @@ public void activate() {
5653
*/
5754
@Override
5855
public void deactivate() {
59-
if (lostApiClient.isConnected()) {
56+
if (lostApiClient != null && lostApiClient.isConnected()) {
6057
lostApiClient.disconnect();
6158
}
6259
}
@@ -72,6 +69,24 @@ public boolean isConnected() {
7269
return lostApiClient.isConnected();
7370
}
7471

72+
/**
73+
* Invoked when the location provider has connected.
74+
*/
75+
@Override
76+
public void onConnected() {
77+
for (LocationEngineListener listener : locationListeners) {
78+
listener.onConnected();
79+
}
80+
}
81+
82+
/**
83+
* Invoked when the location provider connection has been suspended.
84+
*/
85+
@Override
86+
public void onConnectionSuspended() {
87+
// Empty
88+
}
89+
7590
/**
7691
* Returns the Last known location if the location provider is connected and location permissions are granted.
7792
*
@@ -82,7 +97,7 @@ public boolean isConnected() {
8297
public Location getLastLocation() {
8398
if (lostApiClient.isConnected()) {
8499
//noinspection MissingPermission
85-
return LocationServices.FusedLocationApi.getLastLocation();
100+
return LocationServices.FusedLocationApi.getLastLocation(lostApiClient);
86101
}
87102
return null;
88103
}
@@ -117,7 +132,7 @@ public void requestLocationUpdates() {
117132

118133
if (lostApiClient.isConnected()) {
119134
//noinspection MissingPermission
120-
LocationServices.FusedLocationApi.requestLocationUpdates(request, this);
135+
LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this);
121136
}
122137
}
123138

@@ -132,7 +147,7 @@ public Type obtainType() {
132147
@Override
133148
public void removeLocationUpdates() {
134149
if (lostApiClient.isConnected()) {
135-
LocationServices.FusedLocationApi.removeLocationUpdates(this);
150+
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
136151
}
137152
}
138153

@@ -147,4 +162,14 @@ public void onLocationChanged(Location location) {
147162
listener.onLocationChanged(location);
148163
}
149164
}
165+
166+
private void connect() {
167+
if (lostApiClient != null) {
168+
if (lostApiClient.isConnected()) {
169+
onConnected();
170+
} else {
171+
lostApiClient.connect();
172+
}
173+
}
174+
}
150175
}

0 commit comments

Comments
 (0)