mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Seperate all methods logically, to increase modularity
This commit is contained in:
parent
0df35beab2
commit
1dcf4fb461
1 changed files with 69 additions and 80 deletions
|
|
@ -166,7 +166,9 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
|
||||
public void updateMapSlightly() {
|
||||
// Get arguments from bundle for new location
|
||||
|
||||
Bundle bundle = this.getArguments();
|
||||
if (mapboxMap != null) {
|
||||
Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapter(Uri.class, new UriDeserializer())
|
||||
.create();
|
||||
|
|
@ -179,12 +181,18 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
updateMapToTrackPosition();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateMapSignificantly() {
|
||||
Log.d("deneme", "oldu updateMapSignificantly");
|
||||
Bundle bundle = this.getArguments();
|
||||
if (mapboxMap != null) {
|
||||
Log.d("deneme", "oldu1 updateMapSignificantly");
|
||||
if (bundle != null) {
|
||||
Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapter(Uri.class, new UriDeserializer())
|
||||
.create();
|
||||
if (bundle != null) {
|
||||
Log.d("deneme", "oldu2 updateMapSignificantly");
|
||||
String gsonPlaceList = bundle.getString("PlaceList");
|
||||
String gsonLatLng = bundle.getString("CurLatLng");
|
||||
String gsonBoundaryCoordinates = bundle.getString("BoundaryCoord");
|
||||
|
|
@ -199,15 +207,21 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
getActivity());
|
||||
boundaryCoordinates = gson.fromJson(gsonBoundaryCoordinates, gsonBoundaryCoordinatesType);
|
||||
}
|
||||
mapboxMap.clear();
|
||||
addCurrentLocationMarker(mapboxMap);
|
||||
updateMapToTrackPosition();
|
||||
//addNearbyMarkerstoMapBoxMap();
|
||||
addNearbyMarkerstoMapBoxMap();
|
||||
} /*else {
|
||||
setupMapView(bundle);
|
||||
}*/
|
||||
//mapView.setStyleUrl("asset://mapstyle.json");
|
||||
}
|
||||
|
||||
// Only update current position marker and camera view
|
||||
private void updateMapToTrackPosition() {
|
||||
// Change
|
||||
Log.d("deneme","updateMapToTrackPosition");
|
||||
if (currentLocationMarker != null && mapboxMap != null) {
|
||||
if (currentLocationMarker != null) {
|
||||
LatLng curMapBoxLatLng = new LatLng(curLatLng.getLatitude(),curLatLng.getLongitude());
|
||||
ValueAnimator markerAnimator = ObjectAnimator.ofObject(currentLocationMarker, "position",
|
||||
new LatLngEvaluator(), currentLocationMarker.getPosition(),
|
||||
|
|
@ -342,34 +356,15 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
// create map
|
||||
mapView = new MapView(getActivity(), options);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
/*mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
NearbyMapFragment.this.mapboxMap = mapboxMap;
|
||||
NearbyMapFragment.this.mapboxMap.addMarkers(baseMarkerOptions);
|
||||
|
||||
NearbyMapFragment.this.mapboxMap.setOnInfoWindowCloseListener(marker -> {
|
||||
if (marker == selected){
|
||||
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
||||
//addNearbyMarkerstoMapBoxMap();
|
||||
updateMapSignificantly();
|
||||
}
|
||||
});
|
||||
|
||||
NearbyMapFragment.this.mapboxMap.setOnMarkerClickListener(marker -> {
|
||||
if (marker instanceof NearbyMarker) {
|
||||
NearbyMapFragment.this.selected = marker;
|
||||
NearbyMarker nearbyMarker = (NearbyMarker) marker;
|
||||
Place place = nearbyMarker.getNearbyBaseMarker().getPlace();
|
||||
passInfoToSheet(place);
|
||||
bottomSheetListBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
||||
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
addCurrentLocationMarker(NearbyMapFragment.this.mapboxMap);
|
||||
}
|
||||
});*/
|
||||
addNearbyMarkerstoMapBoxMap();
|
||||
//addCurrentLocationMarker(mapboxMap);
|
||||
mapView.setStyleUrl("asset://mapstyle.json");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -403,13 +398,7 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
}
|
||||
|
||||
private void addNearbyMarkerstoMapBoxMap() {
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
|
||||
}
|
||||
});
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
Log.d("deneme", "oldu3");
|
||||
mapboxMap.addMarkers(baseMarkerOptions);
|
||||
|
||||
mapboxMap.setOnInfoWindowCloseListener(marker -> {
|
||||
|
|
@ -430,11 +419,7 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
return false;
|
||||
});
|
||||
|
||||
addCurrentLocationMarker(mapboxMap);
|
||||
NearbyMapFragment.this.mapboxMap = mapboxMap;
|
||||
});
|
||||
|
||||
mapView.setStyleUrl("asset://mapstyle.json");
|
||||
// addCurrentLocationMarker(mapboxMap);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -589,6 +574,9 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
public void onResume() {
|
||||
if (mapView != null) {
|
||||
mapView.onResume();
|
||||
if (mapboxMap!=null) {
|
||||
mapboxMap.clear(); // To clear nearby markers from previous setup
|
||||
}
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
|
@ -623,5 +611,6 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
return latLng;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue