marker removing
This commit is contained in:
parent
03235ce18b
commit
5f65d8e6fb
@ -57,7 +57,10 @@ import com.uam.wmi.findmytutor.utils.PrefUtils;
|
|||||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||||
import com.uam.wmi.findmytutor.utils.mapUtils;
|
import com.uam.wmi.findmytutor.utils.mapUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
@ -67,6 +70,7 @@ import io.reactivex.schedulers.Schedulers;
|
|||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
public class MapActivity extends BaseActivity
|
public class MapActivity extends BaseActivity
|
||||||
@ -90,6 +94,8 @@ public class MapActivity extends BaseActivity
|
|||||||
private Marker droppedMarker;
|
private Marker droppedMarker;
|
||||||
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 int zoomParam = 17;
|
private int zoomParam = 17;
|
||||||
private int bearingParam = 180;
|
private int bearingParam = 180;
|
||||||
@ -101,7 +107,6 @@ public class MapActivity extends BaseActivity
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
|
final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
|
||||||
final String authToken = sharedPref.getString("authToken", null);
|
final String authToken = sharedPref.getString("authToken", null);
|
||||||
|
|
||||||
@ -298,8 +303,30 @@ public class MapActivity extends BaseActivity
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<Coordinate> coordsList) {
|
public void onSuccess(List<Coordinate> coordsList) {
|
||||||
|
|
||||||
|
ArrayList<String> currentCoordsIds = new ArrayList<>();
|
||||||
|
for (Coordinate coordinate : coordsList) {
|
||||||
|
currentCoordsIds.add(coordinate.getUserId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set<String> currentCoordsIds = new HashSet<String>(tmp);
|
||||||
|
if (previousCoordsIds.isEmpty()){
|
||||||
|
previousCoordsIds.addAll(currentCoordsIds);
|
||||||
|
} else {
|
||||||
|
// here we clear + it returns bool if smthing was removed
|
||||||
|
if (previousCoordsIds.removeAll(currentCoordsIds)) {
|
||||||
|
for (String toRemoveId: previousCoordsIds) {
|
||||||
|
Log.e(tag+ "delete: " , "removing: " + toRemoveId + ": " + markerHash.get(toRemoveId));
|
||||||
|
mapboxMap.removeMarker(markerHash.get(toRemoveId));
|
||||||
|
markerHash.remove(toRemoveId);
|
||||||
|
coordsMap.remove(toRemoveId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.e(tag+ "delete: ","nothing to remove");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Log.e(tag, "");
|
|
||||||
|
|
||||||
for (Coordinate element : coordsList) {
|
for (Coordinate element : coordsList) {
|
||||||
String id = element.getUserId();
|
String id = element.getUserId();
|
||||||
@ -348,19 +375,9 @@ public class MapActivity extends BaseActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for (Coordinate coordinate : coordsMap.values()) {
|
// For next fetch
|
||||||
// 300000 = 5mins
|
previousCoordsIds.clear();
|
||||||
if ((System.currentTimeMillis() - coordinate.getTimeStamp()) > (long) 300000) {
|
previousCoordsIds.addAll(currentCoordsIds);
|
||||||
String id = coordinate.getUserId();
|
|
||||||
Marker markerToRemove = markerHash.get(id);
|
|
||||||
markerHash.remove(id);
|
|
||||||
coordsMap.remove(id);
|
|
||||||
mapboxMap.removeMarker(markerToRemove);
|
|
||||||
}
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("LongLogTag")
|
@SuppressLint("LongLogTag")
|
||||||
|
Loading…
Reference in New Issue
Block a user