animacja markera, + stary zostaje
This commit is contained in:
parent
dc0af04e5d
commit
9162c7fd34
@ -18,7 +18,7 @@
|
|||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.StartupActivity"
|
android:name=".activity.StartupActivity"
|
||||||
android:label="@string/title_activity_startup"
|
android:label="@string/app_name"
|
||||||
android:launchMode="singleInstance"
|
android:launchMode="singleInstance"
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -1,17 +1,27 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
package com.uam.wmi.findmytutor.activity;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.ActivityCompat;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.mapbox.mapboxsdk.Mapbox;
|
import com.mapbox.mapboxsdk.Mapbox;
|
||||||
import com.mapbox.mapboxsdk.maps.MapView;
|
import com.mapbox.mapboxsdk.maps.MapView;
|
||||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
|
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
||||||
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
|
|
||||||
|
|
||||||
public class MapActivity extends BaseActivity {
|
public class MapActivity extends BaseActivity {
|
||||||
private MapView mapView;
|
private MapView mapView;
|
||||||
String tag = "LifeCycleEvents";
|
String tag = "LifeCycleEvents";
|
||||||
|
private static final int REQUEST_PERMISSIONS = 100;
|
||||||
|
private boolean isTutor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -20,6 +30,11 @@ public class MapActivity extends BaseActivity {
|
|||||||
mapView = findViewById(R.id.mapView);
|
mapView = findViewById(R.id.mapView);
|
||||||
mapView.onCreate(savedInstanceState);
|
mapView.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
isTutor = PrefUtils.getIsTutor(getApplicationContext());
|
||||||
|
if (isTutor) {
|
||||||
|
fn_permission();
|
||||||
|
}
|
||||||
|
|
||||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onMapReady(MapboxMap mapboxMap) {
|
public void onMapReady(MapboxMap mapboxMap) {
|
||||||
@ -75,6 +90,34 @@ public class MapActivity extends BaseActivity {
|
|||||||
mapView.onSaveInstanceState(outState);
|
mapView.onSaveInstanceState(outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fn_permission() {
|
||||||
|
if ((ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
|
||||||
|
|
||||||
|
if ((ActivityCompat.shouldShowRequestPermissionRationale(MapActivity.this, android.Manifest.permission.ACCESS_FINE_LOCATION))) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ActivityCompat.requestPermissions(MapActivity.this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION
|
||||||
|
|
||||||
|
},
|
||||||
|
REQUEST_PERMISSIONS);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (isTutor) {
|
||||||
|
Intent intent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
startForegroundService(intent);
|
||||||
|
} else {
|
||||||
|
startService(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Toast.makeText(getApplicationContext(), "Please enable the gps", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getContentViewId() {
|
protected int getContentViewId() {
|
||||||
return R.layout.activity_map;
|
return R.layout.activity_map;
|
||||||
|
@ -158,11 +158,16 @@ public class NotificationsActivity extends BaseActivity implements
|
|||||||
for (Coordinate element : coordsList) {
|
for (Coordinate element : coordsList) {
|
||||||
String id = element.getUserId();
|
String id = element.getUserId();
|
||||||
Coordinate cord = coordsMap.get(id);
|
Coordinate cord = coordsMap.get(id);
|
||||||
|
|
||||||
|
|
||||||
|
Log.d("mapper", "a " + mapboxMap.getMarkerViewManager());
|
||||||
|
Log.d("mapper", "b " + coordsMap.size());
|
||||||
if (cord != null) {
|
if (cord != null) {
|
||||||
if (!cord.getLongitude().equals(element.getLongitude())
|
if (!cord.getLongitude().equals(element.getLongitude())
|
||||||
) {
|
) {
|
||||||
Log.d("mapper", " cos sie zienilo ");
|
Log.d("mapper", " cos sie zienilo ");
|
||||||
Marker marker = mapboxMap.addMarker(new MarkerViewOptions()
|
Marker marker = mapboxMap.addMarker(new MarkerViewOptions()
|
||||||
|
.title(cord.getUserId())
|
||||||
.position(new LatLng(cord.getLatitude(),cord.getLongitude())));
|
.position(new LatLng(cord.getLatitude(),cord.getLongitude())));
|
||||||
|
|
||||||
ValueAnimator markerAnimator = ObjectAnimator.ofObject(marker, "position",
|
ValueAnimator markerAnimator = ObjectAnimator.ofObject(marker, "position",
|
||||||
@ -170,12 +175,12 @@ public class NotificationsActivity extends BaseActivity implements
|
|||||||
markerAnimator.setDuration(2000);
|
markerAnimator.setDuration(2000);
|
||||||
markerAnimator.start();
|
markerAnimator.start();
|
||||||
|
|
||||||
coordsMap.put(id,element);
|
coordsMap.replace(id,element);
|
||||||
} else if (!cord.getTimeStamp().equals(element.getTimeStamp())){
|
} else if (!cord.getTimeStamp().equals(element.getTimeStamp())){
|
||||||
Log.d("mapper", "update");
|
Log.d("mapper", "update");
|
||||||
Log.d("mapper", " "+cord.getTimeStamp());
|
Log.d("mapper", " "+cord.getTimeStamp());
|
||||||
Log.d("mapper", " "+element.getTimeStamp());
|
Log.d("mapper", " "+element.getTimeStamp());
|
||||||
coordsMap.put(id,element);
|
coordsMap.replace(id,element);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
coordsMap.put(id,element);
|
coordsMap.put(id,element);
|
||||||
|
Loading…
Reference in New Issue
Block a user