mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Fix the issues with updating search nearby markers and camera position together
This commit is contained in:
parent
13695fdb2b
commit
a3c6734f70
5 changed files with 70 additions and 29 deletions
|
|
@ -435,23 +435,43 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
|
||||||
if (curlatLng.equals(searchLatLng)) { // Means we are checking around current location
|
if (curlatLng.equals(searchLatLng)) { // Means we are checking around current location
|
||||||
Log.d("denemeTestt","checking around current location1");
|
Log.d("denemeTestt","checking around current location1");
|
||||||
checkingAroundCurretLocation = true;
|
checkingAroundCurretLocation = true;
|
||||||
|
compositeDisposable.add(Observable.fromCallable(() -> nearbyController
|
||||||
|
.loadAttractionsFromLocation(curlatLng, searchLatLng, false, checkingAroundCurretLocation))
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(this::updateMapMarkers,
|
||||||
|
throwable -> {
|
||||||
|
Timber.d(throwable);
|
||||||
|
//showErrorMessage(getString(R.string.error_fetching_nearby_places));
|
||||||
|
// TODO solve first unneeded method call here
|
||||||
|
//progressBar.setVisibility(View.GONE);
|
||||||
|
//nearbyParentFragmentPresenter.lockUnlockNearby(false);
|
||||||
|
}));
|
||||||
} else {
|
} else {
|
||||||
Log.d("denemeTestt","not checking around current location2");
|
Log.d("denemeTestt","not checking around current location2");
|
||||||
checkingAroundCurretLocation = false;
|
checkingAroundCurretLocation = false;
|
||||||
|
compositeDisposable.add(Observable.fromCallable(() -> nearbyController
|
||||||
|
.loadAttractionsFromLocation(curlatLng, searchLatLng, false, checkingAroundCurretLocation))
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(this::updateMapMarkersForCustomLocation,
|
||||||
|
throwable -> {
|
||||||
|
Timber.d(throwable);
|
||||||
|
//showErrorMessage(getString(R.string.error_fetching_nearby_places));
|
||||||
|
// TODO solve first unneeded method call here
|
||||||
|
//progressBar.setVisibility(View.GONE);
|
||||||
|
//nearbyParentFragmentPresenter.lockUnlockNearby(false);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
compositeDisposable.add(Observable.fromCallable(() -> nearbyController
|
/**
|
||||||
.loadAttractionsFromLocation(curlatLng, searchLatLng, false, checkingAroundCurretLocation))
|
* Populates places for your location, should be used for finding nearby places around a
|
||||||
.subscribeOn(Schedulers.io())
|
* location where you are.
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
* @param nearbyPlacesInfo This variable has place list information and distances.
|
||||||
.subscribe(this::updateMapMarkers,
|
*/
|
||||||
throwable -> {
|
private void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
|
||||||
Timber.d(throwable);
|
nearbyParentFragmentPresenter.updateMapMarkers(nearbyPlacesInfo, selectedMarker);
|
||||||
//showErrorMessage(getString(R.string.error_fetching_nearby_places));
|
|
||||||
// TODO solve first unneeded method call here
|
|
||||||
//progressBar.setVisibility(View.GONE);
|
|
||||||
//nearbyParentFragmentPresenter.lockNearby(false);
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -459,10 +479,13 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
|
||||||
* location where you are not at.
|
* location where you are not at.
|
||||||
* @param nearbyPlacesInfo This variable has place list information and distances.
|
* @param nearbyPlacesInfo This variable has place list information and distances.
|
||||||
*/
|
*/
|
||||||
private void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
|
private void updateMapMarkersForCustomLocation(NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
|
||||||
nearbyParentFragmentPresenter.updateMapMarkers(nearbyPlacesInfo, selectedMarker);
|
nearbyParentFragmentPresenter.updateMapMarkersForCustomLocation(nearbyPlacesInfo, selectedMarker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBottomSheetExpanded() {
|
public boolean isBottomSheetExpanded() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import com.mapbox.mapboxsdk.annotations.Marker;
|
||||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||||
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
|
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
|
||||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||||
|
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||||
import com.mapbox.mapboxsdk.maps.MapFragment;
|
import com.mapbox.mapboxsdk.maps.MapFragment;
|
||||||
import com.mapbox.mapboxsdk.maps.MapView;
|
import com.mapbox.mapboxsdk.maps.MapView;
|
||||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||||
|
|
@ -283,9 +284,7 @@ public class SupportMapFragment extends CommonsDaggerSupportFragment
|
||||||
bookmarkLocationDao.getAllBookmarksLocations());
|
bookmarkLocationDao.getAllBookmarksLocations());
|
||||||
mapboxMap.clear();
|
mapboxMap.clear();
|
||||||
// TODO: set search latlang here
|
// TODO: set search latlang here
|
||||||
CameraPosition cameraPosition = new CameraPosition.Builder().target
|
|
||||||
(LocationUtils.commonsLatLngToMapBoxLatLng(latLng)).build();
|
|
||||||
mapboxMap.setCameraPosition(cameraPosition);
|
|
||||||
/*mapboxMap.animateCamera(CameraUpdateFactory
|
/*mapboxMap.animateCamera(CameraUpdateFactory
|
||||||
.newCameraPosition(cameraPosition), 1000);*/
|
.newCameraPosition(cameraPosition), 1000);*/
|
||||||
// TODO: set position depening to botom sheet position heere
|
// TODO: set position depening to botom sheet position heere
|
||||||
|
|
@ -293,12 +292,15 @@ public class SupportMapFragment extends CommonsDaggerSupportFragment
|
||||||
addNearbyMarkersToMapBoxMap(customBaseMarkerOptions, selectedMarker, nearbyParentFragmentPresenter);
|
addNearbyMarkersToMapBoxMap(customBaseMarkerOptions, selectedMarker, nearbyParentFragmentPresenter);
|
||||||
// Re-enable mapbox gestures on custom location markers load
|
// Re-enable mapbox gestures on custom location markers load
|
||||||
mapboxMap.getUiSettings().setAllGesturesEnabled(true);
|
mapboxMap.getUiSettings().setAllGesturesEnabled(true);
|
||||||
updateMapToTrackPosition(latLng);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMapToTrackPosition(LatLng curLatLng) {
|
public void updateMapToTrackPosition(LatLng curLatLng) {
|
||||||
addCurrentLocationMarker(curLatLng);
|
CameraPosition cameraPosition = new CameraPosition.Builder().target
|
||||||
|
(LocationUtils.commonsLatLngToMapBoxLatLng(curLatLng)).build();
|
||||||
|
mapboxMap.setCameraPosition(cameraPosition);
|
||||||
|
mapboxMap.animateCamera(CameraUpdateFactory
|
||||||
|
.newCameraPosition(cameraPosition), 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ public interface NearbyParentFragmentContract {
|
||||||
void onTabSelected();
|
void onTabSelected();
|
||||||
void initializeNearbyOperations();
|
void initializeNearbyOperations();
|
||||||
void updateMapAndList(LocationServiceManager.LocationChangeType locationChangeType, LatLng cameraTarget);
|
void updateMapAndList(LocationServiceManager.LocationChangeType locationChangeType, LatLng cameraTarget);
|
||||||
void lockNearby(boolean isNearbyLocked);
|
void lockUnlockNearby(boolean isNearbyLocked);
|
||||||
void setActionListeners(JsonKvStore applicationKvStore);
|
void setActionListeners(JsonKvStore applicationKvStore);
|
||||||
|
|
||||||
MapboxMap.OnCameraMoveListener onCameraMove(MapboxMap mapboxMap);
|
MapboxMap.OnCameraMoveListener onCameraMove(MapboxMap mapboxMap);
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
//showErrorMessage(getString(R.string.error_fetching_nearby_places));
|
//showErrorMessage(getString(R.string.error_fetching_nearby_places));
|
||||||
// TODO solve first unneeded method call here
|
// TODO solve first unneeded method call here
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
//nearbyParentFragmentPresenter.lockNearby(false);
|
//nearbyParentFragmentPresenter.lockUnlockNearby(false);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ import fr.free.nrw.commons.location.LocationUpdateListener;
|
||||||
import fr.free.nrw.commons.nearby.NearbyController;
|
import fr.free.nrw.commons.nearby.NearbyController;
|
||||||
import fr.free.nrw.commons.nearby.mvp.contract.NearbyMapContract;
|
import fr.free.nrw.commons.nearby.mvp.contract.NearbyMapContract;
|
||||||
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
||||||
import fr.free.nrw.commons.nearby.mvp.fragments.NearbyParentFragment;
|
|
||||||
import fr.free.nrw.commons.utils.LocationUtils;
|
import fr.free.nrw.commons.utils.LocationUtils;
|
||||||
|
|
||||||
import fr.free.nrw.commons.wikidata.WikidataEditListener;
|
import fr.free.nrw.commons.wikidata.WikidataEditListener;
|
||||||
|
|
@ -111,7 +110,6 @@ public class NearbyParentFragmentPresenter
|
||||||
Timber.d("performNearbyOperationsIfPermissionGiven");
|
Timber.d("performNearbyOperationsIfPermissionGiven");
|
||||||
//nearbyParentFragmentView.registerLocationUpdates(locationServiceManager);
|
//nearbyParentFragmentView.registerLocationUpdates(locationServiceManager);
|
||||||
// Nearby buttons should be active, they should be inactive only during update
|
// Nearby buttons should be active, they should be inactive only during update
|
||||||
//lockNearby(false);
|
|
||||||
// This will start a consequence to check GPS depending on different API
|
// This will start a consequence to check GPS depending on different API
|
||||||
//nearbyParentFragmentView.checkGps(locationServiceManager);
|
//nearbyParentFragmentView.checkGps(locationServiceManager);
|
||||||
// We will know when we went offline and online again
|
// We will know when we went offline and online again
|
||||||
|
|
@ -147,7 +145,8 @@ public class NearbyParentFragmentPresenter
|
||||||
Log.d("denemeTest","initializeMapOperations");
|
Log.d("denemeTest","initializeMapOperations");
|
||||||
nearbyParentFragmentView.initViewPositions();
|
nearbyParentFragmentView.initViewPositions();
|
||||||
|
|
||||||
lockNearby(false);
|
lockUnlockNearby(false);
|
||||||
|
registerUnregisterLocationListener(false);
|
||||||
nearbyParentFragmentView.addNetworkBroadcastReceiver();
|
nearbyParentFragmentView.addNetworkBroadcastReceiver();
|
||||||
|
|
||||||
Timber.d("Nearby map view is created and ready");
|
Timber.d("Nearby map view is created and ready");
|
||||||
|
|
@ -193,9 +192,12 @@ public class NearbyParentFragmentPresenter
|
||||||
* @param isNearbyLocked true means lock, false means unlock
|
* @param isNearbyLocked true means lock, false means unlock
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void lockNearby(boolean isNearbyLocked) {
|
public void lockUnlockNearby(boolean isNearbyLocked) {
|
||||||
this.isNearbyLocked = isNearbyLocked;
|
this.isNearbyLocked = isNearbyLocked;
|
||||||
if (isNearbyLocked) {
|
}
|
||||||
|
|
||||||
|
public void registerUnregisterLocationListener(boolean removeLocationListener) {
|
||||||
|
if (removeLocationListener) {
|
||||||
locationServiceManager.unregisterLocationManager();
|
locationServiceManager.unregisterLocationManager();
|
||||||
locationServiceManager.removeLocationListener(this);
|
locationServiceManager.removeLocationListener(this);
|
||||||
Timber.d("Nearby locked");
|
Timber.d("Nearby locked");
|
||||||
|
|
@ -256,6 +258,7 @@ public class NearbyParentFragmentPresenter
|
||||||
if (locationChangeType.equals(LOCATION_SIGNIFICANTLY_CHANGED)
|
if (locationChangeType.equals(LOCATION_SIGNIFICANTLY_CHANGED)
|
||||||
|| locationChangeType.equals(MAP_UPDATED)) {
|
|| locationChangeType.equals(MAP_UPDATED)) {
|
||||||
Log.d("denemeTest","1");
|
Log.d("denemeTest","1");
|
||||||
|
lockUnlockNearby(true);
|
||||||
nearbyParentFragmentView.populatePlaces(lastLocation, lastLocation);
|
nearbyParentFragmentView.populatePlaces(lastLocation, lastLocation);
|
||||||
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(false);
|
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(false);
|
||||||
//nearbyMapFragmentView.updateMapToTrackPosition(curLatLng);
|
//nearbyMapFragmentView.updateMapToTrackPosition(curLatLng);
|
||||||
|
|
@ -264,7 +267,7 @@ public class NearbyParentFragmentPresenter
|
||||||
|
|
||||||
} else if (locationChangeType.equals(SEARCH_CUSTOM_AREA)) {
|
} else if (locationChangeType.equals(SEARCH_CUSTOM_AREA)) {
|
||||||
Log.d("denemeTest","2");
|
Log.d("denemeTest","2");
|
||||||
|
lockUnlockNearby(true);
|
||||||
nearbyParentFragmentView.populatePlaces(lastLocation, cameraTarget);
|
nearbyParentFragmentView.populatePlaces(lastLocation, cameraTarget);
|
||||||
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(false);
|
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(false);
|
||||||
searchingThisArea = false;
|
searchingThisArea = false;
|
||||||
|
|
@ -284,7 +287,20 @@ public class NearbyParentFragmentPresenter
|
||||||
*/
|
*/
|
||||||
public void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo, Marker selectedMarker) {
|
public void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo, Marker selectedMarker) {
|
||||||
nearbyMapFragmentView.updateMapMarkers(nearbyPlacesInfo.curLatLng, nearbyPlacesInfo.placeList, selectedMarker, this);
|
nearbyMapFragmentView.updateMapMarkers(nearbyPlacesInfo.curLatLng, nearbyPlacesInfo.placeList, selectedMarker, this);
|
||||||
|
nearbyMapFragmentView.addCurrentLocationMarker(nearbyPlacesInfo.curLatLng);
|
||||||
nearbyMapFragmentView.updateMapToTrackPosition(nearbyPlacesInfo.curLatLng);
|
nearbyMapFragmentView.updateMapToTrackPosition(nearbyPlacesInfo.curLatLng);
|
||||||
|
lockUnlockNearby(false); // So that new location updates wont come
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates places for custom location, should be used for finding nearby places around a
|
||||||
|
* location where you are not at.
|
||||||
|
* @param nearbyPlacesInfo This variable has place list information and distances.
|
||||||
|
*/
|
||||||
|
public void updateMapMarkersForCustomLocation(NearbyController.NearbyPlacesInfo nearbyPlacesInfo, Marker selectedMarker) {
|
||||||
|
nearbyMapFragmentView.updateMapMarkers(nearbyPlacesInfo.curLatLng, nearbyPlacesInfo.placeList, selectedMarker, this);
|
||||||
|
nearbyMapFragmentView.addCurrentLocationMarker(nearbyPlacesInfo.curLatLng);
|
||||||
|
lockUnlockNearby(false); // So that new location updates wont come
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -343,7 +359,7 @@ public class NearbyParentFragmentPresenter
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Log.d("denemeTestt","onSearchThisAreaClicked");
|
Log.d("denemeTestt","onSearchThisAreaClicked");
|
||||||
// Lock map operations during search this area operation
|
// Lock map operations during search this area operation
|
||||||
lockNearby(true);
|
// TODO: test lock nearby
|
||||||
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(true);
|
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(true);
|
||||||
// TODO: make this invisible at somewhere
|
// TODO: make this invisible at somewhere
|
||||||
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(false);
|
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(false);
|
||||||
|
|
@ -353,7 +369,7 @@ public class NearbyParentFragmentPresenter
|
||||||
updateMapAndList(LOCATION_SIGNIFICANTLY_CHANGED,
|
updateMapAndList(LOCATION_SIGNIFICANTLY_CHANGED,
|
||||||
null);
|
null);
|
||||||
} else {
|
} else {
|
||||||
Log.d("denemeTestt","!searchCloseToCurrentLocation()");
|
Log.d("denemeTestt","!searchCloseToCurrentLocation()+"+getCameraTarget());
|
||||||
updateMapAndList(SEARCH_CUSTOM_AREA,
|
updateMapAndList(SEARCH_CUSTOM_AREA,
|
||||||
getCameraTarget());
|
getCameraTarget());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue