Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Lost version to 3.0.4 #636

Merged
merged 1 commit into from
Nov 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions mapbox/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ dependencies {
compile rootProject.ext.dep.gmsLocation

// LOST
compile(rootProject.ext.dep.lost) {
exclude group: 'com.google.guava'
}
compile rootProject.ext.dep.lost

// Picasso (Static Image)
compile rootProject.ext.dep.picasso
Expand Down
4 changes: 2 additions & 2 deletions mapbox/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ext {
supportCardView : "com.android.support:cardview-v7:${supportLibVersion}",

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

// gson
gson : 'com.google.code.gson:gson:2.8.0',
Expand All @@ -37,7 +37,7 @@ ext {
okhttp3Mockwebserver : 'com.squareup.okhttp3:mockwebserver:3.6.0',

// lost
lost : 'com.mapzen.android:lost:1.1.1',
lost : 'com.mapzen.android:lost:3.0.4',

// play services
gmsLocation : 'com.google.android.gms:play-services-location:10.2.0',
Expand Down
4 changes: 1 addition & 3 deletions mapbox/libandroid-services/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ dependencies {
compile rootProject.ext.dep.timber

// LOST
compile(rootProject.ext.dep.lost) {
exclude group: 'com.google.guava'
}
compile rootProject.ext.dep.lost

// Testing
testCompile rootProject.ext.dep.mockito
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Sample LocationEngine using the Open Source Lost library
*/
public class LostLocationEngine extends LocationEngine implements LocationListener {
public class LostLocationEngine extends LocationEngine implements LostApiClient.ConnectionCallbacks, LocationListener {

private static LocationEngine instance;

Expand All @@ -27,7 +27,9 @@ public class LostLocationEngine extends LocationEngine implements LocationListen
public LostLocationEngine(Context context) {
super();
this.context = new WeakReference<>(context);
lostApiClient = new LostApiClient.Builder(this.context.get()).build();
lostApiClient = new LostApiClient.Builder(this.context.get())
.addConnectionCallbacks(this)
.build();
}

public static synchronized LocationEngine getLocationEngine(Context context) {
Expand All @@ -44,12 +46,7 @@ public static synchronized LocationEngine getLocationEngine(Context context) {
*/
@Override
public void activate() {
if (!lostApiClient.isConnected()) {
lostApiClient.connect();
}
for (LocationEngineListener listener : locationListeners) {
listener.onConnected();
}
connect();
}

/**
Expand All @@ -59,7 +56,7 @@ public void activate() {
*/
@Override
public void deactivate() {
if (lostApiClient.isConnected()) {
if (lostApiClient != null && lostApiClient.isConnected()) {
lostApiClient.disconnect();
}
}
Expand All @@ -75,6 +72,24 @@ public boolean isConnected() {
return lostApiClient.isConnected();
}

/**
* Invoked when the location provider has connected.
*/
@Override
public void onConnected() {
for (LocationEngineListener listener : locationListeners) {
listener.onConnected();
}
}

/**
* Invoked when the location provider connection has been suspended.
*/
@Override
public void onConnectionSuspended() {
// Empty
}

/**
* Returns the Last known location if the location provider is connected and location permissions are granted.
*
Expand All @@ -85,7 +100,7 @@ public boolean isConnected() {
public Location getLastLocation() {
if (lostApiClient.isConnected()) {
//noinspection MissingPermission
return LocationServices.FusedLocationApi.getLastLocation();
return LocationServices.FusedLocationApi.getLastLocation(lostApiClient);
}
return null;
}
Expand Down Expand Up @@ -120,7 +135,7 @@ public void requestLocationUpdates() {

if (lostApiClient.isConnected()) {
//noinspection MissingPermission
LocationServices.FusedLocationApi.requestLocationUpdates(request, this);
LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this);
}
}

Expand All @@ -135,7 +150,7 @@ public Type obtainType() {
@Override
public void removeLocationUpdates() {
if (lostApiClient.isConnected()) {
LocationServices.FusedLocationApi.removeLocationUpdates(this);
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
}
}

Expand All @@ -150,4 +165,14 @@ public void onLocationChanged(Location location) {
listener.onLocationChanged(location);
}
}

private void connect() {
if (lostApiClient != null) {
if (lostApiClient.isConnected()) {
onConnected();
} else {
lostApiClient.connect();
}
}
}
}
4 changes: 1 addition & 3 deletions mapbox/libandroid-telemetry/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ dependencies {
provided rootProject.ext.dep.gmsLocation

// LOST
provided(rootProject.ext.dep.lost) {
exclude group: 'com.google.guava'
}
provided rootProject.ext.dep.lost

// Testing
testCompile rootProject.ext.dep.junit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Sample LocationEngine using the Open Source Lost library
*/
public class LostLocationEngine extends LocationEngine implements LocationListener {
public class LostLocationEngine extends LocationEngine implements LostApiClient.ConnectionCallbacks, LocationListener {

private static LocationEngine instance;

Expand All @@ -24,7 +24,9 @@ public class LostLocationEngine extends LocationEngine implements LocationListen
public LostLocationEngine(Context context) {
super();
this.context = new WeakReference<>(context);
lostApiClient = new LostApiClient.Builder(this.context.get()).build();
lostApiClient = new LostApiClient.Builder(this.context.get())
.addConnectionCallbacks(this)
.build();
}

public static synchronized LocationEngine getLocationEngine(Context context) {
Expand All @@ -41,12 +43,7 @@ public static synchronized LocationEngine getLocationEngine(Context context) {
*/
@Override
public void activate() {
if (!lostApiClient.isConnected()) {
lostApiClient.connect();
}
for (LocationEngineListener listener : locationListeners) {
listener.onConnected();
}
connect();
}

/**
Expand All @@ -56,7 +53,7 @@ public void activate() {
*/
@Override
public void deactivate() {
if (lostApiClient.isConnected()) {
if (lostApiClient != null && lostApiClient.isConnected()) {
lostApiClient.disconnect();
}
}
Expand All @@ -72,6 +69,24 @@ public boolean isConnected() {
return lostApiClient.isConnected();
}

/**
* Invoked when the location provider has connected.
*/
@Override
public void onConnected() {
for (LocationEngineListener listener : locationListeners) {
listener.onConnected();
}
}

/**
* Invoked when the location provider connection has been suspended.
*/
@Override
public void onConnectionSuspended() {
// Empty
}

/**
* Returns the Last known location if the location provider is connected and location permissions are granted.
*
Expand All @@ -82,7 +97,7 @@ public boolean isConnected() {
public Location getLastLocation() {
if (lostApiClient.isConnected()) {
//noinspection MissingPermission
return LocationServices.FusedLocationApi.getLastLocation();
return LocationServices.FusedLocationApi.getLastLocation(lostApiClient);
}
return null;
}
Expand Down Expand Up @@ -117,7 +132,7 @@ public void requestLocationUpdates() {

if (lostApiClient.isConnected()) {
//noinspection MissingPermission
LocationServices.FusedLocationApi.requestLocationUpdates(request, this);
LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this);
}
}

Expand All @@ -132,7 +147,7 @@ public Type obtainType() {
@Override
public void removeLocationUpdates() {
if (lostApiClient.isConnected()) {
LocationServices.FusedLocationApi.removeLocationUpdates(this);
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
}
}

Expand All @@ -147,4 +162,14 @@ public void onLocationChanged(Location location) {
listener.onLocationChanged(location);
}
}

private void connect() {
if (lostApiClient != null) {
if (lostApiClient.isConnected()) {
onConnected();
} else {
lostApiClient.connect();
}
}
}
}