Skip to content

Commit

Permalink
Revert back to old LOST 2.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Jul 6, 2017
1 parent 3956411 commit 252e7aa
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ dependencies {

// map and location
compile 'com.mapzen.tangram:tangram:0.7.1'
compile 'com.mapzen.android:lost:3.0.2'
compile 'com.mapzen.android:lost:2.1.2'

// config files
compile 'com.esotericsoftware.yamlbeans:yamlbeans:1.09'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,15 @@ public void startPositionTracking()

public void stopPositionTracking()
{
if(lostApiClient.isConnected())
try // TODO remove when https://github.com/mapzen/lost/issues/178 is solved
{
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
lostApiClient.disconnect();
if(lostApiClient.isConnected())
{
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
lostApiClient.disconnect();
}
} catch(Exception e) {
e.printStackTrace();
}
}

Expand All @@ -106,10 +111,19 @@ public void onConnectionSuspended() {}

@Override public void onLocationChanged(Location location)
{
this.pos = new OsmLatLon(location.getLatitude(), location.getLongitude());
LatLon pos = new OsmLatLon(location.getLatitude(), location.getLongitude());
// TODO remove when https://github.com/mapzen/lost/issues/142 is fixed
if(this.pos != null)
{
if(SphericalEarthMath.distance(pos, this.pos) < 400) return;
}
this.pos = pos;
triggerAutoDownload();
}

@Override public void onProviderEnabled(String provider) {}
@Override public void onProviderDisabled(String provider) {}

public void triggerAutoDownload()
{
if(!isAllowedByPreference()) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ public void stopRequest()
{
@Override public void run()
{
if(lostApiClient.isConnected())
try // TODO remove when https://github.com/mapzen/lost/issues/178 is solved
{
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, SingleLocationRequest.this);
lostApiClient.disconnect();
if(lostApiClient.isConnected())
{
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, SingleLocationRequest.this);
lostApiClient.disconnect();
}
} catch(Exception e) {
e.printStackTrace();
}
}
});

}

@Override public void onConnected() throws SecurityException
Expand All @@ -66,5 +70,7 @@ public void stopRequest()
stopRequest();
}

@Override public void onProviderDisabled(String provider) {}
@Override public void onProviderEnabled(String provider) {}
@Override public void onConnectionSuspended() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,15 @@ public void stopPositionTracking()
lastLocation = null;
zoomedYet = false;

if(lostApiClient.isConnected())
try // TODO remove when https://github.com/mapzen/lost/issues/178 is solved
{
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
lostApiClient.disconnect();
if(lostApiClient.isConnected())
{
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
lostApiClient.disconnect();
}
} catch (Exception e) {
e.printStackTrace();
}
}

Expand Down Expand Up @@ -359,6 +364,16 @@ private float meters2Pixels(LngLat at, float meters) {
return Math.abs(screenPos1.y - screenPos0.y);
}

@Override public void onProviderEnabled(String provider)
{

}

@Override public void onProviderDisabled(String provider)
{

}

private static final String PREF_ROTATION = "map_rotation";
private static final String PREF_TILT = "map_tilt";
private static final String PREF_ZOOM = "map_zoom";
Expand Down

0 comments on commit 252e7aa

Please sign in to comment.