List of usage examples for android.util JsonReader nextBoolean
public boolean nextBoolean() throws IOException
From source file:com.fuzz.android.limelight.util.JSONTool.java
/** * @param reader/* w w w.j ava 2 s. c o m*/ * @return the generated ChapterTransition object from JSON * @throws IOException */ public static ChapterTransition readTransition(JsonReader reader) throws IOException { long time = -1; int itemPosition = -1; int childId = -1; int anchorId = -1; String message = null; int messageResId = -1; int grapicResID = -1; boolean isActionBarItem = false; double xOffset = -1; double yOffset = -1; int textColor = -1; int textBackgroundColor = -1; float textSize = -1; boolean textBackgroundTransparent = false; String animation = null; while (reader.hasNext()) { try { String name = reader.nextName(); if (name.equals("time")) time = reader.nextLong(); else if (name.equals("item_position")) itemPosition = reader.nextInt(); else if (name.equals("child_id")) childId = reader.nextInt(); else if (name.equals("id")) anchorId = reader.nextInt(); else if (name.equals("message")) message = reader.nextString(); else if (name.equals("message_res_id")) messageResId = reader.nextInt(); else if (name.equals("graphic_res_id")) grapicResID = reader.nextInt(); else if (name.equals("is_action_bar_item")) isActionBarItem = reader.nextBoolean(); else if (name.equals("x_offset")) xOffset = reader.nextDouble(); else if (name.equals("y_offset")) yOffset = reader.nextDouble(); else if (name.equals("text_color")) textColor = reader.nextInt(); else if (name.equals("text_background_color")) textBackgroundColor = reader.nextInt(); else if (name.equals("text_size")) textSize = reader.nextLong(); else if (name.equals("text_background_transparent")) textBackgroundTransparent = reader.nextBoolean(); else if (name.equals("animation")) animation = reader.nextString(); } catch (IllegalStateException e) { reader.nextNull(); e.printStackTrace(); } } reader.endObject(); ChapterTransition transition = new ChapterTransition(); transition.setTime(time); transition.setItemPosition(itemPosition); transition.setChildID(childId); transition.setId(anchorId); transition.setMessage(message); transition.setMessageResID(messageResId); transition.setGraphicResID(grapicResID); transition.setIsActionBarItem(isActionBarItem); transition.setDisplacement(xOffset, yOffset); transition.setTextColor(textColor); transition.setTextBackgroundColor(textBackgroundColor); transition.setTextSize(textSize); transition.setTransparentBackground(textBackgroundTransparent); transition.setAnimation(animation); return transition; }
From source file:at.ac.tuwien.caa.docscan.logic.DataLog.java
private ShotLog readShotLog(JsonReader reader) throws IOException, ParseException { GPS gps = null;//from w w w . j av a2 s. c o m String dateString, fileName = null; Date date = null; boolean seriesMode = false; reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals(FILE_NAME)) { fileName = reader.nextString(); } else if (name.equals(DATE_NAME)) { dateString = reader.nextString(); if (dateString != null) date = string2Date(dateString); } else if (name.equals(GPS_NAME)) { gps = readGPS(reader); } else if (name.equals(SERIES_MODE_NAME)) { seriesMode = reader.nextBoolean(); } } reader.endObject(); ShotLog shotLog = new ShotLog(fileName, gps, date, seriesMode); return shotLog; }
From source file:com.dalaran.async.task.http.AbstractHTTPService.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) protected List<ContentValues> parseJson(JsonReader reader) throws IOException { List<ContentValues> contentValueses = new ArrayList<ContentValues>(); ContentValues values = new ContentValues(); Long threadId = 0L;//from w ww.java2 s. c o m boolean notEnd = true; String name = ""; if (reader.hasNext()) { //todo android.util.MalformedJsonException: Use JsonReader.setLenient(true) do { switch (reader.peek()) { case BEGIN_OBJECT: values = new ContentValues(); if (threadId != 0) { values.put("threadId", threadId); } reader.beginObject(); break; case BEGIN_ARRAY: if (values != null && values.getAsLong("threadId") != null) { threadId = values.getAsLong("threadId"); } reader.beginArray(); break; case BOOLEAN: values.put(name, reader.nextBoolean()); break; case END_ARRAY: reader.endArray(); break; case END_DOCUMENT: notEnd = false; break; case END_OBJECT: contentValueses.add(values); reader.endObject(); break; case NAME: name = reader.nextName(); break; case NULL: reader.nextNull(); break; case NUMBER: values.put(name, reader.nextDouble()); break; case STRING: values.put(name, reader.nextString()); break; default: reader.skipValue(); } } while (notEnd); } return contentValueses; }