mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Merge pull request #673 from tobias47n9e/bugfix/nearby-crash
Fix crash of nearby list when the places list is null
This commit is contained in:
commit
0112a09a70
2 changed files with 67 additions and 4 deletions
|
|
@ -84,14 +84,20 @@ public class NearbyController {
|
|||
*Loads attractions from location for map view, we need to return BaseMarkerOption data type.
|
||||
* @param curLatLng users current location
|
||||
* @param placeList list of nearby places in Place data type
|
||||
* @return BaseMarkerOprions list that holds nearby places
|
||||
* @return BaseMarkerOptions list that holds nearby places
|
||||
*/
|
||||
public static List<NearbyBaseMarker> loadAttractionsFromLocationToBaseMarkerOptions(
|
||||
LatLng curLatLng,
|
||||
List<Place> placeList,
|
||||
Context context) {
|
||||
List<NearbyBaseMarker> baseMarkerOptionses = new ArrayList<>();
|
||||
List<NearbyBaseMarker> baseMarkerOptions = new ArrayList<>();
|
||||
|
||||
if (placeList == null) {
|
||||
return baseMarkerOptions;
|
||||
}
|
||||
|
||||
placeList = placeList.subList(0, Math.min(placeList.size(), MAX_RESULTS));
|
||||
|
||||
for (Place place: placeList) {
|
||||
String distance = formatDistanceBetween(curLatLng, place.location);
|
||||
place.setDistance(distance);
|
||||
|
|
@ -108,8 +114,8 @@ public class NearbyController {
|
|||
nearbyBaseMarker.place(place);
|
||||
nearbyBaseMarker.icon(icon);
|
||||
|
||||
baseMarkerOptionses.add(nearbyBaseMarker);
|
||||
baseMarkerOptions.add(nearbyBaseMarker);
|
||||
}
|
||||
return baseMarkerOptionses;
|
||||
return baseMarkerOptions;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue