Skip to content

Commit 48ff537

Browse files
Revert "Center map on location clicked in nearby list and notification card(#2060) (#2366)"
This reverts commit 67d9afe.
1 parent ec8bbb2 commit 48ff537

File tree

4 files changed

+6
-49
lines changed

4 files changed

+6
-49
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/NearbyFragment.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -705,17 +705,6 @@ public void onPause() {
705705
}
706706
}
707707

708-
709-
/**
710-
* Centers the map in nearby fragment to a given place
711-
* @param place is new center of the map
712-
*/
713-
public void centerMapToPlace(Place place) {
714-
if (nearbyMapFragment != null) {
715-
nearbyMapFragment.centerMapToPlace(place);
716-
}
717-
}
718-
719708
public boolean isBottomSheetExpanded() { return bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED;
720709
}
721710
}

app/src/main/java/fr/free/nrw/commons/nearby/NearbyMapFragment.java

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
225225
Timber.d("curLatLng found, setting up map view...");
226226
setupMapView(savedInstanceState);
227227
}
228+
228229
setHasOptionsMenu(false);
229230

230231
return mapView;
@@ -253,7 +254,6 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
253254
});
254255
}
255256

256-
257257
/**
258258
* Updates map slightly means it doesn't updates all nearby markers around. It just updates
259259
* location tracker marker of user.
@@ -719,6 +719,7 @@ private void addNearbyMarkersToMapBoxMap(@Nullable List<NearbyBaseMarker> custom
719719
passInfoToSheet(place);
720720
bottomSheetListBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
721721
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
722+
722723
}
723724
return false;
724725
});
@@ -1039,25 +1040,6 @@ public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
10391040
}
10401041
}
10411042

1042-
/**
1043-
* Centers the map in nearby fragment to a given place
1044-
* @param place is new center of the map
1045-
*/
1046-
public void centerMapToPlace(Place place) {
1047-
mapView.getMapAsync(mapboxMap1 -> {
1048-
CameraPosition position = new CameraPosition.Builder()
1049-
.target(isBottomListSheetExpanded ?
1050-
new LatLng(place.location.getLatitude()- CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE,
1051-
place.getLocation().getLongitude())
1052-
: new LatLng(place.getLocation().getLatitude(), place.getLocation().getLongitude(), 0)) // Sets the new camera position
1053-
.zoom(isBottomListSheetExpanded ?
1054-
ZOOM_LEVEL
1055-
:mapboxMap.getCameraPosition().zoom) // Same zoom level
1056-
.build();
1057-
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), 1000);
1058-
});
1059-
}
1060-
10611043

10621044
public void updateMarker(boolean isBookmarked, Place place) {
10631045

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

10961078
}
10971079

1098-
10991080
}
11001081

app/src/main/java/fr/free/nrw/commons/nearby/NearbyNotificationCardView.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import fr.free.nrw.commons.utils.ViewUtil;
1818
import timber.log.Timber;
1919

20-
import static fr.free.nrw.commons.contributions.MainActivity.NEARBY_TAB_POSITION;
21-
2220
/**
2321
* Custom card view for nearby notification card view on main screen, above contributions list
2422
*/
@@ -68,6 +66,7 @@ private void init() {
6866

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

69+
setActionListeners();
7170
}
7271

7372
@Override
@@ -82,16 +81,8 @@ protected void onAttachedToWindow() {
8281
}
8382

8483

85-
private void setActionListeners(Place place) {
86-
this.setOnClickListener(view -> {
87-
MainActivity m = (MainActivity) getContext();
88-
89-
// Change to nearby tab
90-
m.viewPager.setCurrentItem(NEARBY_TAB_POSITION);
91-
92-
// Center the map to the place
93-
((NearbyFragment) m.contributionsActivityPagerAdapter.getItem(NEARBY_TAB_POSITION)).centerMapToPlace(place);
94-
});
84+
private void setActionListeners() {
85+
this.setOnClickListener(view -> ((MainActivity)getContext()).viewPager.setCurrentItem(1));
9586
}
9687

9788
@Override public boolean onSwipe(View view) {
@@ -129,7 +120,6 @@ public void updateContent(Place place) {
129120
contentLayout.setVisibility(VISIBLE);
130121
// Make progress bar invisible once data is ready
131122
progressBar.setVisibility(GONE);
132-
setActionListeners(place);
133123
// And content views visible since they are ready
134124
notificationTitle.setVisibility(VISIBLE);
135125
notificationDistance.setVisibility(VISIBLE);

app/src/main/java/fr/free/nrw/commons/nearby/PlaceRenderer.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,9 @@ protected void hookListeners(View view) {
116116
((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(lastPosition, buttonLayout.getHeight());
117117
}
118118
}
119-
if (onBookmarkClick == null) {
120-
((NearbyFragment) fragment.getParentFragment()).centerMapToPlace(place);
121-
}
119+
122120
};
123121
view.setOnClickListener(listener);
124-
125122
view.requestFocus();
126123
view.setOnFocusChangeListener((view1, hasFocus) -> {
127124
if (!hasFocus && buttonLayout.isShown()) {

0 commit comments

Comments
 (0)