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
|
||||
Log.d("denemeTestt","checking around current location1");
|
||||
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 {
|
||||
Log.d("denemeTestt","not checking around current location2");
|
||||
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))
|
||||
.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.lockNearby(false);
|
||||
}));
|
||||
/**
|
||||
* Populates places for your location, should be used for finding nearby places around a
|
||||
* location where you are.
|
||||
* @param nearbyPlacesInfo This variable has place list information and distances.
|
||||
*/
|
||||
private void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
|
||||
nearbyParentFragmentPresenter.updateMapMarkers(nearbyPlacesInfo, selectedMarker);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -459,10 +479,13 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
|
|||
* location where you are not at.
|
||||
* @param nearbyPlacesInfo This variable has place list information and distances.
|
||||
*/
|
||||
private void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
|
||||
nearbyParentFragmentPresenter.updateMapMarkers(nearbyPlacesInfo, selectedMarker);
|
||||
private void updateMapMarkersForCustomLocation(NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
|
||||
nearbyParentFragmentPresenter.updateMapMarkersForCustomLocation(nearbyPlacesInfo, selectedMarker);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isBottomSheetExpanded() {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.mapbox.mapboxsdk.annotations.Marker;
|
|||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.maps.MapFragment;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
|
|
@ -283,9 +284,7 @@ public class SupportMapFragment extends CommonsDaggerSupportFragment
|
|||
bookmarkLocationDao.getAllBookmarksLocations());
|
||||
mapboxMap.clear();
|
||||
// TODO: set search latlang here
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder().target
|
||||
(LocationUtils.commonsLatLngToMapBoxLatLng(latLng)).build();
|
||||
mapboxMap.setCameraPosition(cameraPosition);
|
||||
|
||||
/*mapboxMap.animateCamera(CameraUpdateFactory
|
||||
.newCameraPosition(cameraPosition), 1000);*/
|
||||
// TODO: set position depening to botom sheet position heere
|
||||
|
|
@ -293,12 +292,15 @@ public class SupportMapFragment extends CommonsDaggerSupportFragment
|
|||
addNearbyMarkersToMapBoxMap(customBaseMarkerOptions, selectedMarker, nearbyParentFragmentPresenter);
|
||||
// Re-enable mapbox gestures on custom location markers load
|
||||
mapboxMap.getUiSettings().setAllGesturesEnabled(true);
|
||||
updateMapToTrackPosition(latLng);
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public interface NearbyParentFragmentContract {
|
|||
void onTabSelected();
|
||||
void initializeNearbyOperations();
|
||||
void updateMapAndList(LocationServiceManager.LocationChangeType locationChangeType, LatLng cameraTarget);
|
||||
void lockNearby(boolean isNearbyLocked);
|
||||
void lockUnlockNearby(boolean isNearbyLocked);
|
||||
void setActionListeners(JsonKvStore applicationKvStore);
|
||||
|
||||
MapboxMap.OnCameraMoveListener onCameraMove(MapboxMap mapboxMap);
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
//showErrorMessage(getString(R.string.error_fetching_nearby_places));
|
||||
// TODO solve first unneeded method call here
|
||||
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.mvp.contract.NearbyMapContract;
|
||||
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.wikidata.WikidataEditListener;
|
||||
|
|
@ -111,7 +110,6 @@ public class NearbyParentFragmentPresenter
|
|||
Timber.d("performNearbyOperationsIfPermissionGiven");
|
||||
//nearbyParentFragmentView.registerLocationUpdates(locationServiceManager);
|
||||
// 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
|
||||
//nearbyParentFragmentView.checkGps(locationServiceManager);
|
||||
// We will know when we went offline and online again
|
||||
|
|
@ -147,7 +145,8 @@ public class NearbyParentFragmentPresenter
|
|||
Log.d("denemeTest","initializeMapOperations");
|
||||
nearbyParentFragmentView.initViewPositions();
|
||||
|
||||
lockNearby(false);
|
||||
lockUnlockNearby(false);
|
||||
registerUnregisterLocationListener(false);
|
||||
nearbyParentFragmentView.addNetworkBroadcastReceiver();
|
||||
|
||||
Timber.d("Nearby map view is created and ready");
|
||||
|
|
@ -193,9 +192,12 @@ public class NearbyParentFragmentPresenter
|
|||
* @param isNearbyLocked true means lock, false means unlock
|
||||
*/
|
||||
@Override
|
||||
public void lockNearby(boolean isNearbyLocked) {
|
||||
public void lockUnlockNearby(boolean isNearbyLocked) {
|
||||
this.isNearbyLocked = isNearbyLocked;
|
||||
if (isNearbyLocked) {
|
||||
}
|
||||
|
||||
public void registerUnregisterLocationListener(boolean removeLocationListener) {
|
||||
if (removeLocationListener) {
|
||||
locationServiceManager.unregisterLocationManager();
|
||||
locationServiceManager.removeLocationListener(this);
|
||||
Timber.d("Nearby locked");
|
||||
|
|
@ -256,6 +258,7 @@ public class NearbyParentFragmentPresenter
|
|||
if (locationChangeType.equals(LOCATION_SIGNIFICANTLY_CHANGED)
|
||||
|| locationChangeType.equals(MAP_UPDATED)) {
|
||||
Log.d("denemeTest","1");
|
||||
lockUnlockNearby(true);
|
||||
nearbyParentFragmentView.populatePlaces(lastLocation, lastLocation);
|
||||
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(false);
|
||||
//nearbyMapFragmentView.updateMapToTrackPosition(curLatLng);
|
||||
|
|
@ -264,7 +267,7 @@ public class NearbyParentFragmentPresenter
|
|||
|
||||
} else if (locationChangeType.equals(SEARCH_CUSTOM_AREA)) {
|
||||
Log.d("denemeTest","2");
|
||||
|
||||
lockUnlockNearby(true);
|
||||
nearbyParentFragmentView.populatePlaces(lastLocation, cameraTarget);
|
||||
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(false);
|
||||
searchingThisArea = false;
|
||||
|
|
@ -284,7 +287,20 @@ public class NearbyParentFragmentPresenter
|
|||
*/
|
||||
public void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo, Marker selectedMarker) {
|
||||
nearbyMapFragmentView.updateMapMarkers(nearbyPlacesInfo.curLatLng, nearbyPlacesInfo.placeList, selectedMarker, this);
|
||||
nearbyMapFragmentView.addCurrentLocationMarker(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
|
||||
|
|
@ -343,7 +359,7 @@ public class NearbyParentFragmentPresenter
|
|||
public void onClick(View v) {
|
||||
Log.d("denemeTestt","onSearchThisAreaClicked");
|
||||
// Lock map operations during search this area operation
|
||||
lockNearby(true);
|
||||
// TODO: test lock nearby
|
||||
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(true);
|
||||
// TODO: make this invisible at somewhere
|
||||
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(false);
|
||||
|
|
@ -353,7 +369,7 @@ public class NearbyParentFragmentPresenter
|
|||
updateMapAndList(LOCATION_SIGNIFICANTLY_CHANGED,
|
||||
null);
|
||||
} else {
|
||||
Log.d("denemeTestt","!searchCloseToCurrentLocation()");
|
||||
Log.d("denemeTestt","!searchCloseToCurrentLocation()+"+getCameraTarget());
|
||||
updateMapAndList(SEARCH_CUSTOM_AREA,
|
||||
getCameraTarget());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue