manual location fixing

This commit is contained in:
Adam Domagalski 2018-11-17 17:46:27 +01:00
parent fd9cb37fb3
commit c04373a59c

View File

@ -90,6 +90,7 @@ public class MapActivity extends BaseActivity
private MapView mapView;
private MapboxMap mapboxMap;
private Marker droppedMarker;
private Coordinate droppedMarkercoordinate;
private HashMap<String, Coordinate> coordsMap = new HashMap<>();
private HashMap<String, Marker> markerHash = new HashMap<>();
private Set<String> previousCoordsIds = new HashSet<>();
@ -208,7 +209,6 @@ public class MapActivity extends BaseActivity
selectLocationButton.setVisibility(View.VISIBLE);
Icon icon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.green_marker);
if (droppedMarker == null) {
droppedMarker = mapboxMap.addMarker(new MarkerOptions()
@ -232,7 +232,7 @@ public class MapActivity extends BaseActivity
// TODO PUT MANUAL CORD
try {
Coordinate coordinate = new Coordinate(
droppedMarkercoordinate = new Coordinate(
latLng.getLatitude(),
latLng.getLongitude(),
latLng.getAltitude(),
@ -243,7 +243,7 @@ public class MapActivity extends BaseActivity
disposable.add(
coordinateService
.postCoordinate(coordinate)
.postCoordinate(droppedMarkercoordinate)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<Coordinate>() {
@ -284,9 +284,10 @@ public class MapActivity extends BaseActivity
cancel[0] = true;
} else {
// TODO REMOVE Manual Locatio
// TODO REMOVE Manual Location
mapboxMap.removeMarker(droppedMarker);
droppedMarker = null;
droppedMarkercoordinate = null;
Toast.makeText(
MapActivity.this,
@ -338,6 +339,7 @@ public class MapActivity extends BaseActivity
private void fetchTopCoords() {
disposable.add(
// coordinateService.getTopCoordinates()
coordinateService.getOnlineCoordinates()
@ -348,12 +350,18 @@ public class MapActivity extends BaseActivity
@Override
public void onSuccess(List<Coordinate> coordsList) {
if (coordsList.isEmpty()) {
Log.e(tag, "200 empty []");
//mapboxMap.clear();
return;
if (droppedMarker != null) {
coordsList.add(droppedMarkercoordinate);
}
if (coordsList.isEmpty() && droppedMarker == null) {
Log.e(tag, "200 empty []");
mapboxMap.clear();
return();
}
ArrayList<String> tmp = new ArrayList<>();
for (Coordinate coordinate : coordsList) {