mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
* center map on location clicked in nearby (#2060) * improved animation * Center map on location clicked in nearby list * removed unnecessary methods * center map on location clicked in nearby notification card * some minor changes * travis build error * resolved errors * Tidy up PR
This commit is contained in:
parent
579d44ce80
commit
67d9afe77e
4 changed files with 49 additions and 6 deletions
|
|
@ -705,6 +705,17 @@ 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;
|
public boolean isBottomSheetExpanded() { return bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,6 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
Timber.d("curLatLng found, setting up map view...");
|
Timber.d("curLatLng found, setting up map view...");
|
||||||
setupMapView(savedInstanceState);
|
setupMapView(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
setHasOptionsMenu(false);
|
setHasOptionsMenu(false);
|
||||||
|
|
||||||
return mapView;
|
return mapView;
|
||||||
|
|
@ -254,6 +253,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates map slightly means it doesn't updates all nearby markers around. It just updates
|
* Updates map slightly means it doesn't updates all nearby markers around. It just updates
|
||||||
* location tracker marker of user.
|
* location tracker marker of user.
|
||||||
|
|
@ -719,7 +719,6 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
passInfoToSheet(place);
|
passInfoToSheet(place);
|
||||||
bottomSheetListBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
bottomSheetListBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
||||||
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
@ -1040,6 +1039,25 @@ 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) {
|
public void updateMarker(boolean isBookmarked, Place place) {
|
||||||
|
|
||||||
|
|
@ -1077,5 +1095,6 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ import fr.free.nrw.commons.utils.SwipableCardView;
|
||||||
import fr.free.nrw.commons.utils.ViewUtil;
|
import fr.free.nrw.commons.utils.ViewUtil;
|
||||||
import timber.log.Timber;
|
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
|
* Custom card view for nearby notification card view on main screen, above contributions list
|
||||||
*/
|
*/
|
||||||
|
|
@ -66,7 +68,6 @@ public class NearbyNotificationCardView extends SwipableCardView {
|
||||||
|
|
||||||
progressBar = rootView.findViewById(R.id.progressBar);
|
progressBar = rootView.findViewById(R.id.progressBar);
|
||||||
|
|
||||||
setActionListeners();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -81,8 +82,16 @@ public class NearbyNotificationCardView extends SwipableCardView {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setActionListeners() {
|
private void setActionListeners(Place place) {
|
||||||
this.setOnClickListener(view -> ((MainActivity)getContext()).viewPager.setCurrentItem(1));
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean onSwipe(View view) {
|
@Override public boolean onSwipe(View view) {
|
||||||
|
|
@ -120,6 +129,7 @@ public class NearbyNotificationCardView extends SwipableCardView {
|
||||||
contentLayout.setVisibility(VISIBLE);
|
contentLayout.setVisibility(VISIBLE);
|
||||||
// Make progress bar invisible once data is ready
|
// Make progress bar invisible once data is ready
|
||||||
progressBar.setVisibility(GONE);
|
progressBar.setVisibility(GONE);
|
||||||
|
setActionListeners(place);
|
||||||
// And content views visible since they are ready
|
// And content views visible since they are ready
|
||||||
notificationTitle.setVisibility(VISIBLE);
|
notificationTitle.setVisibility(VISIBLE);
|
||||||
notificationDistance.setVisibility(VISIBLE);
|
notificationDistance.setVisibility(VISIBLE);
|
||||||
|
|
|
||||||
|
|
@ -116,9 +116,12 @@ public class PlaceRenderer extends Renderer<Place> {
|
||||||
((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(lastPosition, buttonLayout.getHeight());
|
((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(lastPosition, buttonLayout.getHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (onBookmarkClick == null) {
|
||||||
|
((NearbyFragment) fragment.getParentFragment()).centerMapToPlace(place);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
view.setOnClickListener(listener);
|
view.setOnClickListener(listener);
|
||||||
|
|
||||||
view.requestFocus();
|
view.requestFocus();
|
||||||
view.setOnFocusChangeListener((view1, hasFocus) -> {
|
view.setOnFocusChangeListener((view1, hasFocus) -> {
|
||||||
if (!hasFocus && buttonLayout.isShown()) {
|
if (!hasFocus && buttonLayout.isShown()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue