Feature/nearby io fix (#1847)

* Bug fix issue #1839, changes
* Extracted out PageTitle object's member varaible, displayText in a variable in findTemplate() in MediaDataExtractor
* added null checks for the same varaible [Lets be safe side]
* replaced equals with contains, ie. displayText.contains(title), so that uploads from multiple sources which have different formats still show up coordinates which was not being shown earlier

* Bug fix issue #1846
1. Added null check in places in loadAttractionsFromLocation() in NearbyController
2. Catched exception in getFromWikidataQuery() which getFromWikidataQuery( )[Could be because of anything, primarily io].

* code formatting, adjusted whitespaces

* return places which is initialised to empty list instead of null for places

* replace catching Exception with the excact exception, ie. InterruptedIOException in NearbyPlaces
This commit is contained in:
Ashish Kumar 2018-08-24 22:36:23 +05:30 committed by Vivek Maskara
parent 4baabab960
commit 355c4f5b0a
2 changed files with 8 additions and 2 deletions

View file

@ -55,7 +55,7 @@ public class NearbyController {
}
List<Place> places = nearbyPlaces.getFromWikidataQuery(curLatLng, Locale.getDefault().getLanguage());
if (places.size() > 0) {
if (null != places && places.size() > 0) {
LatLng[] boundaryCoordinates = {places.get(0).location, // south
places.get(0).location, // north
places.get(0).location, // west

View file

@ -5,6 +5,7 @@ import android.net.Uri;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InterruptedIOException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
@ -45,7 +46,12 @@ public class NearbyPlaces {
// increase the radius gradually to find a satisfactory number of nearby places
while (radius <= MAX_RADIUS) {
places = getFromWikidataQuery(curLatLng, lang, radius);
try {
places = getFromWikidataQuery(curLatLng, lang, radius);
} catch (InterruptedIOException e) {
Timber.d("exception in fetching nearby places", e.getLocalizedMessage());
return places;
}
Timber.d("%d results at radius: %f", places.size(), radius);
if (places.size() >= MIN_RESULTS) {
break;