Make recenter button work when list sheet is expanded

This commit is contained in:
neslihanturan 2019-09-17 19:47:33 +03:00
parent 45d6f56630
commit ee57f84fea
3 changed files with 12 additions and 12 deletions

View file

@ -317,6 +317,7 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment
MarkerOptions currentLocationMarkerOptions = new MarkerOptions() MarkerOptions currentLocationMarkerOptions = new MarkerOptions()
.position(new com.mapbox.mapboxsdk.geometry.LatLng(curLatLng.getLatitude(), curLatLng.getLongitude())); .position(new com.mapbox.mapboxsdk.geometry.LatLng(curLatLng.getLatitude(), curLatLng.getLongitude()));
currentLocationMarkerOptions.setIcon(icon); // Set custom icon currentLocationMarkerOptions.setIcon(icon); // Set custom icon
Marker currentLocationMarker = mapboxMap.addMarker(currentLocationMarkerOptions);
List<com.mapbox.mapboxsdk.geometry.LatLng> circle = UiUtils.createCircleArray(curLatLng.getLatitude(), curLatLng.getLongitude(), List<com.mapbox.mapboxsdk.geometry.LatLng> circle = UiUtils.createCircleArray(curLatLng.getLatitude(), curLatLng.getLongitude(),
curLatLng.getAccuracy() * 2, 100); curLatLng.getAccuracy() * 2, 100);

View file

@ -188,17 +188,16 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
private boolean isNetworkErrorOccurred = false; private boolean isNetworkErrorOccurred = false;
private Snackbar snackbar; private Snackbar snackbar;
FragmentTransaction transaction; FragmentTransaction transaction;
View view; private View view;
public NearbyParentFragmentPresenter nearbyParentFragmentPresenter; public NearbyParentFragmentPresenter nearbyParentFragmentPresenter;
boolean isDarkTheme; private boolean isDarkTheme;
boolean isFabOpen; private boolean isFabOpen;
boolean isBottomListSheetExpanded;
private Marker selectedMarker; private Marker selectedMarker;
private Place selectedPlace; private Place selectedPlace;
private final double CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT = 0.06; private final double CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT = 0.005;
private final double CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE = 0.04; private final double CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE = 0.004;
NearbyMapFragment nearbyMapFragment; NearbyMapFragment nearbyMapFragment;
@ -769,21 +768,21 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
if (ViewUtil.isPortrait(getActivity())){ if (ViewUtil.isPortrait(getActivity())){
position = new CameraPosition.Builder() position = new CameraPosition.Builder()
.target(isBottomListSheetExpanded ? .target(isListBottomSheetExpanded() ?
new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT, new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT,
curLatLng.getLongitude()) curLatLng.getLongitude())
: new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) // Sets the new camera position : new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) // Sets the new camera position
.zoom(isBottomListSheetExpanded ? .zoom(isListBottomSheetExpanded() ?
ZOOM_LEVEL ZOOM_LEVEL
: nearbyMapFragment.getMapboxMap().getCameraPosition().zoom) // Same zoom level : nearbyMapFragment.getMapboxMap().getCameraPosition().zoom) // Same zoom level
.build(); .build();
}else { }else {
position = new CameraPosition.Builder() position = new CameraPosition.Builder()
.target(isBottomListSheetExpanded ? .target(isListBottomSheetExpanded() ?
new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE, new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE,
curLatLng.getLongitude()) curLatLng.getLongitude())
: new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) // Sets the new camera position : new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) // Sets the new camera position
.zoom(isBottomListSheetExpanded ? .zoom(isListBottomSheetExpanded() ?
ZOOM_LEVEL ZOOM_LEVEL
: nearbyMapFragment.getMapboxMap().getCameraPosition().zoom) // Same zoom level : nearbyMapFragment.getMapboxMap().getCameraPosition().zoom) // Same zoom level
.build(); .build();
@ -808,7 +807,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
NearbyMarker nearbyMarker = (NearbyMarker) marker; NearbyMarker nearbyMarker = (NearbyMarker) marker;
Place place = nearbyMarker.getNearbyBaseMarker().getPlace(); Place place = nearbyMarker.getNearbyBaseMarker().getPlace();
passInfoToSheet(place); passInfoToSheet(place);
bottomSheetListBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); hideBottomSheet();
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
} }

View file

@ -56,7 +56,7 @@ public class UiUtils {
* *
* @return List List of LatLng points of the circle. * @return List List of LatLng points of the circle.
*/ */
public static List<LatLng> createCircleArray( public static List<com.mapbox.mapboxsdk.geometry.LatLng> createCircleArray(
double centerLat, double centerLong, float radius, int nodes) { double centerLat, double centerLong, float radius, int nodes) {
List<com.mapbox.mapboxsdk.geometry.LatLng> circle = new ArrayList<>(); List<com.mapbox.mapboxsdk.geometry.LatLng> circle = new ArrayList<>();
float radiusKilometer = radius / 1000; float radiusKilometer = radius / 1000;