本文整理匯總了Java中android.util.JsonReader.nextDouble方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonReader.nextDouble方法的具體用法?Java JsonReader.nextDouble怎麽用?Java JsonReader.nextDouble使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.util.JsonReader
的用法示例。
在下文中一共展示了JsonReader.nextDouble方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parse
import android.util.JsonReader; //導入方法依賴的package包/類
@Override public Integer parse(JsonReader reader, float scale) throws IOException {
boolean isArray = reader.peek() == JsonToken.BEGIN_ARRAY;
if (isArray) {
reader.beginArray();
}
double r = reader.nextDouble();
double g = reader.nextDouble();
double b = reader.nextDouble();
double a = reader.nextDouble();
if (isArray) {
reader.endArray();
}
if (r <= 1 && g <= 1 && b <= 1 && a <= 1) {
r *= 255;
g *= 255;
b *= 255;
a *= 255;
}
return Color.argb((int) a, (int) r, (int) g, (int) b);
}
示例2: parse
import android.util.JsonReader; //導入方法依賴的package包/類
@Override public PointF parse(JsonReader reader, float scale) throws IOException {
JsonToken token = reader.peek();
if (token == JsonToken.BEGIN_ARRAY) {
return JsonUtils.jsonToPoint(reader, scale);
} else if (token == JsonToken.BEGIN_OBJECT) {
return JsonUtils.jsonToPoint(reader, scale);
} else if (token == JsonToken.NUMBER) {
// This is the case where the static value for a property is an array of numbers.
// We begin the array to see if we have an array of keyframes but it's just an array
// of static numbers instead.
PointF point = new PointF((float) reader.nextDouble() * scale, (float) reader.nextDouble() * scale);
while (reader.hasNext()) {
reader.skipValue();
}
return point;
} else {
throw new IllegalArgumentException("Cannot convert json to point. Next token is " + token);
}
}
示例3: valueFromObject
import android.util.JsonReader; //導入方法依賴的package包/類
static float valueFromObject(JsonReader reader) throws IOException {
JsonToken token = reader.peek();
switch (token) {
case NUMBER:
return (float) reader.nextDouble();
case BEGIN_ARRAY:
reader.beginArray();
float val = (float) reader.nextDouble();
while (reader.hasNext()) {
reader.skipValue();
}
reader.endArray();
return val;
default:
throw new IllegalArgumentException("Unknown value for token of type " + token);
}
}
示例4: readValue
import android.util.JsonReader; //導入方法依賴的package包/類
/** Reads the next value in the {@link JsonReader}. */
private static Object readValue(JsonReader reader) throws IOException {
JsonToken token = reader.peek();
switch (token) {
case BEGIN_OBJECT:
return readerToMap(reader);
case BEGIN_ARRAY:
return readerToList(reader);
case BOOLEAN:
return reader.nextBoolean();
case NULL:
reader.nextNull(); // consume the null token
return null;
case NUMBER:
return reader.nextDouble();
case STRING:
return reader.nextString();
default:
throw new IllegalStateException("Invalid token " + token);
}
}
示例5: deSerializeRepresentation
import android.util.JsonReader; //導入方法依賴的package包/類
@Override
public void deSerializeRepresentation(JsonReader reader) throws IOException {
boolean unset = true;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
if (SERIALIZATION_STRAIGHTEN_VALUE.equals(name)) {
float s = (float) reader.nextDouble();
if (rangeCheck(s)) {
setStraighten(s);
unset = false;
}
} else {
reader.skipValue();
}
}
if (unset) {
Log.w(TAG, "WARNING: bad value when deserializing " + SERIALIZATION_NAME);
}
reader.endObject();
}
示例6: deSerializeRepresentation
import android.util.JsonReader; //導入方法依賴的package包/類
@Override
public void deSerializeRepresentation(JsonReader reader) throws IOException {
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
if (BOUNDS[0].equals(name)) {
mCrop.left = (float) reader.nextDouble();
} else if (BOUNDS[1].equals(name)) {
mCrop.top = (float) reader.nextDouble();
} else if (BOUNDS[2].equals(name)) {
mCrop.right = (float) reader.nextDouble();
} else if (BOUNDS[3].equals(name)) {
mCrop.bottom = (float) reader.nextDouble();
} else {
reader.skipValue();
}
}
reader.endObject();
}
示例7: readGeometry
import android.util.JsonReader; //導入方法依賴的package包/類
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));
}
示例8: parse
import android.util.JsonReader; //導入方法依賴的package包/類
private List<Currency> parse(Pair<Reader, HttpURLConnection> in) {
List<Currency> currencies = new ArrayList<>();
try {
JsonReader jsonReader = new JsonReader(in.first);
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (name.equals("rates")) {
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String id = jsonReader.nextName();
if (id.matches("CAD|EUR|GBP|JPY|USD")) {
double rate = jsonReader.nextDouble();
currencies.add(new Currency(id, rate, CurrencyUtil.getLocale(id)));
} else jsonReader.skipValue();
}
jsonReader.endObject();
} else jsonReader.skipValue();
}
jsonReader.endObject();
jsonReader.close(); //not in finally cuz we're don't in this test :)
} catch (Exception e) {
e.printStackTrace();
} finally {
in.second.disconnect();
}
return currencies;
}
示例9: parse
import android.util.JsonReader; //導入方法依賴的package包/類
@Override public ScaleXY parse(JsonReader reader, float scale) throws IOException {
boolean isArray = reader.peek() == JsonToken.BEGIN_ARRAY;
if (isArray) {
reader.beginArray();
}
float sx = (float) reader.nextDouble();
float sy = (float) reader.nextDouble();
while (reader.hasNext()) {
reader.skipValue();
}
if (isArray) {
reader.endArray();
}
return new ScaleXY(sx / 100f * scale, sy / 100f * scale);
}
示例10: parse
import android.util.JsonReader; //導入方法依賴的package包/類
static Font parse(JsonReader reader) throws IOException {
String family = null;
String name = null;
String style = null;
float ascent = 0;
reader.beginObject();
while (reader.hasNext()) {
switch (reader.nextName()) {
case "fFamily":
family = reader.nextString();
break;
case "fName":
name = reader.nextString();
break;
case "fStyle":
style = reader.nextString();
break;
case "ascent":
ascent = (float) reader.nextDouble();
break;
default:
reader.skipValue();
}
}
reader.endObject();
return new Font(family, name, style, ascent);
}
示例11: jsonToColor
import android.util.JsonReader; //導入方法依賴的package包/類
/**
* [r,g,b]
*/
@ColorInt static int jsonToColor(JsonReader reader) throws IOException {
reader.beginArray();
int r = (int) (reader.nextDouble() * 255);
int g = (int) (reader.nextDouble() * 255);
int b = (int) (reader.nextDouble() * 255);
while (reader.hasNext()) {
reader.skipValue();
}
reader.endArray();
return Color.argb(255, r, g, b);
}
示例12: jsonNumbersToPoint
import android.util.JsonReader; //導入方法依賴的package包/類
private static PointF jsonNumbersToPoint(JsonReader reader, float scale) throws IOException {
float x = (float) reader.nextDouble();
float y = (float) reader.nextDouble();
while (reader.hasNext()) {
reader.skipValue();
}
return new PointF(x * scale, y * scale);
}
示例13: jsonArrayToPoint
import android.util.JsonReader; //導入方法依賴的package包/類
private static PointF jsonArrayToPoint(JsonReader reader, float scale) throws IOException {
float x;
float y;
reader.beginArray();
x = (float) reader.nextDouble();
y = (float) reader.nextDouble();
while (reader.peek() != JsonToken.END_ARRAY) {
reader.skipValue();
}
reader.endArray();
return new PointF(x * scale, y * scale);
}
示例14: deSerializeRepresentation
import android.util.JsonReader; //導入方法依賴的package包/類
@Override
public void deSerializeRepresentation(JsonReader sreader) throws IOException {
sreader.beginObject();
Spline[] spline = new Spline[MAX_SPLINE_NUMBER];
while (sreader.hasNext()) {
String name = sreader.nextName();
if (NAME_TAG.equals(name)) {
setName(sreader.nextString());
} else if (name.startsWith(SERIALIZATION_NAME)) {
int curveNo = Integer.parseInt(name.substring(SERIALIZATION_NAME.length()));
spline[curveNo] = new Spline();
sreader.beginArray();
while (sreader.hasNext()) {
sreader.beginArray();
sreader.hasNext();
float x = (float) sreader.nextDouble();
sreader.hasNext();
float y = (float) sreader.nextDouble();
sreader.endArray();
spline[curveNo].addPoint(x, y);
}
sreader.endArray();
}
}
mSplines = spline;
sreader.endObject();
}
示例15: deSerializeRepresentation
import android.util.JsonReader; //導入方法依賴的package包/類
@Override
public void deSerializeRepresentation(JsonReader sreader) throws IOException {
sreader.beginObject();
while (sreader.hasNext()) {
String name = sreader.nextName();
if (name.startsWith(ELLIPSE)) {
sreader.beginArray();
sreader.hasNext();
mCenterX = (float) sreader.nextDouble();
sreader.hasNext();
mCenterY = (float) sreader.nextDouble();
sreader.hasNext();
mRadiusX = (float) sreader.nextDouble();
sreader.hasNext();
mRadiusY = (float) sreader.nextDouble();
sreader.hasNext();
sreader.endArray();
} else if (name.startsWith(ARGS)) {
sreader.beginArray();
sreader.hasNext();
mParamVignette.setValue(sreader.nextInt());
sreader.hasNext();
mParamExposure.setValue(sreader.nextInt());
sreader.hasNext();
mParamSaturation.setValue(sreader.nextInt());
sreader.hasNext();
mParamContrast.setValue(sreader.nextInt());
sreader.hasNext();
mParamFalloff.setValue(sreader.nextInt());
sreader.hasNext();
sreader.endArray();
} else {
sreader.skipValue();
}
}
sreader.endObject();
}