aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/maps/CGeoMap.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/maps/CGeoMap.java')
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java72
1 files changed, 20 insertions, 52 deletions
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index c98ba72..1d8e1b4 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -38,12 +38,13 @@ import cgeo.geocaching.utils.CancellableHandler;
import cgeo.geocaching.utils.GeoDirHandler;
import cgeo.geocaching.utils.LeastRecentlyUsedSet;
import cgeo.geocaching.utils.Log;
-import cgeo.geocaching.utils.RunnableWithArgument;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.HashCodeBuilder;
+import rx.functions.Action1;
+
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
@@ -289,8 +290,6 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
waitDialog.dismiss();
waitDialog.setOnCancelListener(null);
}
-
- geoDirUpdate.startDir();
}
}
@@ -299,8 +298,6 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
if (loadDetailsThread != null) {
loadDetailsThread.stopIt();
}
-
- geoDirUpdate.startDir();
}
}
@@ -466,7 +463,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
prepareFilterBar();
- if (!app.isLiveMapHintShown() && !Settings.getHideLiveMapHint()) {
+ if (!app.isLiveMapHintShownInThisSession() && !Settings.getHideLiveMapHint() && Settings.getLiveMapHintShowCount() <= 3) {
LiveMapInfoDialogBuilder.create(activity).show();
}
}
@@ -495,7 +492,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
public void onResume() {
super.onResume();
- addGeoDirObservers();
+ geoDirUpdate.startGeoAndDir();
if (!CollectionUtils.isEmpty(dirtyCaches)) {
for (String geocode : dirtyCaches) {
@@ -515,18 +512,10 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
startTimer();
}
- private void addGeoDirObservers() {
- geoDirUpdate.startGeoAndDir();
- }
-
- private void deleteGeoDirObservers() {
- geoDirUpdate.stopGeoAndDir();
- }
-
@Override
public void onPause() {
stopTimer();
- deleteGeoDirObservers();
+ geoDirUpdate.stopGeoAndDir();
savePrefs();
if (mapView != null) {
@@ -661,9 +650,9 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
if (Settings.getChooseList()) {
// let user select list to store cache in
new StoredList.UserInterface(activity).promptForListSelection(R.string.list_title,
- new RunnableWithArgument<Integer>() {
+ new Action1<Integer>() {
@Override
- public void run(final Integer selectedListId) {
+ public void call(final Integer selectedListId) {
storeCaches(geocodes, selectedListId);
}
}, true, StoredList.TEMPORARY_LIST_ID);
@@ -800,7 +789,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
* @return true if a restart is needed, false otherwise
*/
private boolean changeMapSource(final MapSource mapSource) {
- final boolean restartRequired = !MapProviderFactory.isSameActivity(Settings.getMapSource(), mapSource);
+ final boolean restartRequired = !MapProviderFactory.isSameActivity(MapProviderFactory.getMapSource(currentSourceId), mapSource);
Settings.setMapSource(mapSource);
currentSourceId = mapSource.getNumericalId();
@@ -898,7 +887,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
private long timeLastPositionOverlayCalculation = 0;
@Override
- protected void updateGeoData(final IGeoData geo) {
+ public void updateGeoData(final IGeoData geo) {
if (geo.isPseudoLocation()) {
locationValid = false;
} else {
@@ -994,7 +983,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();
@@ -1182,7 +1171,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
}
}
- final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport.resize(0.8), tokens);
+ final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport.resize(0.8), tokens).toBlockingObservable().single();
downloaded = true;
Set<Geocache> result = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB);
@@ -1271,32 +1260,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 {
+ private void displayPoint(final Geopoint coords) {
+ final Waypoint waypoint = new Waypoint("some place", waypointTypeIntent != null ? waypointTypeIntent : WaypointType.WAYPOINT, false);
+ waypoint.setCoords(coords);
- @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);
+ final CachesOverlayItemImpl item = getWaypointItem(waypoint);
+ overlayCaches.updateItems(item);
+ displayHandler.sendEmptyMessage(INVALIDATE_MAP);
+ displayHandler.sendEmptyMessage(UPDATE_TITLE);
- cachesCnt = 1;
- } else {
- cachesCnt = 0;
- }
-
- displayHandler.sendEmptyMessage(UPDATE_TITLE);
- }
+ cachesCnt = 1;
}
private static abstract class DoRunnable implements Runnable {
@@ -1343,8 +1316,6 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
if (loadDetailsThread != null) {
loadDetailsThread.stopIt();
}
-
- geoDirUpdate.startDir();
} catch (Exception e) {
Log.e("CGeoMap.storeCaches.onCancel", e);
}
@@ -1392,8 +1363,6 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
return;
}
- deleteGeoDirObservers();
-
for (final String geocode : geocodes) {
try {
if (handler.isCancelled()) {
@@ -1417,7 +1386,6 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
// we're done
handler.sendEmptyMessage(FINISHED_LOADING_DETAILS);
- addGeoDirObservers();
}
}
@@ -1609,7 +1577,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
private CachesOverlayItemImpl getCacheItem(final Geocache cache) {
- final CachesOverlayItemImpl item = mapItemFactory.getCachesOverlayItem(cache, cache.getType().applyDistanceRule());
+ final CachesOverlayItemImpl item = mapItemFactory.getCachesOverlayItem(cache, cache.applyDistanceRule());
final int hashcode = new HashCodeBuilder()
.append(cache.isReliableLatLon())