Add predifined

This commit is contained in:
Mieszko Wrzeszczyński 2018-11-27 00:00:37 +01:00
parent 3a2c4f10d4
commit ba67a8b088
3 changed files with 17 additions and 29 deletions

View File

@ -40,11 +40,6 @@ import com.mapbox.mapboxsdk.location.modes.RenderMode;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.Coordinate;
import com.uam.wmi.findmytutor.model.User;
@ -57,10 +52,6 @@ import com.uam.wmi.findmytutor.utils.RestApiHelper;
import com.uam.wmi.findmytutor.utils.SharingLevel;
import com.uam.wmi.findmytutor.utils.mapUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@ -74,23 +65,6 @@ import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.expressions.Expression.all;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.gt;
import static com.mapbox.mapboxsdk.style.expressions.Expression.gte;
import static com.mapbox.mapboxsdk.style.expressions.Expression.has;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.lt;
import static com.mapbox.mapboxsdk.style.expressions.Expression.toNumber;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAllowOverlap;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textIgnorePlacement;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize;
public class MapActivity extends BaseActivity
implements PermissionsListener, OnMapReadyCallback {
@ -378,7 +352,7 @@ public class MapActivity extends BaseActivity
if (coordsList.isEmpty() && tmpLocalMarker != null) {
Timber.e("200 empty []");
mapboxMap.clear();
return;
}
ArrayList<String> tmp = new ArrayList<>();
@ -491,6 +465,18 @@ public class MapActivity extends BaseActivity
// For next fetch
previousCoordsIds.clear();
previousCoordsIds.addAll(currentCoordsIds);
for (Coordinate coordinate : coordsMap.values()) {
// 300000 = 5mins
if ((System.currentTimeMillis() - coordinate.getTimeStamp()) > (long) 300000) {
String id = coordinate.getUserId();
Marker markerToRemove = markerHash.get(id).getMarker();
markerHash.remove(id);
coordsMap.remove(id);
mapboxMap.removeMarker(markerToRemove);
}
}
}
@Override
@ -506,7 +492,8 @@ public class MapActivity extends BaseActivity
if (sharingLevel.equals(SharingLevel.APPROXIMATED.toString())) {
defaultIcon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.approximate_localization_marker);
} else if (sharingLevel.equals(SharingLevel.MANUAL.toString())) {
} else if (sharingLevel.equals(SharingLevel.MANUAL.toString()) ||
sharingLevel.equals(SharingLevel.PREDEFINED.toString()) ) {
defaultIcon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.manual_localization_marker);
} else if (id.equals(myId)) {
defaultIcon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.my_marker);

View File

@ -4,6 +4,7 @@ public enum SharingLevel {
PRESENCE("presence"),
APPROXIMATED("approximated"),
EXACT("exact"),
PREDEFINED("predefined"),
MANUAL("manual");
private final String text;

View File

@ -16,7 +16,7 @@
mapbox:mapbox_cameraTargetLat="52.466799"
mapbox:mapbox_cameraTargetLng="16.927002"
mapbox:mapbox_cameraZoom="17"
mapbox:mapbox_styleUrl="mapbox://styles/domagalsky/cjiyzrqjp05l72rmj6ntvv2n8">
mapbox:mapbox_styleUrl="mapbox://styles/domagalsky/cjo8yjhfj0ih02rld5rft5nv7">
</com.mapbox.mapboxsdk.maps.MapView>