Skip to content

Commit

Permalink
Remove lookUpPlacesByIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
tolu360 committed Mar 8, 2019
1 parent cae154d commit 3152653
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 46 deletions.
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"files.exclude": {
"**/.classpath": true,
"**/.project": true,
"**/.settings": true,
"**/.factorypath": true
}
}
17 changes: 17 additions & 0 deletions android/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>android</name>
<comment>Project android created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1
Original file line number Diff line number Diff line change
Expand Up @@ -291,42 +291,6 @@ public void lookUpPlaceByID(String placeID, ReadableArray fields, final Promise
});
}

@ReactMethod
public void lookUpPlacesByIDs(ReadableArray placeIDs, final Promise promise) {
List<Object> placeIDsObjects = placeIDs.toArrayList();
List<String> placeIDsStrings = new ArrayList<>(placeIDsObjects.size());
for (Object item : placeIDsObjects) {
placeIDsStrings.add(Objects.toString(item, null));
}

Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeIDsStrings.toArray(new String[placeIDsStrings.size()]))
.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer places) {
if (places.getStatus().isSuccess()) {
if (places.getCount() == 0) {
WritableMap emptyResult = Arguments.createMap();
places.release();
promise.resolve(emptyResult);
return;
}

WritableArray resultList = processLookupByIDsPlaces(places);

// Release the PlaceBuffer to prevent a memory leak
places.release();

promise.resolve(resultList);
} else {
places.release();
promise.reject("E_PLACE_DETAILS_ERROR",
new Error("Error making place lookup API call: " + places.getStatus().toString()));
return;
}
}
});
}

@ReactMethod
public void getCurrentPlace(ReadableArray fields, final Promise promise) {
if (ContextCompat.checkSelfPermission(this.reactContext.getApplicationContext(), permission.ACCESS_WIFI_STATE)
Expand Down Expand Up @@ -385,16 +349,6 @@ private void findCurrentPlaceWithPermissions(List<Place.Field> selectedFields, f
});
}

private WritableArray processLookupByIDsPlaces(final PlaceBuffer places) {
WritableArray resultList = new WritableNativeArray();

for (Place place : places) {
resultList.pushMap(propertiesMapForPlace(place));
}

return resultList;
}

private WritableMap propertiesMapForPlace(Place place) {
// Display attributions if required.
CharSequence attributions = place.getAttributions();
Expand Down

0 comments on commit 3152653

Please sign in to comment.