Skip to content

Revert "Center map on location clicked in nearby list and notification card(#2060)" #3116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions app/src/main/java/fr/free/nrw/commons/nearby/NearbyFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -705,17 +705,6 @@ public void onPause() {
}
}


/**
* Centers the map in nearby fragment to a given place
* @param place is new center of the map
*/
public void centerMapToPlace(Place place) {
if (nearbyMapFragment != null) {
nearbyMapFragment.centerMapToPlace(place);
}
}

public boolean isBottomSheetExpanded() { return bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
Timber.d("curLatLng found, setting up map view...");
setupMapView(savedInstanceState);
}

setHasOptionsMenu(false);

return mapView;
Expand Down Expand Up @@ -253,7 +254,6 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
});
}


/**
* Updates map slightly means it doesn't updates all nearby markers around. It just updates
* location tracker marker of user.
Expand Down Expand Up @@ -719,6 +719,7 @@ private void addNearbyMarkersToMapBoxMap(@Nullable List<NearbyBaseMarker> custom
passInfoToSheet(place);
bottomSheetListBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);

}
return false;
});
Expand Down Expand Up @@ -1039,25 +1040,6 @@ public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
}
}

/**
* Centers the map in nearby fragment to a given place
* @param place is new center of the map
*/
public void centerMapToPlace(Place place) {
mapView.getMapAsync(mapboxMap1 -> {
CameraPosition position = new CameraPosition.Builder()
.target(isBottomListSheetExpanded ?
new LatLng(place.location.getLatitude()- CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE,
place.getLocation().getLongitude())
: new LatLng(place.getLocation().getLatitude(), place.getLocation().getLongitude(), 0)) // Sets the new camera position
.zoom(isBottomListSheetExpanded ?
ZOOM_LEVEL
:mapboxMap.getCameraPosition().zoom) // Same zoom level
.build();
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), 1000);
});
}


public void updateMarker(boolean isBookmarked, Place place) {

Expand Down Expand Up @@ -1095,6 +1077,5 @@ public void updateMarker(boolean isBookmarked, Place place) {

}


}

Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import fr.free.nrw.commons.utils.ViewUtil;
import timber.log.Timber;

import static fr.free.nrw.commons.contributions.MainActivity.NEARBY_TAB_POSITION;

/**
* Custom card view for nearby notification card view on main screen, above contributions list
*/
Expand Down Expand Up @@ -68,6 +66,7 @@ private void init() {

progressBar = rootView.findViewById(R.id.progressBar);

setActionListeners();
}

@Override
Expand All @@ -82,16 +81,8 @@ protected void onAttachedToWindow() {
}


private void setActionListeners(Place place) {
this.setOnClickListener(view -> {
MainActivity m = (MainActivity) getContext();

// Change to nearby tab
m.viewPager.setCurrentItem(NEARBY_TAB_POSITION);

// Center the map to the place
((NearbyFragment) m.contributionsActivityPagerAdapter.getItem(NEARBY_TAB_POSITION)).centerMapToPlace(place);
});
private void setActionListeners() {
this.setOnClickListener(view -> ((MainActivity)getContext()).viewPager.setCurrentItem(1));
}

@Override public boolean onSwipe(View view) {
Expand Down Expand Up @@ -129,7 +120,6 @@ public void updateContent(Place place) {
contentLayout.setVisibility(VISIBLE);
// Make progress bar invisible once data is ready
progressBar.setVisibility(GONE);
setActionListeners(place);
// And content views visible since they are ready
notificationTitle.setVisibility(VISIBLE);
notificationDistance.setVisibility(VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,9 @@ protected void hookListeners(View view) {
((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(lastPosition, buttonLayout.getHeight());
}
}
if (onBookmarkClick == null) {
((NearbyFragment) fragment.getParentFragment()).centerMapToPlace(place);
}

};
view.setOnClickListener(listener);

view.requestFocus();
view.setOnFocusChangeListener((view1, hasFocus) -> {
if (!hasFocus && buttonLayout.isShown()) {
Expand Down