mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Make list item clicked and map focus to same place
This commit is contained in:
parent
6d41622b7d
commit
9f8becc581
3 changed files with 37 additions and 1 deletions
|
|
@ -33,6 +33,7 @@ import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
|
|||
import fr.free.nrw.commons.contributions.ContributionController;
|
||||
import fr.free.nrw.commons.di.ApplicationlessInjection;
|
||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||
import fr.free.nrw.commons.nearby.mvp.fragments.NearbyParentFragment;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static fr.free.nrw.commons.theme.NavigationBaseActivity.startActivityWithFlags;
|
||||
|
|
@ -117,7 +118,7 @@ public class PlaceRenderer extends Renderer<Place> {
|
|||
}
|
||||
}
|
||||
if (onBookmarkClick == null) {
|
||||
//((NearbyFragment) fragment.getParentFragment()).centerMapToPlace(place);
|
||||
((NearbyParentFragment) fragment.getParentFragment()).centerMapToPlace(place);
|
||||
}
|
||||
};
|
||||
view.setOnClickListener(listener);
|
||||
|
|
|
|||
|
|
@ -75,6 +75,9 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment
|
|||
private MapFragment.OnMapViewReadyCallback mapViewReadyCallback;
|
||||
private MapboxMap mapboxMap;
|
||||
private MapView map;
|
||||
private final double CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT = 0.005;
|
||||
private final double CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE = 0.004;
|
||||
private static final double ZOOM_LEVEL = 14f;
|
||||
|
||||
/**
|
||||
* Creates a default MapFragment instance
|
||||
|
|
@ -435,5 +438,26 @@ public class NearbyMapFragment 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, boolean isPortraitMode) {
|
||||
Log.d("denemeSon","isPortyrait:"+isPortraitMode);
|
||||
double cameraShift;
|
||||
if (isPortraitMode) {
|
||||
cameraShift = CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT;
|
||||
} else {
|
||||
cameraShift = CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE;
|
||||
}
|
||||
CameraPosition position = new CameraPosition.Builder()
|
||||
.target(LocationUtils.commonsLatLngToMapBoxLatLng(
|
||||
new LatLng(place.location.getLatitude()-cameraShift,
|
||||
place.getLocation().getLongitude(),
|
||||
0))) // Sets the new camera position
|
||||
.zoom(ZOOM_LEVEL) // Same zoom level
|
||||
.build();
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
|
|
@ -398,6 +399,16 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
return mapFragment;
|
||||
}
|
||||
|
||||
public void centerMapToPlace(Place place) {
|
||||
Log.d("denemeson","place:"+place);
|
||||
if (nearbyMapFragment != null) {
|
||||
nearbyMapFragment.centerMapToPlace(
|
||||
place,
|
||||
getActivity().getResources().getConfiguration().orientation ==
|
||||
Configuration.ORIENTATION_PORTRAIT);
|
||||
}
|
||||
}
|
||||
|
||||
NearbyListFragment setListFragment() {
|
||||
///if (savedInstanceState == null) {
|
||||
NearbyListFragment nearbyListFragment;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue