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