mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Fix search this area button visibility issue
This commit is contained in:
parent
43b4ac18a6
commit
13695fdb2b
4 changed files with 25 additions and 20 deletions
|
|
@ -346,6 +346,7 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addOnCameraMoveListener(MapboxMap.OnCameraMoveListener onCameraMoveListener) {
|
public void addOnCameraMoveListener(MapboxMap.OnCameraMoveListener onCameraMoveListener) {
|
||||||
|
Log.d("denemeTestt","on camera move listener is set");
|
||||||
mapFragment.getMapboxMap().addOnCameraMoveListener(onCameraMoveListener);
|
mapFragment.getMapboxMap().addOnCameraMoveListener(onCameraMoveListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -430,8 +431,17 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void populatePlaces(fr.free.nrw.commons.location.LatLng curlatLng, fr.free.nrw.commons.location.LatLng searchLatLng) {
|
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
|
compositeDisposable.add(Observable.fromCallable(() -> nearbyController
|
||||||
.loadAttractionsFromLocation(curlatLng, searchLatLng, false, true))
|
.loadAttractionsFromLocation(curlatLng, searchLatLng, false, checkingAroundCurretLocation))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(this::updateMapMarkers,
|
.subscribe(this::updateMapMarkers,
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,9 @@ public interface NearbyParentFragmentContract {
|
||||||
void initializeNearbyOperations();
|
void initializeNearbyOperations();
|
||||||
void updateMapAndList(LocationServiceManager.LocationChangeType locationChangeType, LatLng cameraTarget);
|
void updateMapAndList(LocationServiceManager.LocationChangeType locationChangeType, LatLng cameraTarget);
|
||||||
void lockNearby(boolean isNearbyLocked);
|
void lockNearby(boolean isNearbyLocked);
|
||||||
MapboxMap.OnCameraMoveListener onCameraMove(MapboxMap mapboxMap);
|
|
||||||
void setActionListeners(JsonKvStore applicationKvStore);
|
void setActionListeners(JsonKvStore applicationKvStore);
|
||||||
|
|
||||||
MapboxMap.OnCameraMoveListener onCameraMove(LatLng cameraTarget);
|
MapboxMap.OnCameraMoveListener onCameraMove(MapboxMap mapboxMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ViewsAreReadyCallback {
|
interface ViewsAreReadyCallback {
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSearchThisAreaButtonAction() {
|
public void addSearchThisAreaButtonAction() {
|
||||||
searchThisAreaButton.setOnClickListener(nearbyParentFragmentPresenter.onSearchThisAreaClicked());
|
//searchThisAreaButton.setOnClickListener(nearbyParentFragmentPresenter.onSearchThisAreaClicked());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ public class NearbyParentFragmentPresenter
|
||||||
//nearbyMapFragmentView.setupMapView(null);
|
//nearbyMapFragmentView.setupMapView(null);
|
||||||
//nearbyOperationsInitialized();
|
//nearbyOperationsInitialized();
|
||||||
this.nearbyParentFragmentView.addSearchThisAreaButtonAction();
|
this.nearbyParentFragmentView.addSearchThisAreaButtonAction();
|
||||||
this.nearbyParentFragmentView.addOnCameraMoveListener(onCameraMove(getCameraTarget()));
|
this.nearbyParentFragmentView.addOnCameraMoveListener(onCameraMove(getMapboxMap()));
|
||||||
initializeMapOperations();
|
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() {
|
public void markerUnselected() {
|
||||||
nearbyParentFragmentView.hideBottomSheet();
|
nearbyParentFragmentView.hideBottomSheet();
|
||||||
}
|
}
|
||||||
|
|
@ -325,17 +310,24 @@ public class NearbyParentFragmentPresenter
|
||||||
Timber.d("Location changed medium");
|
Timber.d("Location changed medium");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MapboxMap.OnCameraMoveListener onCameraMove(MapboxMap mapboxMap) {
|
public MapboxMap.OnCameraMoveListener onCameraMove(MapboxMap mapboxMap) {
|
||||||
|
Log.d("denemeTestt","cameramoving1");
|
||||||
|
|
||||||
return () -> {
|
return () -> {
|
||||||
|
Log.d("denemeTestt","cameramoving2");
|
||||||
|
|
||||||
// If our nearby markers are calculated at least once
|
// If our nearby markers are calculated at least once
|
||||||
if (NearbyController.currentLocation != null) {
|
if (NearbyController.currentLocation != null) {
|
||||||
|
Log.d("denemeTestt","NearbyController.currentLocation != null");
|
||||||
double distance = mapboxMap.getCameraPosition().target.distanceTo
|
double distance = mapboxMap.getCameraPosition().target.distanceTo
|
||||||
(LocationUtils.commonsLatLngToMapBoxLatLng(NearbyController.latestSearchLocation));
|
(LocationUtils.commonsLatLngToMapBoxLatLng(NearbyController.latestSearchLocation));
|
||||||
if (nearbyParentFragmentView.isNetworkConnectionEstablished()) {
|
if (nearbyParentFragmentView.isNetworkConnectionEstablished()) {
|
||||||
if (distance > NearbyController.latestSearchRadius) {
|
if (distance > NearbyController.latestSearchRadius) {
|
||||||
|
Log.d("denemeTestt","distance > NearbyController.latestSearchRadius");
|
||||||
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(true);
|
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(true);
|
||||||
} else {
|
} else {
|
||||||
|
Log.d("denemeTestt","distance < NearbyController.latestSearchRadius");
|
||||||
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(false);
|
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -349,6 +341,7 @@ public class NearbyParentFragmentPresenter
|
||||||
return new View.OnClickListener() {
|
return new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
Log.d("denemeTestt","onSearchThisAreaClicked");
|
||||||
// Lock map operations during search this area operation
|
// Lock map operations during search this area operation
|
||||||
lockNearby(true);
|
lockNearby(true);
|
||||||
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(true);
|
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(true);
|
||||||
|
|
@ -356,9 +349,11 @@ public class NearbyParentFragmentPresenter
|
||||||
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(false);
|
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(false);
|
||||||
|
|
||||||
if (searchCloseToCurrentLocation()){
|
if (searchCloseToCurrentLocation()){
|
||||||
|
Log.d("denemeTestt","searchCloseToCurrentLocation()");
|
||||||
updateMapAndList(LOCATION_SIGNIFICANTLY_CHANGED,
|
updateMapAndList(LOCATION_SIGNIFICANTLY_CHANGED,
|
||||||
null);
|
null);
|
||||||
} else {
|
} else {
|
||||||
|
Log.d("denemeTestt","!searchCloseToCurrentLocation()");
|
||||||
updateMapAndList(SEARCH_CUSTOM_AREA,
|
updateMapAndList(SEARCH_CUSTOM_AREA,
|
||||||
getCameraTarget());
|
getCameraTarget());
|
||||||
}
|
}
|
||||||
|
|
@ -372,6 +367,7 @@ public class NearbyParentFragmentPresenter
|
||||||
* @return Returns true if search this area button is used around our current location
|
* @return Returns true if search this area button is used around our current location
|
||||||
*/
|
*/
|
||||||
public boolean searchCloseToCurrentLocation() {
|
public boolean searchCloseToCurrentLocation() {
|
||||||
|
Log.d("denemeTestt","searchCloseToCurrentLocation method");
|
||||||
double distance = LocationUtils.commonsLatLngToMapBoxLatLng(getCameraTarget())
|
double distance = LocationUtils.commonsLatLngToMapBoxLatLng(getCameraTarget())
|
||||||
.distanceTo(new com.mapbox.mapboxsdk.geometry.LatLng(NearbyController.currentLocation.getLatitude()
|
.distanceTo(new com.mapbox.mapboxsdk.geometry.LatLng(NearbyController.currentLocation.getLatitude()
|
||||||
, NearbyController.currentLocation.getLongitude()));
|
, NearbyController.currentLocation.getLongitude()));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue