From 4b2098fbe2c24b423dcf619981d7a9f3faeebb67 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sun, 26 Jan 2014 14:59:12 +0100 Subject: refactoring: do not start a thread to display a point Displaying a point can be done on the UI thread directly. --- main/src/cgeo/geocaching/maps/CGeoMap.java | 34 ++++++++---------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index d1ef0a3..bcc99a2 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -995,7 +995,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto public synchronized void startTimer() { if (coordsIntent != null) { // display just one point - (new DisplayPointThread()).start(); + displayPoint(coordsIntent); } else { // start timer stopTimer(); @@ -1272,32 +1272,16 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } } - /** - * Thread to display one point. Started on opening if in single mode. - */ - private class DisplayPointThread extends Thread { - - @Override - public void run() { - if (mapView == null || caches == null) { - return; - } - - if (coordsIntent != null) { - final Waypoint waypoint = new Waypoint("some place", waypointTypeIntent != null ? waypointTypeIntent : WaypointType.WAYPOINT, false); - waypoint.setCoords(coordsIntent); - - final CachesOverlayItemImpl item = getWaypointItem(waypoint); - overlayCaches.updateItems(item); - displayHandler.sendEmptyMessage(INVALIDATE_MAP); + private void displayPoint(final Geopoint coords) { + final Waypoint waypoint = new Waypoint("some place", waypointTypeIntent != null ? waypointTypeIntent : WaypointType.WAYPOINT, false); + waypoint.setCoords(coords); - cachesCnt = 1; - } else { - cachesCnt = 0; - } + final CachesOverlayItemImpl item = getWaypointItem(waypoint); + overlayCaches.updateItems(item); + displayHandler.sendEmptyMessage(INVALIDATE_MAP); + displayHandler.sendEmptyMessage(UPDATE_TITLE); - displayHandler.sendEmptyMessage(UPDATE_TITLE); - } + cachesCnt = 1; } private static abstract class DoRunnable implements Runnable { -- cgit v1.1