aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/maps
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/maps')
-rw-r--r--main/src/cgeo/geocaching/maps/AbstractMap.java9
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java754
-rw-r--r--main/src/cgeo/geocaching/maps/CachesOverlay.java2
-rw-r--r--main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java7
-rw-r--r--main/src/cgeo/geocaching/maps/PositionDrawer.java8
-rw-r--r--main/src/cgeo/geocaching/maps/ScaleDrawer.java9
-rw-r--r--main/src/cgeo/geocaching/maps/google/GoogleMapActivity.java12
-rw-r--r--main/src/cgeo/geocaching/maps/google/GoogleMapView.java16
-rw-r--r--main/src/cgeo/geocaching/maps/google/GoogleOverlay.java5
-rw-r--r--main/src/cgeo/geocaching/maps/interfaces/MapActivityImpl.java3
-rw-r--r--main/src/cgeo/geocaching/maps/interfaces/MapViewImpl.java3
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapActivity.java6
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java12
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java5
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapActivity024.java6
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java12
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java5
17 files changed, 533 insertions, 341 deletions
diff --git a/main/src/cgeo/geocaching/maps/AbstractMap.java b/main/src/cgeo/geocaching/maps/AbstractMap.java
index d341823..2eceadb 100644
--- a/main/src/cgeo/geocaching/maps/AbstractMap.java
+++ b/main/src/cgeo/geocaching/maps/AbstractMap.java
@@ -5,10 +5,11 @@ import cgeo.geocaching.maps.interfaces.MapActivityImpl;
import android.app.Activity;
import android.content.res.Resources;
+import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
-import android.view.View;
+import android.view.Window;
/**
* Base class for the map activity. Delegates base class calls to the
@@ -31,7 +32,11 @@ public abstract class AbstractMap {
}
public void onCreate(Bundle savedInstanceState) {
+
mapActivity.superOnCreate(savedInstanceState);
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
+ mapActivity.getActivity().requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+ }
}
public void onResume() {
@@ -64,8 +69,6 @@ public abstract class AbstractMap {
return mapActivity.superOnOptionsItemSelected(item);
}
- public abstract void goHome(View view);
-
public abstract void onSaveInstanceState(final Bundle outState);
}
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index 00aee36..4524dec 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -43,14 +43,17 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import rx.Scheduler;
import rx.Subscription;
+import rx.functions.Action0;
import rx.functions.Action1;
import rx.schedulers.Schedulers;
import rx.subscriptions.CompositeSubscription;
import rx.subscriptions.Subscriptions;
+import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
@@ -61,6 +64,7 @@ import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.location.Location;
+import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -70,9 +74,11 @@ import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
+import android.widget.CheckBox;
import android.widget.ImageSwitcher;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
+import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.ViewSwitcher.ViewFactory;
@@ -92,7 +98,7 @@ import java.util.concurrent.TimeUnit;
/**
* Class representing the Map in c:geo
*/
-public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFactory {
+public class CGeoMap extends AbstractMap implements ViewFactory {
/** max. number of caches displayed in the Live Map */
public static final int MAX_CACHES = 500;
@@ -171,7 +177,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
private static final int[][] INSET_USERMODIFIEDCOORDS = { { 21, 28, 0, 0 }, { 19, 25, 0, 0 }, { 25, 33, 0, 0 } }; // bottom right, 12x12 / 26x26 / 35x35
private static final int[][] INSET_PERSONALNOTE = { { 0, 28, 21, 0 }, { 0, 25, 19, 0 }, { 0, 33, 25, 0 } }; // bottom left, 12x12 / 26x26 / 35x35
- private SparseArray<LayerDrawable> overlaysCache = new SparseArray<LayerDrawable>();
+ private final SparseArray<LayerDrawable> overlaysCache = new SparseArray<LayerDrawable>();
/** Count of caches currently visible */
private int cachesCnt = 0;
/** List of caches in the viewport */
@@ -184,9 +190,9 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
private int detailProgress = 0;
private long detailProgressTime = 0L;
// views
- private ImageSwitcher myLocSwitch = null;
+ private CheckBox myLocSwitch = null;
- /** Controls the map behaviour */
+ /** Controls the map behavior */
private MapMode mapMode = null;
/** Live mode enabled for map. **/
private boolean isLiveEnabled;
@@ -210,74 +216,130 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
// handlers
/** Updates the titles */
- final private Handler displayHandler = new Handler() {
+ private final static class DisplayHandler extends Handler {
+
+ private final WeakReference<CGeoMap> mapRef;
+
+ public DisplayHandler(@NonNull final CGeoMap map) {
+ this.mapRef = new WeakReference<CGeoMap>(map);
+ }
@Override
- public void handleMessage(Message msg) {
+ public void handleMessage(final Message msg) {
final int what = msg.what;
+ final CGeoMap map = mapRef.get();
+ if (map == null) {
+ return;
+ }
switch (what) {
case UPDATE_TITLE:
// set title
final StringBuilder title = new StringBuilder();
- if (mapMode == MapMode.LIVE && isLiveEnabled) {
- title.append(res.getString(R.string.map_live));
+ if (map.mapMode == MapMode.LIVE && map.isLiveEnabled) {
+ title.append(map.res.getString(R.string.map_live));
} else {
- title.append(mapTitle);
+ title.append(map.mapTitle);
}
- countVisibleCaches();
- if (caches != null && !caches.isEmpty() && !mapTitle.contains("[")) {
- title.append(" [").append(cachesCnt);
- if (cachesCnt != caches.size()) {
- title.append('/').append(caches.size());
+ map.countVisibleCaches();
+ if (map.caches != null && !map.caches.isEmpty() && !map.mapTitle.contains("[")) {
+ title.append(" [").append(map.cachesCnt);
+ if (map.cachesCnt != map.caches.size()) {
+ title.append('/').append(map.caches.size());
}
title.append(']');
}
- if (Settings.isDebug() && lastSearchResult != null && StringUtils.isNotBlank(lastSearchResult.getUrl())) {
- title.append('[').append(lastSearchResult.getUrl()).append(']');
+ if (Settings.isDebug() && map.lastSearchResult != null && StringUtils.isNotBlank(map.lastSearchResult.getUrl())) {
+ title.append('[').append(map.lastSearchResult.getUrl()).append(']');
}
- ActivityMixin.setTitle(activity, title.toString());
+ map.setTitle(title.toString());
break;
case INVALIDATE_MAP:
- mapView.repaintRequired(null);
+ map.mapView.repaintRequired(null);
break;
default:
break;
}
}
- };
- /** Updates the progress. */
- final private Handler showProgressHandler = new Handler() {
+ }
+
+ final private Handler displayHandler = new DisplayHandler(this);
+
+ private void setTitle(final String title) {
+ /* Compatibility for the old Action Bar, only used by the maps activity at the moment */
+ final TextView titleview = (TextView) activity.findViewById(R.id.actionbar_title);
+ if (titleview != null) {
+ titleview.setText(title);
+
+ }
+ if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)) {
+ setTitleHoneyComb(title);
+ }
+ }
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ private void setTitleHoneyComb(final String title) {
+ activity.getActionBar().setTitle(title);
+ }
+
+ /** Updates the progress. */
+ private static final class ShowProgressHandler extends Handler {
private int counter = 0;
+ @NonNull private final WeakReference<CGeoMap> mapRef;
+
+ public ShowProgressHandler(@NonNull final CGeoMap map) {
+ this.mapRef = new WeakReference<CGeoMap>(map);
+ }
@Override
- public void handleMessage(Message msg) {
+ public void handleMessage(final Message msg) {
final int what = msg.what;
if (what == HIDE_PROGRESS) {
if (--counter == 0) {
- ActivityMixin.showProgress(activity, false);
+ showProgress(false);
}
} else if (what == SHOW_PROGRESS) {
- ActivityMixin.showProgress(activity, true);
+ showProgress(true);
counter++;
}
}
- };
+
+ private void showProgress(final boolean show) {
+ final CGeoMap map = mapRef.get();
+ if (map == null) {
+ return;
+ }
+
+ final ProgressBar progress = (ProgressBar) map.activity.findViewById(R.id.actionbar_progress);
+ if (progress != null) {
+ if (show) {
+ progress.setVisibility(View.VISIBLE);
+ } else {
+ progress.setVisibility(View.GONE);
+
+ }
+ }
+ if (Build.VERSION.SDK_INT >= 11) {
+ map.activity.setProgressBarIndeterminateVisibility(show);
+ }
+ }
+ }
+
+ final private Handler showProgressHandler = new ShowProgressHandler(this);
final private class LoadDetailsHandler extends CancellableHandler {
@Override
- public void handleRegularMessage(Message msg) {
+ public void handleRegularMessage(final Message msg) {
if (msg.what == UPDATE_PROGRESS) {
if (waitDialog != null) {
- int secondsElapsed = (int) ((System.currentTimeMillis() - detailProgressTime) / 1000);
+ final int secondsElapsed = (int) ((System.currentTimeMillis() - detailProgressTime) / 1000);
int secondsRemaining;
if (detailProgress > 0) {
secondsRemaining = (detailTotal - detailProgress) * secondsElapsed / detailProgress;
@@ -289,7 +351,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
if (secondsRemaining < 40) {
waitDialog.setMessage(res.getString(R.string.caches_downloading) + " " + res.getString(R.string.caches_eta_ltm));
} else {
- int minsRemaining = secondsRemaining / 60;
+ final int minsRemaining = secondsRemaining / 60;
waitDialog.setMessage(res.getString(R.string.caches_downloading) + " " + minsRemaining + " " + res.getQuantityString(R.plurals.caches_eta_mins, minsRemaining));
}
}
@@ -312,7 +374,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
final private Handler noMapTokenHandler = new Handler() {
@Override
- public void handleMessage(Message msg) {
+ public void handleMessage(final Message msg) {
if (!noMapTokenShowed) {
ActivityMixin.showToast(activity, res.getString(R.string.map_token_err));
@@ -328,7 +390,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
/* Current source id */
private int currentSourceId;
- public CGeoMap(MapActivityImpl activity) {
+ public CGeoMap(final MapActivityImpl activity) {
super(activity);
geoDirUpdate = new UpdateLoc(this);
}
@@ -361,8 +423,9 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
}
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
- public void onCreate(Bundle savedInstanceState) {
+ public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// class init
@@ -370,7 +433,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
activity = this.getActivity();
app = (CgeoApplication) activity.getApplication();
- int countBubbleCnt = DataStore.getAllCachesCount();
+ final int countBubbleCnt = DataStore.getAllCachesCount();
caches = new LeastRecentlyUsedSet<Geocache>(MAX_CACHES + countBubbleCnt);
final MapProvider mapProvider = Settings.getMapProvider();
@@ -418,10 +481,16 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
ActivityMixin.keepScreenOn(activity, true);
+
// set layout
- ActivityMixin.setTheme(activity);
+ //ActivityMixin.setTheme(activity);
+ // TODO: set a proper theme
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
+ activity.setTheme(android.R.style.Theme_Holo);
+ activity.getActionBar().setDisplayHomeAsUpEnabled(true);
+ }
activity.setContentView(mapProvider.getMapLayoutId());
- ActivityMixin.setTitle(activity, res.getString(R.string.map_map));
+ setTitle(res.getString(R.string.map_map));
// initialize map
mapView = (MapViewImpl) activity.findViewById(mapProvider.getMapViewId());
@@ -429,7 +498,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
mapView.setBuiltInZoomControls(true);
mapView.displayZoomControls(true);
mapView.preLoad();
- mapView.setOnDragListener(this);
+ mapView.setOnDragListener(new MapDragListener(this));
// initialize overlays
mapView.clearOverlays();
@@ -439,7 +508,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
if (overlayPositionAndScale == null) {
- overlayPositionAndScale = mapView.createAddPositionAndScaleOverlay(activity);
+ overlayPositionAndScale = mapView.createAddPositionAndScaleOverlay();
if (trailHistory != null) {
overlayPositionAndScale.setHistory(trailHistory);
}
@@ -462,14 +531,11 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
centerMap(geocodeIntent, searchIntent, coordsIntent, mapStateIntent);
}
- // prepare my location button
- myLocSwitch = (ImageSwitcher) activity.findViewById(R.id.my_position);
- myLocSwitch.setFactory(this);
- myLocSwitch.setInAnimation(activity, android.R.anim.fade_in);
- myLocSwitch.setOutAnimation(activity, android.R.anim.fade_out);
- myLocSwitch.setOnClickListener(new MyLocationListener());
- switchMyLocationButton();
+ final CheckBox locSwitch = (CheckBox) activity.findViewById(R.id.my_position);
+ if (locSwitch!=null) {
+ initMyLocationSwitchButton(locSwitch);
+ }
prepareFilterBar();
if (!app.isLiveMapHintShownInThisSession() && !Settings.getHideLiveMapHint() && Settings.getLiveMapHintShowCount() <= 3) {
@@ -477,6 +543,16 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
}
+ private void initMyLocationSwitchButton(final CheckBox locSwitch) {
+ myLocSwitch = locSwitch;
+ /* TODO: Switch back to ImageSwitcher for animations?
+ myLocSwitch.setFactory(this);
+ myLocSwitch.setInAnimation(activity, android.R.anim.fade_in);
+ myLocSwitch.setOutAnimation(activity, android.R.anim.fade_out); */
+ myLocSwitch.setOnClickListener(new MyLocationListener(this));
+ switchMyLocationButton();
+ }
+
/**
* Set the zoom of the map. The zoom is restricted to a certain minimum in case of live map.
*
@@ -489,7 +565,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
private void prepareFilterBar() {
// show the filter warning bar if the filter is set
if (Settings.getCacheType() != CacheType.ALL) {
- String cacheType = Settings.getCacheType().getL10n();
+ final String cacheType = Settings.getCacheType().getL10n();
((TextView) activity.findViewById(R.id.filter_text)).setText(cacheType);
activity.findViewById(R.id.filter_bar).setVisibility(View.VISIBLE);
} else {
@@ -503,8 +579,8 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
resumeSubscription = Subscriptions.from(geoDirUpdate.start(GeoDirHandler.UPDATE_GEODIR), startTimer());
if (!CollectionUtils.isEmpty(dirtyCaches)) {
- for (String geocode : dirtyCaches) {
- Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_WAYPOINTS);
+ for (final String geocode : dirtyCaches) {
+ final Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_WAYPOINTS);
if (cache != null) {
// new collection type needs to remove first
caches.remove(cache);
@@ -514,7 +590,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
dirtyCaches.clear();
// Update display
- displayExecutor.execute(new DisplayRunnable(mapView.getViewport()));
+ displayExecutor.execute(new DisplayRunnable(this));
}
}
@@ -532,8 +608,9 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
super.onPause();
}
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
- public boolean onCreateOptionsMenu(Menu menu) {
+ public boolean onCreateOptionsMenu(final Menu menu) {
// menu inflation happens in Google/Mapsforge specific classes
super.onCreateOptionsMenu(menu);
@@ -541,26 +618,35 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
final SubMenu subMenuStrategy = menu.findItem(R.id.submenu_strategy).getSubMenu();
subMenuStrategy.setHeaderTitle(res.getString(R.string.map_strategy_title));
+
+
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
+ /* if we have an Actionbar find the my position toggle */
+ final MenuItem item = menu.findItem(R.id.menu_toggle_mypos);
+ myLocSwitch = new CheckBox(activity);
+ myLocSwitch.setButtonDrawable(R.drawable.ic_menu_myposition);
+ item.setActionView(myLocSwitch);
+ initMyLocationSwitchButton(myLocSwitch);
+ } else {
+ // Already on the fake Actionbar
+ menu.removeItem(R.id.menu_toggle_mypos);
+ }
return true;
}
@Override
- public boolean onPrepareOptionsMenu(Menu menu) {
+ public boolean onPrepareOptionsMenu(final Menu menu) {
super.onPrepareOptionsMenu(menu);
- for (MapSource mapSource : MapProviderFactory.getMapSources()) {
+ for (final MapSource mapSource : MapProviderFactory.getMapSources()) {
final MenuItem menuItem = menu.findItem(mapSource.getNumericalId());
if (menuItem != null) {
- menuItem.setEnabled(mapSource.isAvailable());
+ menuItem.setVisible(mapSource.isAvailable());
}
}
try {
MenuItem item = menu.findItem(R.id.menu_trail_mode);
- if (Settings.isMapTrail()) {
- item.setTitle(res.getString(R.string.map_trail_hide));
- } else {
- item.setTitle(res.getString(R.string.map_trail_show));
- }
+ item.setChecked(Settings.isMapTrail());
item = menu.findItem(R.id.menu_map_live); // live map
if (isLiveEnabled) {
@@ -570,28 +656,20 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
item = menu.findItem(R.id.menu_mycaches_mode); // own & found caches
- if (Settings.isExcludeMyCaches()) {
- item.setTitle(res.getString(R.string.map_mycaches_show));
- } else {
- item.setTitle(res.getString(R.string.map_mycaches_hide));
- }
+ item.setChecked(Settings.isExcludeMyCaches());
final Set<String> geocodesInViewport = getGeocodesForCachesInViewport();
- menu.findItem(R.id.menu_store_caches).setEnabled(!isLoading() && CollectionUtils.isNotEmpty(geocodesInViewport) && new SearchResult(geocodesInViewport).hasUnsavedCaches());
+ menu.findItem(R.id.menu_store_caches).setVisible(!isLoading() && CollectionUtils.isNotEmpty(geocodesInViewport) && new SearchResult(geocodesInViewport).hasUnsavedCaches());
item = menu.findItem(R.id.menu_circle_mode); // show circles
- if (overlayCaches != null && overlayCaches.getCircles()) {
- item.setTitle(res.getString(R.string.map_circles_hide));
- } else {
- item.setTitle(res.getString(R.string.map_circles_show));
- }
+ item.setChecked(overlayCaches != null && overlayCaches.getCircles());
item = menu.findItem(R.id.menu_theme_mode); // show theme selection
item.setVisible(mapView.hasMapThemes());
- menu.findItem(R.id.menu_as_list).setEnabled(!isLoading());
+ menu.findItem(R.id.menu_as_list).setVisible(!isLoading());
- menu.findItem(R.id.submenu_strategy).setEnabled(isLiveEnabled);
+ menu.findItem(R.id.submenu_strategy).setVisible(isLiveEnabled);
switch (Settings.getLiveMapStrategy()) {
case FASTEST:
@@ -606,7 +684,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
default: // DETAILED
menu.findItem(R.id.menu_strategy_detailed).setChecked(true);
}
- } catch (RuntimeException e) {
+ } catch (final RuntimeException e) {
Log.e("CGeoMap.onPrepareOptionsMenu", e);
}
@@ -614,9 +692,12 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
+ public boolean onOptionsItemSelected(final MenuItem item) {
final int id = item.getItemId();
switch (id) {
+ case android.R.id.home:
+ ActivityMixin.navigateUp(activity);
+ return true;
case R.id.menu_trail_mode:
Settings.setMapTrail(!Settings.isMapTrail());
mapView.repaintRequired(overlayPositionAndScale);
@@ -726,16 +807,16 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
final File[] themeFiles = Settings.getMapThemeFiles();
String currentTheme = StringUtils.EMPTY;
- String currentThemePath = Settings.getCustomRenderThemeFilePath();
+ final String currentThemePath = Settings.getCustomRenderThemeFilePath();
if (StringUtils.isNotEmpty(currentThemePath)) {
- File currentThemeFile = new File(currentThemePath);
+ final File currentThemeFile = new File(currentThemePath);
currentTheme = currentThemeFile.getName();
}
- List<String> names = new ArrayList<String>();
+ final List<String> names = new ArrayList<String>();
names.add(res.getString(R.string.map_theme_builtin));
int currentItem = 0;
- for (File file : themeFiles) {
+ for (final File file : themeFiles) {
if (currentTheme.equalsIgnoreCase(file.getName())) {
currentItem = names.size();
}
@@ -744,7 +825,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
final int selectedItem = currentItem;
- AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+ final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.map_theme_select);
@@ -752,7 +833,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
new DialogInterface.OnClickListener() {
@Override
- public void onClick(DialogInterface dialog, int newItem) {
+ public void onClick(final DialogInterface dialog, final int newItem) {
if (newItem != selectedItem) {
// Adjust index because of <default> selection
if (newItem > 0) {
@@ -818,7 +899,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
activity.finish();
// prepare information to restart a similar view
- Intent mapIntent = new Intent(activity, Settings.getMapProvider().getMapClass());
+ final Intent mapIntent = new Intent(activity, Settings.getMapProvider().getMapClass());
mapIntent.putExtra(EXTRAS_SEARCH, searchIntent);
mapIntent.putExtra(EXTRAS_GEOCODE, geocodeIntent);
@@ -896,7 +977,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
*/
private final WeakReference<CGeoMap> map;
- public UpdateLoc(CGeoMap map) {
+ public UpdateLoc(final CGeoMap map) {
this.map = new WeakReference<CGeoMap>(map);
}
@@ -922,15 +1003,15 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
timeLastPositionOverlayCalculation = currentTimeMillis;
try {
- CGeoMap cgeoMapRef = map.get();
+ final CGeoMap cgeoMapRef = map.get();
if (cgeoMapRef != null) {
if (cgeoMapRef.mapView != null) {
if (cgeoMapRef.overlayPositionAndScale == null) {
- cgeoMapRef.overlayPositionAndScale = cgeoMapRef.mapView.createAddPositionAndScaleOverlay(cgeoMapRef.activity);
+ cgeoMapRef.overlayPositionAndScale = cgeoMapRef.mapView.createAddPositionAndScaleOverlay();
}
- boolean needsRepaintForDistance = needsRepaintForDistance();
- boolean needsRepaintForHeading = needsRepaintForHeading();
+ final boolean needsRepaintForDistance = needsRepaintForDistance();
+ final boolean needsRepaintForHeading = needsRepaintForHeading();
if (needsRepaintForDistance) {
if (cgeoMapRef.followMyLocation) {
@@ -945,7 +1026,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
}
}
- } catch (RuntimeException e) {
+ } catch (final RuntimeException e) {
Log.w("Failed to update location.");
}
}
@@ -1003,50 +1084,95 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
return loadTimer;
}
- /**
- * loading timer Triggers every 250ms and checks for viewport change and starts a {@link LoadRunnable}.
- */
- private Subscription startLoadTimer() {
- return Schedulers.newThread().schedulePeriodically(new Action1<Scheduler.Inner>() {
- @Override
- public void call(Scheduler.Inner inner) {
- try {
- if (mapView != null) {
- // get current viewport
- final Viewport viewportNow = mapView.getViewport();
- // Since zoomNow is used only for local comparison purposes,
- // it is ok to use the Google Maps compatible zoom level of OSM Maps
- final int zoomNow = mapView.getMapZoomLevel();
-
- // check if map moved or zoomed
- //TODO Portree Use Rectangle inside with bigger search window. That will stop reloading on every move
- final boolean moved = markersInvalidated || (isLiveEnabled && !downloaded) || (viewport == null) || zoomNow != zoom ||
- (mapMoved(viewport, viewportNow) && (cachesCnt <= 0 || CollectionUtils.isEmpty(caches) || !viewport.includes(viewportNow)));
-
- // update title on any change
- if (moved || !viewportNow.equals(viewport)) {
- displayHandler.sendEmptyMessage(UPDATE_TITLE);
- }
- zoom = zoomNow;
+ private static final class LoadTimerAction implements Action0, Subscription {
- // save new values
- if (moved) {
- markersInvalidated = false;
+ private volatile boolean isUnsubscribed = false;
- long currentTime = System.currentTimeMillis();
+ private Scheduler.Worker worker;
- if (1000 < (currentTime - loadThreadRun)) {
- viewport = viewportNow;
- loadExecutor.execute(new LoadRunnable(viewport));
- }
+ @NonNull private final WeakReference<CGeoMap> mapRef;
+
+ public LoadTimerAction(@NonNull final CGeoMap map, final Scheduler.Worker worker) {
+ this.mapRef = new WeakReference<CGeoMap>(map);
+ this.worker = worker;
+ }
+
+ @Override
+ public void call() {
+ final CGeoMap map = mapRef.get();
+ if (map == null) {
+ return;
+ }
+ try {
+ if (map.mapView != null && !isUnsubscribed) {
+ // get current viewport
+ final Viewport viewportNow = map.mapView.getViewport();
+ // Since zoomNow is used only for local comparison purposes,
+ // it is ok to use the Google Maps compatible zoom level of OSM Maps
+ final int zoomNow = map.mapView.getMapZoomLevel();
+
+ // check if map moved or zoomed
+ //TODO Portree Use Rectangle inside with bigger search window. That will stop reloading on every move
+ final boolean moved = map.markersInvalidated || (map.isLiveEnabled && !map.downloaded) || (map.viewport == null) || zoomNow != map.zoom ||
+ (mapMoved(map.viewport, viewportNow) && (map.cachesCnt <= 0 || CollectionUtils.isEmpty(map.caches) || !map.viewport.includes(viewportNow)));
+
+ // update title on any change
+ if (moved || !viewportNow.equals(map.viewport)) {
+ map.displayHandler.sendEmptyMessage(UPDATE_TITLE);
+ }
+ map.zoom = zoomNow;
+
+ // save new values
+ if (moved) {
+ map.markersInvalidated = false;
+
+ final long currentTime = System.currentTimeMillis();
+
+ if (1000 < (currentTime - map.loadThreadRun)) {
+ map.viewport = viewportNow;
+ loadExecutor.execute(new LoadRunnable(map));
}
}
+ }
- } catch (Exception e) {
- Log.w("CGeoMap.startLoadtimer.start", e);
+ } catch (final Exception e) {
+ Log.w("CGeoMap.startLoadtimer.start", e);
+ }
+
+ if (!isUnsubscribed) {
+ if (worker == null) {
+ worker = Schedulers.newThread().createWorker();
}
+ worker.schedule(this, 250, TimeUnit.MILLISECONDS);
+ }
+ }
+
+ @Override
+ public void unsubscribe() {
+ isUnsubscribed = true;
+ if (worker != null) {
+ worker.unsubscribe();
+ worker = null;
}
- }, 250, 250, TimeUnit.MILLISECONDS);
+ }
+
+ @Override
+ public boolean isUnsubscribed() {
+ return isUnsubscribed;
+ }
+ }
+
+ /**
+ * loading timer Triggers every 250ms and checks for viewport change and starts a {@link LoadRunnable}.
+ */
+ private Subscription startLoadTimer() {
+ // We cannot use schedulePeriodically with RxJava 0.19 and earlier because the unsubscription
+ // mechanism fails. As a consequence, we reschedule periodically by hand as long as we are not
+ // unsubscribed. There may be a small drift, but it has no consequence.
+ final Scheduler.Worker worker = Schedulers.newThread().createWorker();
+ final LoadTimerAction action = new LoadTimerAction(this, worker);
+ worker.schedule(action, 250, TimeUnit.MILLISECONDS);
+ return action;
}
/**
@@ -1066,79 +1192,87 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
* started by {@link LoadTimer}
*/
- private class LoadRunnable extends DoRunnable {
+ private static class LoadRunnable extends DoRunnable {
- public LoadRunnable(final Viewport viewport) {
- super(viewport);
+ public LoadRunnable(@NonNull final CGeoMap map) {
+ super(map);
}
@Override
public void run() {
- try {
- showProgressHandler.sendEmptyMessage(SHOW_PROGRESS);
- loadThreadRun = System.currentTimeMillis();
-
- SearchResult searchResult;
- if (mapMode == MapMode.LIVE) {
- searchResult = isLiveEnabled ? new SearchResult() : new SearchResult(DataStore.loadStoredInViewport(viewport, Settings.getCacheType()));
- } else {
- // map started from another activity
- searchResult = searchIntent != null ? new SearchResult(searchIntent) : new SearchResult();
- if (geocodeIntent != null) {
- searchResult.addGeocode(geocodeIntent);
- }
- }
- // live mode search result
- if (isLiveEnabled) {
- searchResult.addSearchResult(DataStore.loadCachedInViewport(viewport, Settings.getCacheType()));
- }
+ final CGeoMap map = getMap();
+ if (map != null) {
+ map.doLoadRun();
+ }
+ }
+ }
- downloaded = true;
- Set<Geocache> cachesFromSearchResult = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_WAYPOINTS);
- // update the caches
- // new collection type needs to remove first
- caches.removeAll(cachesFromSearchResult);
- caches.addAll(cachesFromSearchResult);
+ private void doLoadRun() {
+ try {
+ showProgressHandler.sendEmptyMessage(SHOW_PROGRESS);
+ loadThreadRun = System.currentTimeMillis();
- final boolean excludeMine = Settings.isExcludeMyCaches();
- final boolean excludeDisabled = Settings.isExcludeDisabledCaches();
- if (mapMode == MapMode.LIVE) {
- CGeoMap.filter(caches);
+ SearchResult searchResult;
+ if (mapMode == MapMode.LIVE) {
+ searchResult = isLiveEnabled ? new SearchResult() : new SearchResult(DataStore.loadStoredInViewport(viewport, Settings.getCacheType()));
+ } else {
+ // map started from another activity
+ searchResult = searchIntent != null ? new SearchResult(searchIntent) : new SearchResult();
+ if (geocodeIntent != null) {
+ searchResult.addGeocode(geocodeIntent);
}
- countVisibleCaches();
- if (cachesCnt < Settings.getWayPointsThreshold() || geocodeIntent != null) {
- // we don't want to see any stale waypoints
- waypoints.clear();
- if (isLiveEnabled || mapMode == MapMode.LIVE
- || mapMode == MapMode.COORDS) {
- //All visible waypoints
- CacheType type = Settings.getCacheType();
- Set<Waypoint> waypointsInViewport = DataStore.loadWaypoints(viewport, excludeMine, excludeDisabled, type);
- waypoints.addAll(waypointsInViewport);
- }
- else {
- //All waypoints from the viewed caches
- for (Geocache c : caches.getAsList()) {
- waypoints.addAll(c.getWaypoints());
- }
- }
+ }
+ // live mode search result
+ if (isLiveEnabled) {
+ searchResult.addSearchResult(DataStore.loadCachedInViewport(viewport, Settings.getCacheType()));
+ }
+
+ downloaded = true;
+ final Set<Geocache> cachesFromSearchResult = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_WAYPOINTS);
+ // update the caches
+ // new collection type needs to remove first
+ caches.removeAll(cachesFromSearchResult);
+ caches.addAll(cachesFromSearchResult);
+
+ final boolean excludeMine = Settings.isExcludeMyCaches();
+ final boolean excludeDisabled = Settings.isExcludeDisabledCaches();
+ if (mapMode == MapMode.LIVE) {
+ CGeoMap.filter(caches);
+ }
+ countVisibleCaches();
+ if (cachesCnt < Settings.getWayPointsThreshold() || geocodeIntent != null) {
+ // we don't want to see any stale waypoints
+ waypoints.clear();
+ if (isLiveEnabled || mapMode == MapMode.LIVE
+ || mapMode == MapMode.COORDS) {
+ //All visible waypoints
+ final CacheType type = Settings.getCacheType();
+ final Set<Waypoint> waypointsInViewport = DataStore.loadWaypoints(viewport, excludeMine, excludeDisabled, type);
+ waypoints.addAll(waypointsInViewport);
}
else {
- // we don't want to see any stale waypoints when above threshold
- waypoints.clear();
+ //All waypoints from the viewed caches
+ for (final Geocache c : caches.getAsList()) {
+ waypoints.addAll(c.getWaypoints());
+ }
}
+ }
+ else {
+ // we don't want to see any stale waypoints when above threshold
+ waypoints.clear();
+ }
- //render
- displayExecutor.execute(new DisplayRunnable(viewport));
+ //render
+ displayExecutor.execute(new DisplayRunnable(this));
- if (isLiveEnabled) {
- downloadExecutor.execute(new DownloadRunnable(viewport));
- }
- lastSearchResult = searchResult;
- } finally {
- showProgressHandler.sendEmptyMessage(HIDE_PROGRESS); // hide progress
+ if (isLiveEnabled) {
+ downloadExecutor.execute(new DownloadRunnable(this));
}
+ lastSearchResult = searchResult;
+ } finally {
+ showProgressHandler.sendEmptyMessage(HIDE_PROGRESS); // hide progress
}
+
}
/**
@@ -1146,111 +1280,125 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
* Started by {@link LoadRunnable}.
*/
- private class DownloadRunnable extends DoRunnable {
+ private static class DownloadRunnable extends DoRunnable {
- public DownloadRunnable(final Viewport viewport) {
- super(viewport);
+ public DownloadRunnable(final CGeoMap map) {
+ super(map);
}
@Override
public void run() {
- try {
- showProgressHandler.sendEmptyMessage(SHOW_PROGRESS); // show progress
- if (Settings.isGCConnectorActive()) {
- if (tokens == null) {
- tokens = GCLogin.getInstance().getMapTokens();
- if (noMapTokenHandler != null && (StringUtils.isEmpty(tokens.getUserSession()) || StringUtils.isEmpty(tokens.getSessionToken()))) {
- tokens = null;
- noMapTokenHandler.sendEmptyMessage(0);
- }
+ final CGeoMap map = getMap();
+ if (map != null) {
+ map.doDownloadRun();
+ }
+ }
+ }
+
+ private void doDownloadRun() {
+ try {
+ showProgressHandler.sendEmptyMessage(SHOW_PROGRESS); // show progress
+ if (Settings.isGCConnectorActive()) {
+ if (tokens == null) {
+ tokens = GCLogin.getInstance().getMapTokens();
+ if (noMapTokenHandler != null && (StringUtils.isEmpty(tokens.getUserSession()) || StringUtils.isEmpty(tokens.getSessionToken()))) {
+ tokens = null;
+ noMapTokenHandler.sendEmptyMessage(0);
}
}
- final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport.resize(0.8), tokens);
- downloaded = true;
-
- Set<Geocache> result = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB);
- CGeoMap.filter(result);
- // update the caches
- // first remove filtered out
- final Set<String> filteredCodes = searchResult.getFilteredGeocodes();
- Log.d("Filtering out " + filteredCodes.size() + " caches: " + filteredCodes.toString());
- caches.removeAll(DataStore.loadCaches(filteredCodes, LoadFlags.LOAD_CACHE_ONLY));
- DataStore.removeCaches(filteredCodes, EnumSet.of(RemoveFlag.REMOVE_CACHE));
- // new collection type needs to remove first to refresh
- caches.removeAll(result);
- caches.addAll(result);
- lastSearchResult = searchResult;
-
- //render
- displayExecutor.execute(new DisplayRunnable(viewport));
-
- } catch (ThreadDeath e) {
- Log.d("DownloadThread stopped");
- displayHandler.sendEmptyMessage(UPDATE_TITLE);
- } finally {
- showProgressHandler.sendEmptyMessage(HIDE_PROGRESS); // hide progress
}
+ final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport.resize(0.8), tokens);
+ downloaded = true;
+
+ final Set<Geocache> result = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB);
+ CGeoMap.filter(result);
+ // update the caches
+ // first remove filtered out
+ final Set<String> filteredCodes = searchResult.getFilteredGeocodes();
+ Log.d("Filtering out " + filteredCodes.size() + " caches: " + filteredCodes.toString());
+ caches.removeAll(DataStore.loadCaches(filteredCodes, LoadFlags.LOAD_CACHE_ONLY));
+ DataStore.removeCaches(filteredCodes, EnumSet.of(RemoveFlag.REMOVE_CACHE));
+ // new collection type needs to remove first to refresh
+ caches.removeAll(result);
+ caches.addAll(result);
+ lastSearchResult = searchResult;
+
+ //render
+ displayExecutor.execute(new DisplayRunnable(this));
+
+ } catch (final ThreadDeath e) {
+ Log.d("DownloadThread stopped");
+ displayHandler.sendEmptyMessage(UPDATE_TITLE);
+ } finally {
+ showProgressHandler.sendEmptyMessage(HIDE_PROGRESS); // hide progress
}
}
/**
* Thread to Display (down)loaded caches. Started by {@link LoadRunnable} and {@link DownloadRunnable}
*/
- private class DisplayRunnable extends DoRunnable {
+ private static class DisplayRunnable extends DoRunnable {
- public DisplayRunnable(final Viewport viewport) {
- super(viewport);
+ public DisplayRunnable(@NonNull final CGeoMap map) {
+ super(map);
}
@Override
public void run() {
- try {
- showProgressHandler.sendEmptyMessage(SHOW_PROGRESS);
- if (mapView == null || caches == null) {
- throw new ThreadDeath();
- }
-
- // display caches
- final List<Geocache> cachesToDisplay = caches.getAsList();
- final List<Waypoint> waypointsToDisplay = new ArrayList<Waypoint>(waypoints);
- final List<CachesOverlayItemImpl> itemsToDisplay = new ArrayList<CachesOverlayItemImpl>();
+ final CGeoMap map = getMap();
+ if (map != null) {
+ map.doDisplayRun();
+ }
+ }
+ }
- if (!cachesToDisplay.isEmpty()) {
- // Only show waypoints for single view or setting
- // when less than showWaypointsthreshold Caches shown
- if (mapMode == MapMode.SINGLE || (cachesCnt < Settings.getWayPointsThreshold())) {
- for (Waypoint waypoint : waypointsToDisplay) {
+ private void doDisplayRun() {
+ try {
+ showProgressHandler.sendEmptyMessage(SHOW_PROGRESS);
+ if (mapView == null || caches == null) {
+ throw new ThreadDeath();
+ }
- if (waypoint == null || waypoint.getCoords() == null) {
- continue;
- }
+ // display caches
+ final List<Geocache> cachesToDisplay = caches.getAsList();
+ final List<Waypoint> waypointsToDisplay = new ArrayList<Waypoint>(waypoints);
+ final List<CachesOverlayItemImpl> itemsToDisplay = new ArrayList<CachesOverlayItemImpl>();
- itemsToDisplay.add(getWaypointItem(waypoint));
- }
- }
- for (Geocache cache : cachesToDisplay) {
+ if (!cachesToDisplay.isEmpty()) {
+ // Only show waypoints for single view or setting
+ // when less than showWaypointsthreshold Caches shown
+ if (mapMode == MapMode.SINGLE || (cachesCnt < Settings.getWayPointsThreshold())) {
+ for (final Waypoint waypoint : waypointsToDisplay) {
- if (cache == null || cache.getCoords() == null) {
+ if (waypoint == null || waypoint.getCoords() == null) {
continue;
}
- itemsToDisplay.add(getCacheItem(cache));
- }
- overlayCaches.updateItems(itemsToDisplay);
- displayHandler.sendEmptyMessage(INVALIDATE_MAP);
+ itemsToDisplay.add(getWaypointItem(waypoint));
+ }
+ }
+ for (final Geocache cache : cachesToDisplay) {
- } else {
- overlayCaches.updateItems(itemsToDisplay);
- displayHandler.sendEmptyMessage(INVALIDATE_MAP);
+ if (cache == null || cache.getCoords() == null) {
+ continue;
+ }
+ itemsToDisplay.add(getCacheItem(cache));
}
- displayHandler.sendEmptyMessage(UPDATE_TITLE);
- } catch (ThreadDeath e) {
- Log.d("DisplayThread stopped");
- displayHandler.sendEmptyMessage(UPDATE_TITLE);
- } finally {
- showProgressHandler.sendEmptyMessage(HIDE_PROGRESS);
+ overlayCaches.updateItems(itemsToDisplay);
+ displayHandler.sendEmptyMessage(INVALIDATE_MAP);
+
+ } else {
+ overlayCaches.updateItems(itemsToDisplay);
+ displayHandler.sendEmptyMessage(INVALIDATE_MAP);
}
+
+ displayHandler.sendEmptyMessage(UPDATE_TITLE);
+ } catch (final ThreadDeath e) {
+ Log.d("DisplayThread stopped");
+ displayHandler.sendEmptyMessage(UPDATE_TITLE);
+ } finally {
+ showProgressHandler.sendEmptyMessage(HIDE_PROGRESS);
}
}
@@ -1268,10 +1416,15 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
private static abstract class DoRunnable implements Runnable {
- final protected Viewport viewport;
+ private final WeakReference<CGeoMap> mapRef;
- protected DoRunnable(final Viewport viewport) {
- this.viewport = viewport;
+ protected DoRunnable(@NonNull final CGeoMap map) {
+ mapRef = new WeakReference<CGeoMap>(map);
+ }
+
+ protected @Nullable
+ final CGeoMap getMap() {
+ return mapRef.get();
}
}
@@ -1281,7 +1434,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
* @param listId
* the list to store the caches in
*/
- private void storeCaches(List<String> geocodes, int listId) {
+ private void storeCaches(final List<String> geocodes, final int listId) {
final LoadDetailsHandler loadDetailsHandler = new LoadDetailsHandler();
waitDialog = new ProgressDialog(activity);
@@ -1292,19 +1445,19 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
waitDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
- public void onCancel(DialogInterface arg0) {
+ public void onCancel(final DialogInterface arg0) {
try {
if (loadDetailsThread != null) {
loadDetailsThread.stopIt();
}
- } catch (Exception e) {
+ } catch (final Exception e) {
Log.e("CGeoMap.storeCaches.onCancel", e);
}
}
});
- float etaTime = detailTotal * 7.0f / 60.0f;
- int roundedEta = Math.round(etaTime);
+ final float etaTime = detailTotal * 7.0f / 60.0f;
+ final int roundedEta = Math.round(etaTime);
if (etaTime < 0.4) {
waitDialog.setMessage(res.getString(R.string.caches_downloading) + " " + res.getString(R.string.caches_eta_ltm));
} else {
@@ -1353,7 +1506,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
if (!DataStore.isOffline(geocode, null)) {
Geocache.storeCache(null, geocode, listId, false, handler);
}
- } catch (Exception e) {
+ } catch (final Exception e) {
Log.e("CGeoMap.LoadDetails.run", e);
} finally {
// one more cache over
@@ -1367,13 +1520,13 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
}
- private static synchronized void filter(Collection<Geocache> caches) {
- boolean excludeMine = Settings.isExcludeMyCaches();
- boolean excludeDisabled = Settings.isExcludeDisabledCaches();
+ private static synchronized void filter(final Collection<Geocache> caches) {
+ final boolean excludeMine = Settings.isExcludeMyCaches();
+ final boolean excludeDisabled = Settings.isExcludeDisabledCaches();
- List<Geocache> removeList = new ArrayList<Geocache>();
- for (Geocache cache : caches) {
- if ((excludeMine && cache.isFound()) || (excludeMine && cache.isOwner()) || (excludeDisabled && cache.isDisabled())) {
+ final List<Geocache> removeList = new ArrayList<Geocache>();
+ for (final Geocache cache : caches) {
+ if ((excludeMine && cache.isFound()) || (excludeMine && cache.isOwner()) || (excludeDisabled && cache.isDisabled()) || (excludeDisabled && cache.isArchived())) {
removeList.add(cache);
}
}
@@ -1410,14 +1563,14 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
// move map to view results of searchIntent
- private void centerMap(String geocodeCenter, final SearchResult searchCenter, final Geopoint coordsCenter, int[] mapState) {
+ private void centerMap(final String geocodeCenter, final SearchResult searchCenter, final Geopoint coordsCenter, final int[] mapState) {
final MapControllerImpl mapController = mapView.getMapController();
if (!centered && mapState != null) {
try {
mapController.setCenter(mapItemFactory.getGeoPointBase(new Geopoint(mapState[0] / 1.0e6, mapState[1] / 1.0e6)));
setZoom(mapState[2]);
- } catch (RuntimeException e) {
+ } catch (final RuntimeException e) {
Log.e("centermap", e);
}
@@ -1441,7 +1594,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
if (viewport.getLatitudeSpan() != 0 && viewport.getLongitudeSpan() != 0) {
mapController.zoomToSpan((int) (viewport.getLatitudeSpan() * 1e6), (int) (viewport.getLongitudeSpan() * 1e6));
}
- } catch (RuntimeException e) {
+ } catch (final RuntimeException e) {
Log.e("centermap", e);
}
@@ -1450,7 +1603,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
} else if (!centered && coordsCenter != null) {
try {
mapController.setCenter(makeGeoPoint(coordsCenter));
- } catch (Exception e) {
+ } catch (final Exception e) {
Log.e("centermap", e);
}
@@ -1461,25 +1614,54 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
// switch My Location button image
private void switchMyLocationButton() {
+ myLocSwitch.setChecked(followMyLocation);
if (followMyLocation) {
- myLocSwitch.setImageResource(R.drawable.actionbar_mylocation_on);
myLocationInMiddle(app.currentGeo());
- } else {
- myLocSwitch.setImageResource(R.drawable.actionbar_mylocation_off);
}
}
// set my location listener
- private class MyLocationListener implements View.OnClickListener {
+ private static class MyLocationListener implements View.OnClickListener {
+
+ private final WeakReference<CGeoMap> mapRef;
+
+ public MyLocationListener(@NonNull final CGeoMap map) {
+ mapRef = new WeakReference<CGeoMap>(map);
+ }
+
@Override
- public void onClick(View view) {
- followMyLocation = !followMyLocation;
- switchMyLocationButton();
+ public void onClick(final View view) {
+ final CGeoMap map = mapRef.get();
+ if (map != null) {
+ map.onFollowMyLocationClicked();
+ }
}
}
- @Override
- public void onDrag() {
+ private void onFollowMyLocationClicked() {
+ followMyLocation = !followMyLocation;
+ switchMyLocationButton();
+ }
+
+ public static class MapDragListener implements OnMapDragListener {
+
+ private final WeakReference<CGeoMap> mapRef;
+
+ public MapDragListener(@NonNull final CGeoMap map) {
+ mapRef = new WeakReference<CGeoMap>(map);
+ }
+
+ @Override
+ public void onDrag() {
+ final CGeoMap map = mapRef.get();
+ if (map != null) {
+ map.onDrag();
+ }
+ }
+
+ }
+
+ private void onDrag() {
if (followMyLocation) {
followMyLocation = false;
switchMyLocationButton();
@@ -1491,15 +1673,9 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
return mapItemFactory.getGeoPointBase(coords);
}
- // close activity and open homescreen
- @Override
- public void goHome(View view) {
- ActivityMixin.goHome(activity);
- }
-
@Override
public View makeView() {
- ImageView imageView = new ImageView(activity);
+ final ImageView imageView = new ImageView(activity);
imageView.setScaleType(ScaleType.CENTER);
imageView.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
return imageView;
@@ -1637,7 +1813,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
private CachesOverlayItemImpl getWaypointItem(final Waypoint waypoint) {
final CachesOverlayItemImpl item = mapItemFactory.getCachesOverlayItem(waypoint, waypoint.getWaypointType().applyDistanceRule());
- Drawable marker = getResources().getDrawable(!waypoint.isVisited() ? R.drawable.marker : R.drawable.marker_transparent);
+ final Drawable marker = getResources().getDrawable(!waypoint.isVisited() ? R.drawable.marker : R.drawable.marker_transparent);
final Drawable[] layers = new Drawable[] {
marker,
getResources().getDrawable(waypoint.getWaypointType().markerId)
diff --git a/main/src/cgeo/geocaching/maps/CachesOverlay.java b/main/src/cgeo/geocaching/maps/CachesOverlay.java
index 0c7c296..8607c88 100644
--- a/main/src/cgeo/geocaching/maps/CachesOverlay.java
+++ b/main/src/cgeo/geocaching/maps/CachesOverlay.java
@@ -211,9 +211,9 @@ public class CachesOverlay extends AbstractItemizedOverlay {
progress.show(context, context.getResources().getString(R.string.map_live), context.getResources().getString(R.string.cache_dialog_loading_details), true, null);
- CachesOverlayItemImpl item = null;
// prevent concurrent changes
getOverlayImpl().lock();
+ CachesOverlayItemImpl item = null;
try {
if (index < items.size()) {
item = items.get(index);
diff --git a/main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java b/main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java
index 6b34b75..63fcd73 100644
--- a/main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java
+++ b/main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java
@@ -5,7 +5,6 @@ import cgeo.geocaching.maps.interfaces.MapProjectionImpl;
import cgeo.geocaching.maps.interfaces.MapViewImpl;
import cgeo.geocaching.maps.interfaces.OverlayImpl;
-import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.Point;
import android.location.Location;
@@ -18,10 +17,10 @@ public class PositionAndScaleOverlay implements GeneralOverlay {
PositionDrawer positionDrawer = null;
ScaleDrawer scaleDrawer = null;
- public PositionAndScaleOverlay(Activity activity, OverlayImpl ovlImpl) {
+ public PositionAndScaleOverlay(OverlayImpl ovlImpl) {
this.ovlImpl = ovlImpl;
- positionDrawer = new PositionDrawer(activity);
- scaleDrawer = new ScaleDrawer(activity);
+ positionDrawer = new PositionDrawer();
+ scaleDrawer = new ScaleDrawer();
}
public void setCoordinates(Location coordinatesIn) {
diff --git a/main/src/cgeo/geocaching/maps/PositionDrawer.java b/main/src/cgeo/geocaching/maps/PositionDrawer.java
index 1a5dcaf..0e20e7c 100644
--- a/main/src/cgeo/geocaching/maps/PositionDrawer.java
+++ b/main/src/cgeo/geocaching/maps/PositionDrawer.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.maps;
+import cgeo.geocaching.CgeoApplication;
import cgeo.geocaching.R;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.maps.interfaces.GeoPointImpl;
@@ -7,7 +8,6 @@ import cgeo.geocaching.maps.interfaces.MapItemFactory;
import cgeo.geocaching.maps.interfaces.MapProjectionImpl;
import cgeo.geocaching.settings.Settings;
-import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
@@ -36,11 +36,9 @@ public class PositionDrawer {
private PaintFlagsDrawFilter setfil = null;
private PaintFlagsDrawFilter remfil = null;
private PositionHistory positionHistory = new PositionHistory();
- private Activity activity;
private MapItemFactory mapItemFactory;
- public PositionDrawer(Activity activity) {
- this.activity = activity;
+ public PositionDrawer() {
this.mapItemFactory = Settings.getMapProvider().getMapItemFactory();
}
@@ -144,7 +142,7 @@ public class PositionDrawer {
}
if (arrow == null) {
- arrow = BitmapFactory.decodeResource(activity.getResources(), R.drawable.my_location_chevron);
+ arrow = BitmapFactory.decodeResource(CgeoApplication.getInstance().getResources(), R.drawable.my_location_chevron);
widthArrowHalf = arrow.getWidth() / 2;
heightArrowHalf = arrow.getHeight() / 2;
}
diff --git a/main/src/cgeo/geocaching/maps/ScaleDrawer.java b/main/src/cgeo/geocaching/maps/ScaleDrawer.java
index fb46408..95c987d 100644
--- a/main/src/cgeo/geocaching/maps/ScaleDrawer.java
+++ b/main/src/cgeo/geocaching/maps/ScaleDrawer.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.maps;
+import cgeo.geocaching.CgeoApplication;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.geopoint.Units;
import cgeo.geocaching.maps.interfaces.GeoPointImpl;
@@ -7,12 +8,13 @@ import cgeo.geocaching.maps.interfaces.MapViewImpl;
import org.apache.commons.lang3.tuple.ImmutablePair;
-import android.app.Activity;
+import android.content.Context;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.util.DisplayMetrics;
+import android.view.WindowManager;
public class ScaleDrawer {
private static final double SCALE_WIDTH_FACTOR = 1.0 / 2.5;
@@ -22,9 +24,10 @@ public class ScaleDrawer {
private BlurMaskFilter blur = null;
private float pixelDensity = 0;
- public ScaleDrawer(Activity activity) {
+ public ScaleDrawer() {
DisplayMetrics metrics = new DisplayMetrics();
- activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
+ WindowManager windowManager = (WindowManager) CgeoApplication.getInstance().getSystemService(Context.WINDOW_SERVICE);
+ windowManager.getDefaultDisplay().getMetrics(metrics);
pixelDensity = metrics.density;
}
diff --git a/main/src/cgeo/geocaching/maps/google/GoogleMapActivity.java b/main/src/cgeo/geocaching/maps/google/GoogleMapActivity.java
index a98241f..2a29cc9 100644
--- a/main/src/cgeo/geocaching/maps/google/GoogleMapActivity.java
+++ b/main/src/cgeo/geocaching/maps/google/GoogleMapActivity.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.maps.google;
+import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.activity.FilteredActivity;
import cgeo.geocaching.maps.AbstractMap;
import cgeo.geocaching.maps.CGeoMap;
@@ -97,6 +98,11 @@ public class GoogleMapActivity extends MapActivity implements MapActivityImpl, F
}
@Override
+ public void navigateUp(View view) {
+ ActivityMixin.navigateUp(this);
+ }
+
+ @Override
public void superOnResume() {
super.onResume();
}
@@ -116,12 +122,6 @@ public class GoogleMapActivity extends MapActivity implements MapActivityImpl, F
return super.onPrepareOptionsMenu(menu);
}
- // close activity and open homescreen
- @Override
- public void goHome(View view) {
- mapBase.goHome(view);
- }
-
@Override
public void showFilterMenu(View view) {
// do nothing, the filter bar only shows the global filter
diff --git a/main/src/cgeo/geocaching/maps/google/GoogleMapView.java b/main/src/cgeo/geocaching/maps/google/GoogleMapView.java
index 610dbe1..ea815ab 100644
--- a/main/src/cgeo/geocaching/maps/google/GoogleMapView.java
+++ b/main/src/cgeo/geocaching/maps/google/GoogleMapView.java
@@ -20,7 +20,6 @@ import com.google.android.maps.MapView;
import org.apache.commons.lang3.reflect.MethodUtils;
import org.eclipse.jdt.annotation.NonNull;
-import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
@@ -39,16 +38,23 @@ public class GoogleMapView extends MapView implements MapViewImpl {
public GoogleMapView(Context context, AttributeSet attrs) {
super(context, attrs);
- gestureDetector = new GestureDetector(context, new GestureListener());
+ initialize(context);
}
public GoogleMapView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- gestureDetector = new GestureDetector(context, new GestureListener());
+ initialize(context);
}
public GoogleMapView(Context context, String apiKey) {
super(context, apiKey);
+ initialize(context);
+ }
+
+ private void initialize(Context context) {
+ if (isInEditMode()) {
+ return;
+ }
gestureDetector = new GestureDetector(context, new GestureListener());
}
@@ -120,9 +126,9 @@ public class GoogleMapView extends MapView implements MapViewImpl {
}
@Override
- public PositionAndScaleOverlay createAddPositionAndScaleOverlay(Activity activity) {
+ public PositionAndScaleOverlay createAddPositionAndScaleOverlay() {
- GoogleOverlay ovl = new GoogleOverlay(activity);
+ GoogleOverlay ovl = new GoogleOverlay();
getOverlays().add(ovl);
return (PositionAndScaleOverlay) ovl.getBase();
}
diff --git a/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java b/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java
index 0a5cf69..c684b9a 100644
--- a/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java
+++ b/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java
@@ -8,7 +8,6 @@ import cgeo.geocaching.maps.interfaces.OverlayImpl;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
-import android.app.Activity;
import android.graphics.Canvas;
import java.util.concurrent.locks.Lock;
@@ -19,8 +18,8 @@ public class GoogleOverlay extends Overlay implements OverlayImpl {
private PositionAndScaleOverlay overlayBase = null;
private Lock lock = new ReentrantLock();
- public GoogleOverlay(Activity activityIn) {
- overlayBase = new PositionAndScaleOverlay(activityIn, this);
+ public GoogleOverlay() {
+ overlayBase = new PositionAndScaleOverlay(this);
}
@Override
diff --git a/main/src/cgeo/geocaching/maps/interfaces/MapActivityImpl.java b/main/src/cgeo/geocaching/maps/interfaces/MapActivityImpl.java
index e7deebd..3596d5f 100644
--- a/main/src/cgeo/geocaching/maps/interfaces/MapActivityImpl.java
+++ b/main/src/cgeo/geocaching/maps/interfaces/MapActivityImpl.java
@@ -33,6 +33,5 @@ public interface MapActivityImpl {
boolean superOnOptionsItemSelected(MenuItem item);
- public abstract void goHome(View view);
-
+ public abstract void navigateUp(View view);
}
diff --git a/main/src/cgeo/geocaching/maps/interfaces/MapViewImpl.java b/main/src/cgeo/geocaching/maps/interfaces/MapViewImpl.java
index 5ae8e15..4a6d733 100644
--- a/main/src/cgeo/geocaching/maps/interfaces/MapViewImpl.java
+++ b/main/src/cgeo/geocaching/maps/interfaces/MapViewImpl.java
@@ -6,7 +6,6 @@ import cgeo.geocaching.maps.PositionAndScaleOverlay;
import org.eclipse.jdt.annotation.NonNull;
-import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
@@ -47,7 +46,7 @@ public interface MapViewImpl {
CachesOverlay createAddMapOverlay(Context context, Drawable drawable);
- PositionAndScaleOverlay createAddPositionAndScaleOverlay(Activity activity);
+ PositionAndScaleOverlay createAddPositionAndScaleOverlay();
void setMapSource();
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapActivity.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapActivity.java
index a0384b8..94213ba 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapActivity.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapActivity.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.maps.mapsforge;
+import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.activity.FilteredActivity;
import cgeo.geocaching.maps.AbstractMap;
import cgeo.geocaching.maps.CGeoMap;
@@ -111,10 +112,9 @@ public class MapsforgeMapActivity extends MapActivity implements MapActivityImpl
return super.onPrepareOptionsMenu(menu);
}
- // close activity and open homescreen
@Override
- public void goHome(View view) {
- mapBase.goHome(view);
+ public void navigateUp(View view) {
+ ActivityMixin.navigateUp(this);
}
@Override
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java
index 7a5aab2..d95cc80 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java
@@ -24,7 +24,6 @@ import org.mapsforge.android.maps.mapgenerator.MapGeneratorInternal;
import org.mapsforge.android.maps.overlay.Overlay;
import org.mapsforge.core.GeoPoint;
-import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
@@ -43,6 +42,13 @@ public class MapsforgeMapView extends MapView implements MapViewImpl {
public MapsforgeMapView(Context context, AttributeSet attrs) {
super(context, attrs);
+ initialize(context);
+ }
+
+ private void initialize(Context context) {
+ if (isInEditMode()) {
+ return;
+ }
gestureDetector = new GestureDetector(context, new GestureListener());
if (Settings.isScaleMapsforgeText()) {
this.setTextScale(getResources().getDisplayMetrics().density);
@@ -105,8 +111,8 @@ public class MapsforgeMapView extends MapView implements MapViewImpl {
}
@Override
- public PositionAndScaleOverlay createAddPositionAndScaleOverlay(Activity activity) {
- MapsforgeOverlay ovl = new MapsforgeOverlay(activity);
+ public PositionAndScaleOverlay createAddPositionAndScaleOverlay() {
+ MapsforgeOverlay ovl = new MapsforgeOverlay();
getOverlays().add(ovl);
return (PositionAndScaleOverlay) ovl.getBase();
}
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java
index 74a8601..3df4ab0 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java
@@ -8,7 +8,6 @@ import cgeo.geocaching.maps.interfaces.OverlayImpl;
import org.mapsforge.android.maps.Projection;
import org.mapsforge.android.maps.overlay.Overlay;
-import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.Point;
@@ -20,8 +19,8 @@ public class MapsforgeOverlay extends Overlay implements OverlayImpl {
private PositionAndScaleOverlay overlayBase = null;
private Lock lock = new ReentrantLock();
- public MapsforgeOverlay(Activity activityIn) {
- overlayBase = new PositionAndScaleOverlay(activityIn, this);
+ public MapsforgeOverlay() {
+ overlayBase = new PositionAndScaleOverlay(this);
}
@Override
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapActivity024.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapActivity024.java
index 33ed30e..daeb2b8 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapActivity024.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapActivity024.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.maps.mapsforge.v024;
+import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.activity.FilteredActivity;
import cgeo.geocaching.maps.AbstractMap;
import cgeo.geocaching.maps.CGeoMap;
@@ -111,10 +112,9 @@ public class MapsforgeMapActivity024 extends MapActivity implements MapActivityI
return super.onPrepareOptionsMenu(menu);
}
- // close activity and open homescreen
@Override
- public void goHome(View view) {
- mapBase.goHome(view);
+ public void navigateUp(View view) {
+ ActivityMixin.navigateUp(this);
}
@Override
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java
index 4fa4e02..8dd15fc 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java
@@ -21,7 +21,6 @@ import org.mapsforge.android.mapsold.MapViewMode;
import org.mapsforge.android.mapsold.Overlay;
import org.mapsforge.android.mapsold.Projection;
-import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
@@ -37,6 +36,13 @@ public class MapsforgeMapView024 extends MapView implements MapViewImpl {
public MapsforgeMapView024(Context context, AttributeSet attrs) {
super(context, attrs);
+ initialize(context);
+ }
+
+ private void initialize(Context context) {
+ if (isInEditMode()) {
+ return;
+ }
gestureDetector = new GestureDetector(context, new GestureListener());
}
@@ -96,8 +102,8 @@ public class MapsforgeMapView024 extends MapView implements MapViewImpl {
}
@Override
- public PositionAndScaleOverlay createAddPositionAndScaleOverlay(Activity activity) {
- MapsforgeOverlay ovl = new MapsforgeOverlay(activity);
+ public PositionAndScaleOverlay createAddPositionAndScaleOverlay() {
+ MapsforgeOverlay ovl = new MapsforgeOverlay();
getOverlays().add(ovl);
return (PositionAndScaleOverlay) ovl.getBase();
}
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java
index 655e0b9..bfb3548 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java
@@ -8,7 +8,6 @@ import cgeo.geocaching.maps.interfaces.OverlayImpl;
import org.mapsforge.android.mapsold.Overlay;
import org.mapsforge.android.mapsold.Projection;
-import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.Point;
@@ -20,8 +19,8 @@ public class MapsforgeOverlay extends Overlay implements OverlayImpl {
private PositionAndScaleOverlay overlayBase = null;
private Lock lock = new ReentrantLock();
- public MapsforgeOverlay(Activity activityIn) {
- overlayBase = new PositionAndScaleOverlay(activityIn, this);
+ public MapsforgeOverlay() {
+ overlayBase = new PositionAndScaleOverlay(this);
}
@Override