Add some more tests for NearbyController (#4778)

This commit is contained in:
Madhur Gupta 2022-02-01 14:55:49 +05:30 committed by GitHub
parent 15d70bbe0a
commit d77ae8e582
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 325 additions and 41 deletions

View file

@ -1,18 +1,19 @@
package fr.free.nrw.commons.nearby;
import static fr.free.nrw.commons.utils.LengthUtils.computeDistanceBetween;
import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import androidx.annotation.MainThread;
import androidx.annotation.Nullable;
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
import com.mapbox.mapboxsdk.annotations.IconFactory;
import com.mapbox.mapboxsdk.annotations.Marker;
import io.reactivex.Observable;
import java.io.IOException;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.utils.UiUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -20,17 +21,9 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import javax.inject.Inject;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.utils.UiUtils;
import timber.log.Timber;
import static fr.free.nrw.commons.utils.LengthUtils.computeDistanceBetween;
import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
public class NearbyController {
private static final int MAX_RESULTS = 1000;
private final NearbyPlaces nearbyPlaces;
@ -127,11 +120,8 @@ public class NearbyController {
}
return nearbyPlacesInfo;
}
else {
return nearbyPlacesInfo;
}
return nearbyPlacesInfo;
}
/**
@ -151,24 +141,6 @@ public class NearbyController {
checkingAroundCurrentLocation, shouldQueryForMonuments, null);
}
/**
* Loads attractions from location for list view, we need to return Place data type.
*
* @param curLatLng users current location
* @param placeList list of nearby places in Place data type
* @return Place list that holds nearby places
*/
public static List<Place> loadAttractionsFromLocationToPlaces(
LatLng curLatLng,
List<Place> placeList) {
placeList = placeList.subList(0, Math.min(placeList.size(), MAX_RESULTS));
for (Place place : placeList) {
String distance = formatDistanceBetween(curLatLng, place.location);
place.setDistance(distance);
}
return placeList;
}
/**
* Loads attractions from location for map view, we need to return BaseMarkerOption data type.
*