diff options
| author | Bananeweizen <Bananeweizen@gmx.de> | 2012-07-20 09:07:52 -0700 |
|---|---|---|
| committer | Bananeweizen <Bananeweizen@gmx.de> | 2012-07-20 09:07:52 -0700 |
| commit | 9ca1feffb7476edb91f4a81a2200631fa4f7ed2d (patch) | |
| tree | 51e6c935e8c00ca611e356431098c31a348f824f /main | |
| parent | 51883312e45c97f52aa74f669c1bab96643c450a (diff) | |
| parent | a9076cead14617171d2d89f89935f1dde9504522 (diff) | |
| download | cgeo-9ca1feffb7476edb91f4a81a2200631fa4f7ed2d.zip cgeo-9ca1feffb7476edb91f4a81a2200631fa4f7ed2d.tar.gz cgeo-9ca1feffb7476edb91f4a81a2200631fa4f7ed2d.tar.bz2 | |
Merge pull request #1897 from Portree-Kid/Fix1866
Added Filter to loading of waypoints fixes #1866
Diffstat (limited to 'main')
| -rw-r--r-- | main/src/cgeo/geocaching/cgData.java | 8 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeoapplication.java | 4 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/maps/CGeoMap.java | 9 |
3 files changed, 14 insertions, 7 deletions
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java index f219835..ff2653b 100644 --- a/main/src/cgeo/geocaching/cgData.java +++ b/main/src/cgeo/geocaching/cgData.java @@ -66,7 +66,7 @@ public class cgData { private static final String[] WAYPOINT_COLUMNS = new String[] { "_id", "geocode", "updated", "type", "prefix", "lookup", "name", "latlon", "latitude", "longitude", "note", "own" }; /** Number of days (as ms) after temporarily saved caches are deleted */ - private static long DAYS_AFTER_CACHE_IS_DELETED = 3 * 24 * 60 * 60 * 1000; + private final static long DAYS_AFTER_CACHE_IS_DELETED = 3 * 24 * 60 * 60 * 1000; /** * holds the column indexes of the cache table to avoid lookups @@ -2929,10 +2929,11 @@ public class cgData { * * @param excludeDisabled * @param excludeMine + * @param type * @return */ - public Set<cgWaypoint> loadWaypoints(final Viewport viewport, boolean excludeMine, boolean excludeDisabled) { + public Set<cgWaypoint> loadWaypoints(final Viewport viewport, boolean excludeMine, boolean excludeDisabled, CacheType type) { final StringBuilder where = new StringBuilder(buildCoordinateWhere(dbTableWaypoints, viewport)); if (excludeMine) { where.append(" and ").append(dbTableCaches).append(".own == 0 and ").append(dbTableCaches).append(".found == 0"); @@ -2940,6 +2941,9 @@ public class cgData { if (excludeDisabled) { where.append(" and ").append(dbTableCaches).append(".disabled == 0"); } + if (type != CacheType.ALL) { + where.append(" and ").append(dbTableCaches).append(".type == '").append(type.id).append("'"); + } init(); final StringBuilder query = new StringBuilder("SELECT "); diff --git a/main/src/cgeo/geocaching/cgeoapplication.java b/main/src/cgeo/geocaching/cgeoapplication.java index 0860930..137fe30 100644 --- a/main/src/cgeo/geocaching/cgeoapplication.java +++ b/main/src/cgeo/geocaching/cgeoapplication.java @@ -490,8 +490,8 @@ public class cgeoapplication extends Application { storage.removeCaches(geocodes, removeFlags); } - public Set<cgWaypoint> getWaypointsInViewport(final Viewport viewport, boolean excludeMine, boolean excludeDisabled) { - return storage.loadWaypoints(viewport, excludeMine, excludeDisabled); + public Set<cgWaypoint> getWaypointsInViewport(final Viewport viewport, boolean excludeMine, boolean excludeDisabled, CacheType type) { + return storage.loadWaypoints(viewport, excludeMine, excludeDisabled, type); } public boolean isLiveMapHintShown() { diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 062f02f..c4d2192 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -1187,9 +1187,12 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto waypoints.clear(); if (isLiveMode() || mapMode == MapMode.COORDS) { //All visible waypoints - //FIXME apply type filter - waypoints.addAll(app.getWaypointsInViewport(viewport, Settings.isExcludeMyCaches(), Settings.isExcludeDisabledCaches())); - } else { + CacheType type = Settings.getCacheType(); + Set<cgWaypoint> waypointsInViewport = app.getWaypointsInViewport(viewport, Settings.isExcludeMyCaches(), Settings.isExcludeDisabledCaches(), type); + waypoints.addAll(waypointsInViewport); + } + else + { //All waypoints from the viewed caches for (cgCache c : caches.getAsList()) { waypoints.addAll(c.getWaypoints()); |
