aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/CgeoApplication.java
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2014-08-12 17:43:29 +0200
committerSamuel Tardieu <sam@rfc1149.net>2014-08-12 17:45:26 +0200
commit60b4fb63eaf44509629d0230f65a9558a6c095d3 (patch)
tree88d3525de726ab7fcd548365cae530532766c821 /main/src/cgeo/geocaching/CgeoApplication.java
parent6e7ed201b6f8502f48b830aac6f6a7b8ca07e2f7 (diff)
downloadcgeo-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.java7
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;
}