mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Fix Codacy issues
This commit is contained in:
parent
08501b9348
commit
f9fd354d00
3 changed files with 27 additions and 5 deletions
|
|
@ -24,6 +24,7 @@ import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
|
||||||
|
|
||||||
public class NearbyController {
|
public class NearbyController {
|
||||||
private static final int MAX_RESULTS = 1000;
|
private static final int MAX_RESULTS = 1000;
|
||||||
|
|
||||||
private static List<Place> loadAttractionsFromLocation(LatLng curLatLng, Context context) {
|
private static List<Place> loadAttractionsFromLocation(LatLng curLatLng, Context context) {
|
||||||
Timber.d("Loading attractions near %s", curLatLng);
|
Timber.d("Loading attractions near %s", curLatLng);
|
||||||
if (curLatLng == null) {
|
if (curLatLng == null) {
|
||||||
|
|
@ -53,6 +54,14 @@ public class NearbyController {
|
||||||
}
|
}
|
||||||
return places;
|
return places;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads attractions from location for list view, we need to return Place data type
|
||||||
|
* @param curLatLng
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
|
||||||
public static List<Place> loadAttractionsFromLocationToPlaces(LatLng curLatLng, Context context) {
|
public static List<Place> loadAttractionsFromLocationToPlaces(LatLng curLatLng, Context context) {
|
||||||
|
|
||||||
List<Place> places = loadAttractionsFromLocation(curLatLng,context);
|
List<Place> places = loadAttractionsFromLocation(curLatLng,context);
|
||||||
|
|
@ -63,7 +72,16 @@ public class NearbyController {
|
||||||
}
|
}
|
||||||
return places;
|
return places;
|
||||||
}
|
}
|
||||||
public static List<BaseMarkerOptions> loadAttractionsFromLocationToBaseMarkerOptions(LatLng curLatLng, Context context){
|
|
||||||
|
/**
|
||||||
|
*Loads attractions from location for map view, we need to return BaseMarkerOption data type
|
||||||
|
* @param curLatLng
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<BaseMarkerOptions> loadAttractionsFromLocationToBaseMarkerOptions(
|
||||||
|
LatLng curLatLng,
|
||||||
|
Context context) {
|
||||||
List<BaseMarkerOptions> baseMarkerOptionses = new ArrayList<>();
|
List<BaseMarkerOptions> baseMarkerOptionses = new ArrayList<>();
|
||||||
List<Place> places = loadAttractionsFromLocation(curLatLng,context);
|
List<Place> places = loadAttractionsFromLocation(curLatLng,context);
|
||||||
places = places.subList(0, Math.min(places.size(), MAX_RESULTS));
|
places = places.subList(0, Math.min(places.size(), MAX_RESULTS));
|
||||||
|
|
@ -71,7 +89,8 @@ public class NearbyController {
|
||||||
String distance = formatDistanceBetween(curLatLng, place.location);
|
String distance = formatDistanceBetween(curLatLng, place.location);
|
||||||
place.setDistance(distance);
|
place.setDistance(distance);
|
||||||
baseMarkerOptionses.add(new MarkerOptions()
|
baseMarkerOptionses.add(new MarkerOptions()
|
||||||
.position(new com.mapbox.mapboxsdk.geometry.LatLng(place.location.latitude,place.location.longitude))
|
.position(new com.mapbox.mapboxsdk.geometry
|
||||||
|
.LatLng(place.location.latitude,place.location.longitude))
|
||||||
.title(place.name)
|
.title(place.name)
|
||||||
.snippet(place.description));
|
.snippet(place.description));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,9 @@ public class NearbyListFragment extends ListFragment {
|
||||||
@Override
|
@Override
|
||||||
protected List<Place> doInBackground(Void... params) {
|
protected List<Place> doInBackground(Void... params) {
|
||||||
return NearbyController.loadAttractionsFromLocationToPlaces(
|
return NearbyController.loadAttractionsFromLocationToPlaces(
|
||||||
((NearbyActivity)getActivity()).getLocationManager().getLatestLocation(), getActivity()
|
((NearbyActivity)getActivity())
|
||||||
|
.getLocationManager()
|
||||||
|
.getLatestLocation(), getActivity()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,8 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<BaseMarkerOptions> doInBackground(Void... params) {
|
protected List<BaseMarkerOptions> doInBackground(Void... params) {
|
||||||
return NearbyController.loadAttractionsFromLocationToBaseMarkerOptions(currentLocation, getActivity()
|
return NearbyController
|
||||||
|
.loadAttractionsFromLocationToBaseMarkerOptions(currentLocation, getActivity()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue