From 48ff53773f3f69b05dd51be4dd86f91d5f750aaf Mon Sep 17 00:00:00 2001 From: neslihanturan Date: Mon, 5 Aug 2019 14:26:21 +0300 Subject: [PATCH] Revert "Center map on location clicked in nearby list and notification card(#2060) (#2366)" This reverts commit 67d9afe77eb91cd4859f772943df455476d62939. --- .../nrw/commons/nearby/NearbyFragment.java | 11 --------- .../nrw/commons/nearby/NearbyMapFragment.java | 23 ++----------------- .../nearby/NearbyNotificationCardView.java | 16 +++---------- .../nrw/commons/nearby/PlaceRenderer.java | 5 +--- 4 files changed, 6 insertions(+), 49 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyFragment.java b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyFragment.java index ec00043d6..062f7da90 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyFragment.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyFragment.java @@ -705,17 +705,6 @@ public class NearbyFragment extends CommonsDaggerSupportFragment } } - - /** - * 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; } } diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyMapFragment.java b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyMapFragment.java index 67c41c951..bbc6cd09e 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyMapFragment.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyMapFragment.java @@ -225,6 +225,7 @@ public class NearbyMapFragment extends DaggerFragment { Timber.d("curLatLng found, setting up map view..."); setupMapView(savedInstanceState); } + setHasOptionsMenu(false); return mapView; @@ -253,7 +254,6 @@ public class NearbyMapFragment extends DaggerFragment { }); } - /** * Updates map slightly means it doesn't updates all nearby markers around. It just updates * location tracker marker of user. @@ -719,6 +719,7 @@ public class NearbyMapFragment extends DaggerFragment { passInfoToSheet(place); bottomSheetListBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); + } return false; }); @@ -1039,25 +1040,6 @@ public class NearbyMapFragment extends DaggerFragment { } } - /** - * 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) { @@ -1095,6 +1077,5 @@ public class NearbyMapFragment extends DaggerFragment { } - } diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyNotificationCardView.java b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyNotificationCardView.java index 30acedb8a..b5bc8b219 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyNotificationCardView.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyNotificationCardView.java @@ -17,8 +17,6 @@ import fr.free.nrw.commons.utils.SwipableCardView; 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 */ @@ -68,6 +66,7 @@ public class NearbyNotificationCardView extends SwipableCardView { progressBar = rootView.findViewById(R.id.progressBar); + setActionListeners(); } @Override @@ -82,16 +81,8 @@ public class NearbyNotificationCardView extends SwipableCardView { } - 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) { @@ -129,7 +120,6 @@ public class NearbyNotificationCardView extends SwipableCardView { 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); diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/PlaceRenderer.java b/app/src/main/java/fr/free/nrw/commons/nearby/PlaceRenderer.java index 50291dcb8..3d45b080f 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/PlaceRenderer.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/PlaceRenderer.java @@ -116,12 +116,9 @@ public class PlaceRenderer extends Renderer { ((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()) {