Java Code Examples for android.util.JsonReader#nextDouble()

The following examples show how to use android.util.JsonReader#nextDouble() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AndroidPlacesApiJsonParser.java    From android-PlacesAutocompleteTextView with BSD 2-Clause "Simplified" License 6 votes vote down vote up
PlaceGeometry readGeometry(JsonReader reader) throws IOException {
    double lat = -1.0;
    double lng = -1.0;

    reader.beginObject();
    while (reader.hasNext()) {
        switch (reader.nextName()) {
            case "lat":
                lat = reader.nextDouble();
                break;
            case "lng":
                lng = reader.nextDouble();
                break;
            default:
                reader.skipValue();
                break;
        }
    }
    reader.endObject();
    return new PlaceGeometry(new PlaceLocation(lat, lng));
}
 
Example 2
Source File: GeoPoint.java    From android_maplib with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void setCoordinatesFromJSONStream(JsonReader reader, int crs) throws IOException {
    setCRS(crs);
    reader.beginArray();
    int pos = 0;
    while (reader.hasNext()) {
        if(pos == 0)
            mX = reader.nextDouble();
        else if(pos == 1)
            mY = reader.nextDouble();
        else
            reader.skipValue();
        pos++;
    }
    reader.endArray();
}