diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2014-08-12 17:43:29 +0200 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2014-08-12 17:45:26 +0200 |
commit | 60b4fb63eaf44509629d0230f65a9558a6c095d3 (patch) | |
tree | 88d3525de726ab7fcd548365cae530532766c821 /main/src/cgeo/geocaching/CgeoApplication.java | |
parent | 6e7ed201b6f8502f48b830aac6f6a7b8ca07e2f7 (diff) | |
download | cgeo-60b4fb63eaf44509629d0230f65a9558a6c095d3.zip cgeo-60b4fb63eaf44509629d0230f65a9558a6c095d3.tar.gz cgeo-60b4fb63eaf44509629d0230f65a9558a6c095d3.tar.bz2 |
Never block when building a cache/waypoint details creator
Blocking on the UI thread may prevent other looper threads from
executing, including the ones in charge of receiving the location
updates. This may lead to deadlocks when, for example, starting cgeo
from a cache URL if cgeo has not been started before.
Diffstat (limited to 'main/src/cgeo/geocaching/CgeoApplication.java')
-rw-r--r-- | main/src/cgeo/geocaching/CgeoApplication.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/CgeoApplication.java b/main/src/cgeo/geocaching/CgeoApplication.java index 863dcdd..6eb1235 100644 --- a/main/src/cgeo/geocaching/CgeoApplication.java +++ b/main/src/cgeo/geocaching/CgeoApplication.java @@ -108,6 +108,13 @@ public class CgeoApplication extends Application { return currentGeo != null ? currentGeo : geoDataObservable().toBlocking().first(); } + public Float distanceNonBlocking(final ICoordinates target) { + if (currentGeo == null || target.getCoords() == null) { + return null; + } + return currentGeo.getCoords().distanceTo(target); + } + public float currentDirection() { return currentDirection; } |