Fix bug on set found object button.

This commit is contained in:
Chteufleur 2018-08-22 19:34:32 +02:00
parent 443a7179e8
commit ed6e900282
2 changed files with 18 additions and 14 deletions

View File

@ -231,8 +231,9 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
} }
private void markAsFound() { private void markAsFound() {
WayPointLocation wpl = serviceGps.foundNearObject(); List<WayPointLocation> wpls = serviceGps.foundNearObjects();
if (wpl != null) { for (WayPointLocation wpl: wpls) {
if (wpl != null && !wpl.isFound()) {
wpl.setFound(); wpl.setFound();
for (Overlay o : map.getOverlays()) { for (Overlay o : map.getOverlays()) {
if (o instanceof Marker) { if (o instanceof Marker) {
@ -245,6 +246,8 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
} }
} }
} }
break;
}
} }
} }

View File

@ -13,6 +13,7 @@ import org.xmlpull.v1.XmlPullParserException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Observable; import java.util.Observable;
@ -168,12 +169,12 @@ public class ServiceGps extends Observable implements IServiceGps, LocationListe
return traces.getPoint(lat, lon); return traces.getPoint(lat, lon);
} }
public WayPointLocation foundNearObject() { public List<WayPointLocation> foundNearObjects() {
WayPointLocation ret = null; List<WayPointLocation> ret = new ArrayList<>();
MyLocation curLoc = currentLocation; MyLocation curLoc = currentLocation;
for (MyLocation ml: getListGeoPointObjects()) { for (MyLocation ml: getListGeoPointObjects()) {
if (curLoc.distanceTo(ml) < 10 && ml instanceof WayPointLocation) { if (curLoc.distanceTo(ml) < 10 && ml instanceof WayPointLocation) {
ret = (WayPointLocation) ml; ret.add((WayPointLocation) ml);
} }
} }
return ret; return ret;