Skip to content

Commit 11e9aed

Browse files
author
Cameron Mace
authored
Reverted lost to 1.1 (#596)
* reverted lost to 1.1 * restored circle script to build from master * removed deprecated tag
1 parent 5a61882 commit 11e9aed

4 files changed

Lines changed: 25 additions & 50 deletions

File tree

mapbox/app/build.gradle

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

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

6567
// Picasso (Static Image)
6668
compile rootProject.ext.dep.picasso

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ public void removeLocationUpdates() {
144144
*
145145
* @param location the new location
146146
*/
147-
@Deprecated
148147
@Override
149148
public void onLocationChanged(Location location) {
150149
for (LocationEngineListener listener : locationListeners) {

mapbox/libandroid-telemetry/build.gradle

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

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

4143
// Testing
4244
testCompile rootProject.ext.dep.junit

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

Lines changed: 19 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import android.content.Context;
44
import android.location.Location;
55
import android.support.annotation.Nullable;
6-
import android.util.Log;
76

87
import com.mapzen.android.lost.api.LocationListener;
98
import com.mapzen.android.lost.api.LocationRequest;
@@ -15,10 +14,7 @@
1514
/**
1615
* Sample LocationEngine using the Open Source Lost library
1716
*/
18-
public class LostLocationEngine extends LocationEngine implements
19-
LostApiClient.ConnectionCallbacks, LocationListener {
20-
21-
private static final String LOG_TAG = LostLocationEngine.class.getSimpleName();
17+
public class LostLocationEngine extends LocationEngine implements LocationListener {
2218

2319
private static LocationEngine instance;
2420

@@ -28,9 +24,7 @@ public class LostLocationEngine extends LocationEngine implements
2824
public LostLocationEngine(Context context) {
2925
super();
3026
this.context = new WeakReference<>(context);
31-
lostApiClient = new LostApiClient.Builder(this.context.get())
32-
.addConnectionCallbacks(this)
33-
.build();
27+
lostApiClient = new LostApiClient.Builder(this.context.get()).build();
3428
}
3529

3630
public static synchronized LocationEngine getLocationEngine(Context context) {
@@ -47,7 +41,12 @@ public static synchronized LocationEngine getLocationEngine(Context context) {
4741
*/
4842
@Override
4943
public void activate() {
50-
connect();
44+
if (!lostApiClient.isConnected()) {
45+
lostApiClient.connect();
46+
}
47+
for (LocationEngineListener listener : locationListeners) {
48+
listener.onConnected();
49+
}
5150
}
5251

5352
/**
@@ -57,7 +56,7 @@ public void activate() {
5756
*/
5857
@Override
5958
public void deactivate() {
60-
if (lostApiClient != null && lostApiClient.isConnected()) {
59+
if (lostApiClient.isConnected()) {
6160
lostApiClient.disconnect();
6261
}
6362
}
@@ -74,25 +73,7 @@ public boolean isConnected() {
7473
}
7574

7675
/**
77-
* Invoked when the location provider has connected.
78-
*/
79-
@Override
80-
public void onConnected() {
81-
for (LocationEngineListener listener : locationListeners) {
82-
listener.onConnected();
83-
}
84-
}
85-
86-
/**
87-
* Invoked when the location provider connection has been suspended.
88-
*/
89-
@Override
90-
public void onConnectionSuspended() {
91-
Log.d(LOG_TAG, "Connection suspended");
92-
}
93-
94-
/**
95-
* Returns the Last known location if the location provider is connected.
76+
* Returns the Last known location if the location provider is connected and location permissions are granted.
9677
*
9778
* @return the last known location
9879
*/
@@ -101,7 +82,7 @@ public void onConnectionSuspended() {
10182
public Location getLastLocation() {
10283
if (lostApiClient.isConnected()) {
10384
//noinspection MissingPermission
104-
return LocationServices.FusedLocationApi.getLastLocation(lostApiClient);
85+
return LocationServices.FusedLocationApi.getLastLocation();
10586
}
10687
return null;
10788
}
@@ -123,6 +104,7 @@ public void requestLocationUpdates() {
123104
request.setSmallestDisplacement(smallestDisplacement);
124105
}
125106

107+
// Priority matching is straightforward
126108
if (priority == LocationEnginePriority.NO_POWER) {
127109
request.setPriority(LocationRequest.PRIORITY_NO_POWER);
128110
} else if (priority == LocationEnginePriority.LOW_POWER) {
@@ -135,25 +117,25 @@ public void requestLocationUpdates() {
135117

136118
if (lostApiClient.isConnected()) {
137119
//noinspection MissingPermission
138-
LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this);
120+
LocationServices.FusedLocationApi.requestLocationUpdates(request, this);
139121
}
140122
}
141123

124+
@Override
125+
public Type obtainType() {
126+
return Type.LOST;
127+
}
128+
142129
/**
143130
* Dismiss ongoing location update to the location provider.
144131
*/
145132
@Override
146133
public void removeLocationUpdates() {
147134
if (lostApiClient.isConnected()) {
148-
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
135+
LocationServices.FusedLocationApi.removeLocationUpdates(this);
149136
}
150137
}
151138

152-
@Override
153-
public Type obtainType() {
154-
return Type.LOST;
155-
}
156-
157139
/**
158140
* Invoked when the Location has changed.
159141
*
@@ -165,14 +147,4 @@ public void onLocationChanged(Location location) {
165147
listener.onLocationChanged(location);
166148
}
167149
}
168-
169-
private void connect() {
170-
if (lostApiClient != null) {
171-
if (lostApiClient.isConnected()) {
172-
onConnected();
173-
} else {
174-
lostApiClient.connect();
175-
}
176-
}
177-
}
178150
}

0 commit comments

Comments
 (0)