Fix search this area button visibility issue

This commit is contained in:
neslihanturan 2019-09-11 16:18:31 +03:00
parent 43b4ac18a6
commit 13695fdb2b
4 changed files with 25 additions and 20 deletions

View file

@ -346,6 +346,7 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
@Override
public void addOnCameraMoveListener(MapboxMap.OnCameraMoveListener onCameraMoveListener) {
Log.d("denemeTestt","on camera move listener is set");
mapFragment.getMapboxMap().addOnCameraMoveListener(onCameraMoveListener);
}
@ -430,8 +431,17 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
@Override
public void populatePlaces(fr.free.nrw.commons.location.LatLng curlatLng, fr.free.nrw.commons.location.LatLng searchLatLng) {
boolean checkingAroundCurretLocation;
if (curlatLng.equals(searchLatLng)) { // Means we are checking around current location
Log.d("denemeTestt","checking around current location1");
checkingAroundCurretLocation = true;
} else {
Log.d("denemeTestt","not checking around current location2");
checkingAroundCurretLocation = false;
}
compositeDisposable.add(Observable.fromCallable(() -> nearbyController
.loadAttractionsFromLocation(curlatLng, searchLatLng, false, true))
.loadAttractionsFromLocation(curlatLng, searchLatLng, false, checkingAroundCurretLocation))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::updateMapMarkers,

View file

@ -44,10 +44,9 @@ public interface NearbyParentFragmentContract {
void initializeNearbyOperations();
void updateMapAndList(LocationServiceManager.LocationChangeType locationChangeType, LatLng cameraTarget);
void lockNearby(boolean isNearbyLocked);
MapboxMap.OnCameraMoveListener onCameraMove(MapboxMap mapboxMap);
void setActionListeners(JsonKvStore applicationKvStore);
MapboxMap.OnCameraMoveListener onCameraMove(LatLng cameraTarget);
MapboxMap.OnCameraMoveListener onCameraMove(MapboxMap mapboxMap);
}
interface ViewsAreReadyCallback {

View file

@ -174,7 +174,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
@Override
public void addSearchThisAreaButtonAction() {
searchThisAreaButton.setOnClickListener(nearbyParentFragmentPresenter.onSearchThisAreaClicked());
//searchThisAreaButton.setOnClickListener(nearbyParentFragmentPresenter.onSearchThisAreaClicked());
}
@Override

View file

@ -119,7 +119,7 @@ public class NearbyParentFragmentPresenter
//nearbyMapFragmentView.setupMapView(null);
//nearbyOperationsInitialized();
this.nearbyParentFragmentView.addSearchThisAreaButtonAction();
this.nearbyParentFragmentView.addOnCameraMoveListener(onCameraMove(getCameraTarget()));
this.nearbyParentFragmentView.addOnCameraMoveListener(onCameraMove(getMapboxMap()));
initializeMapOperations();
}
@ -177,21 +177,6 @@ public class NearbyParentFragmentPresenter
}
public MapboxMap.OnCameraMoveListener onCameraMove(LatLng cameraTarget) {
return new MapboxMap.OnCameraMoveListener() {
@Override
public void onCameraMove() {
// If our nearby markers are calculated at least once
if (NearbyController.currentLocation != null) {
if (nearbyParentFragmentView.isNetworkConnectionEstablished()) {
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(true);
}
}
}
};
}
public void markerUnselected() {
nearbyParentFragmentView.hideBottomSheet();
}
@ -325,17 +310,24 @@ public class NearbyParentFragmentPresenter
Timber.d("Location changed medium");
}
@Override
public MapboxMap.OnCameraMoveListener onCameraMove(MapboxMap mapboxMap) {
Log.d("denemeTestt","cameramoving1");
return () -> {
Log.d("denemeTestt","cameramoving2");
// If our nearby markers are calculated at least once
if (NearbyController.currentLocation != null) {
Log.d("denemeTestt","NearbyController.currentLocation != null");
double distance = mapboxMap.getCameraPosition().target.distanceTo
(LocationUtils.commonsLatLngToMapBoxLatLng(NearbyController.latestSearchLocation));
if (nearbyParentFragmentView.isNetworkConnectionEstablished()) {
if (distance > NearbyController.latestSearchRadius) {
Log.d("denemeTestt","distance > NearbyController.latestSearchRadius");
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(true);
} else {
Log.d("denemeTestt","distance < NearbyController.latestSearchRadius");
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(false);
}
}
@ -349,6 +341,7 @@ public class NearbyParentFragmentPresenter
return new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d("denemeTestt","onSearchThisAreaClicked");
// Lock map operations during search this area operation
lockNearby(true);
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(true);
@ -356,9 +349,11 @@ public class NearbyParentFragmentPresenter
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(false);
if (searchCloseToCurrentLocation()){
Log.d("denemeTestt","searchCloseToCurrentLocation()");
updateMapAndList(LOCATION_SIGNIFICANTLY_CHANGED,
null);
} else {
Log.d("denemeTestt","!searchCloseToCurrentLocation()");
updateMapAndList(SEARCH_CUSTOM_AREA,
getCameraTarget());
}
@ -372,6 +367,7 @@ public class NearbyParentFragmentPresenter
* @return Returns true if search this area button is used around our current location
*/
public boolean searchCloseToCurrentLocation() {
Log.d("denemeTestt","searchCloseToCurrentLocation method");
double distance = LocationUtils.commonsLatLngToMapBoxLatLng(getCameraTarget())
.distanceTo(new com.mapbox.mapboxsdk.geometry.LatLng(NearbyController.currentLocation.getLatitude()
, NearbyController.currentLocation.getLongitude()));