clean up
* animated marker onTap removed, * bg loc function removed * todos updated
This commit is contained in:
parent
2b53506651
commit
61f94c7beb
@ -1,30 +1,19 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.mapbox.android.core.permissions.PermissionsListener;
|
||||
import com.mapbox.android.core.permissions.PermissionsManager;
|
||||
@ -48,7 +37,6 @@ import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
@ -56,7 +44,6 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
@ -64,7 +51,6 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
||||
import com.uam.wmi.findmytutor.service.CoordinateService;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||
@ -145,28 +131,11 @@ public class MapActivity extends BaseActivity
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
MapActivity.this.mapboxMap = mapboxMap;
|
||||
enableLocationPlugin();
|
||||
|
||||
// TODO floating marker to remove later
|
||||
final Marker marker = mapboxMap.addMarker(new MarkerViewOptions()
|
||||
.position(new LatLng(52.466782, 16.927549)));
|
||||
mStatusChecker.run();
|
||||
|
||||
mapboxMap.addOnMapClickListener(point -> {
|
||||
|
||||
// When the user clicks on the map, we want to animate the marker to that
|
||||
// location.
|
||||
ValueAnimator markerAnimator = ObjectAnimator.ofObject(marker, "position",
|
||||
new mapUtils.LatLngEvaluator(), marker.getPosition(), point);
|
||||
markerAnimator.setDuration(2000);
|
||||
markerAnimator.start();
|
||||
});
|
||||
|
||||
|
||||
// // TODO what should happend on click?
|
||||
// mapboxMap.setOnMarkerClickListener(marker1 -> {
|
||||
@ -213,8 +182,6 @@ public class MapActivity extends BaseActivity
|
||||
|
||||
|
||||
// TODO PUT MANUAL CORD
|
||||
|
||||
|
||||
try {
|
||||
Coordinate coordinate = new Coordinate(
|
||||
latLng.getLatitude(),
|
||||
@ -268,8 +235,6 @@ public class MapActivity extends BaseActivity
|
||||
} else {
|
||||
|
||||
// TODO REMOVE Manual Locatio
|
||||
|
||||
|
||||
mapboxMap.removeMarker(droppedMarker);
|
||||
droppedMarker = null;
|
||||
|
||||
@ -355,7 +320,7 @@ public class MapActivity extends BaseActivity
|
||||
Log.e(tag, "replace and animate");
|
||||
Marker marker = markerHash.get(id);
|
||||
LatLng toDestination = new LatLng(element.getLatitude(), element.getLongitude());
|
||||
|
||||
// TODO fix flickiering markers
|
||||
ValueAnimator markerAnimator = ObjectAnimator.ofObject(marker, "position",
|
||||
new mapUtils.LatLngEvaluator(),
|
||||
marker.getPosition(),
|
||||
@ -483,8 +448,6 @@ public class MapActivity extends BaseActivity
|
||||
// Get an instance of the component
|
||||
locationComponent = mapboxMap.getLocationComponent();
|
||||
|
||||
// TODO tu jest lepsza lokalizacja(chyba)
|
||||
// locationComponent.getLastKnownLocation();
|
||||
//Log.e(tag + "Last", locationComponent.getLastKnownLocation() + "");
|
||||
|
||||
// Activate with options
|
||||
@ -515,6 +478,7 @@ public class MapActivity extends BaseActivity
|
||||
.newCameraPosition(position), 4000);
|
||||
}
|
||||
|
||||
// Camera aniamtion
|
||||
zoomParam = (zoomParam == 17) ? 19 : 17;
|
||||
bearingParam += 90;
|
||||
tiltParam = (tiltParam == 30) ? 0 : 30;
|
||||
@ -545,26 +509,4 @@ public class MapActivity extends BaseActivity
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Location getLastKnownLocation() {
|
||||
mLocationManager = (LocationManager) getApplicationContext().getSystemService(LOCATION_SERVICE);
|
||||
List<String> providers = mLocationManager.getProviders(true);
|
||||
Location bestLocation = null;
|
||||
for (String provider : providers) {
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
permissionsManager = new PermissionsManager(this);
|
||||
permissionsManager.requestLocationPermissions(this);
|
||||
}
|
||||
Location l = mLocationManager.getLastKnownLocation(provider);
|
||||
if (l == null) {
|
||||
continue;
|
||||
}
|
||||
if (bestLocation == null || l.getAccuracy() < bestLocation.getAccuracy()) {
|
||||
// Found best last known location: %s", l);
|
||||
bestLocation = l;
|
||||
}
|
||||
}
|
||||
return bestLocation;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user