Fix bug on set found object button.
This commit is contained in:
parent
443a7179e8
commit
ed6e900282
|
|
@ -231,19 +231,22 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
}
|
||||
|
||||
private void markAsFound() {
|
||||
WayPointLocation wpl = serviceGps.foundNearObject();
|
||||
if (wpl != null) {
|
||||
wpl.setFound();
|
||||
for (Overlay o : map.getOverlays()) {
|
||||
if (o instanceof Marker) {
|
||||
Marker marker = (Marker) o;
|
||||
GeoPoint gp = marker.getPosition();
|
||||
if (wpl.isEquals(gp.getLatitude(), gp.getLongitude())) {
|
||||
marker.setIcon(getResources().getDrawable(R.drawable.ic_marker_blue));
|
||||
marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
|
||||
break;
|
||||
List<WayPointLocation> wpls = serviceGps.foundNearObjects();
|
||||
for (WayPointLocation wpl: wpls) {
|
||||
if (wpl != null && !wpl.isFound()) {
|
||||
wpl.setFound();
|
||||
for (Overlay o : map.getOverlays()) {
|
||||
if (o instanceof Marker) {
|
||||
Marker marker = (Marker) o;
|
||||
GeoPoint gp = marker.getPosition();
|
||||
if (wpl.isEquals(gp.getLatitude(), gp.getLongitude())) {
|
||||
marker.setIcon(getResources().getDrawable(R.drawable.ic_marker_blue));
|
||||
marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
|
|
@ -168,12 +169,12 @@ public class ServiceGps extends Observable implements IServiceGps, LocationListe
|
|||
return traces.getPoint(lat, lon);
|
||||
}
|
||||
|
||||
public WayPointLocation foundNearObject() {
|
||||
WayPointLocation ret = null;
|
||||
public List<WayPointLocation> foundNearObjects() {
|
||||
List<WayPointLocation> ret = new ArrayList<>();
|
||||
MyLocation curLoc = currentLocation;
|
||||
for (MyLocation ml: getListGeoPointObjects()) {
|
||||
if (curLoc.distanceTo(ml) < 10 && ml instanceof WayPointLocation) {
|
||||
ret = (WayPointLocation) ml;
|
||||
ret.add((WayPointLocation) ml);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Reference in New Issue