當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonReader.nextLong方法代碼示例

本文整理匯總了Java中android.util.JsonReader.nextLong方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonReader.nextLong方法的具體用法?Java JsonReader.nextLong怎麽用?Java JsonReader.nextLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.util.JsonReader的用法示例。


在下文中一共展示了JsonReader.nextLong方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parse

import android.util.JsonReader; //導入方法依賴的package包/類
PodcastLayoutContent parse(Reader reader, URI uri) throws IOException {
    JsonReader parser = new JsonReader(reader);

    long id = 0;
    String name = null;

    long nextPage = 0;

    Records records = null;

    parser.beginObject();
    while (parser.hasNext()) {
        String prop = parser.nextName();
        if (ID_PROPERTY.equals(prop)) {
            id = parser.nextLong();
        } else if (TITLE_PROPERTY.equals(prop)) {
            name = StringUtils.nonEmpty(parser.nextString());
        } else if (NEXT_PAGE_PROPERTY.equals(prop)) {
            if (parser.peek() == JsonToken.NUMBER) {
                nextPage = parser.nextLong();
            } else {
                parser.skipValue();
            }
        } else if (RECORDS_PROPERTY.equals(prop)) {
            records = parseRecords(parser, uri);
        } else {
            parser.skipValue();
        }
    }
    parser.endObject();

    Podcast podcast = null;
    if (id != 0 && name != null) {
        podcast = new Podcast(id, name);
    }
    return new PodcastLayoutContent(podcast, records == null ? new Records() : records, nextPage);
}
 
開發者ID:kalikov,項目名稱:lighthouse,代碼行數:38,代碼來源:PodcastJsonParser.java

示例2: parseSetJson

import android.util.JsonReader; //導入方法依賴的package包/類
RowData parseSetJson( JsonReader reader ) throws IOException {
	reader.beginObject();
	RowData rowData = new RowData();

	while ( reader.hasNext() ) {
		String name = reader.nextName();
		if ( name.equals( "title" )) {
			rowData.name = reader.nextString();
		}
		else if ( name.equals( "description" )) {
			rowData.description = reader.nextString();
			if (rowData.description.length()>200) rowData.description = rowData.description.substring(0,100);
		}
		else if ( name.equals( "id" )) {
			rowData.id = reader.nextInt();
		}
		else if ( name.equals( "term_count" )) {
			rowData.numCards = reader.nextInt();
		}
		else if ( name.equals( "modified_date" )) {
			long value = reader.nextLong();
			rowData.lastModified = Data.SHORT_DATE_FORMAT.format( new Date( value * 1000 ) );
			Log.d( Data.APP_ID, " modified_date   value=" + value + " formatted=" + rowData.lastModified + " now=" + (new Date().getTime())  );
		}
		else {
			reader.skipValue();
		}
	}
	reader.endObject();
	return rowData ;
}
 
開發者ID:jhmgbl,項目名稱:learnforandroidfragAS,代碼行數:32,代碼來源:fragFileChooserQuizlet.java

示例3: initializeAssets

import android.util.JsonReader; //導入方法依賴的package包/類
private void initializeAssets(final JsonReader reader) throws IOException {
    long mySize = 0;
    boolean isValid = false;
    String myUrl = null;

    reader.beginArray();
    while (reader.hasNext()) {
        reader.beginObject();
        while (reader.hasNext()) {
            switch (reader.nextName()) {
                default:
                    reader.skipValue();
                    break;
                case "size":
                    mySize = reader.nextLong();
                    break;
                case "state":
                    isValid = "uploaded".equals(reader.nextString());
                    break;
                case "browser_download_url":
                    myUrl = reader.nextString();
                    break;
            }
        }
        reader.endObject();
    }
    reader.endArray();

    if (isValid) {
        size = mySize;
        url = myUrl;
    } else {
        throw new IOException("APK not yet uploaded, please wait a few minutes");
    }
}
 
開發者ID:kennytm,項目名稱:CatSaver,代碼行數:36,代碼來源:ReleaseInfo.java

示例4: parseRecord

import android.util.JsonReader; //導入方法依賴的package包/類
@Nullable
private static Record parseRecord(JsonReader parser, @Nullable URI uri) throws IOException {
    long id = 0;
    String url = null;
    String name = null;
    String description = null;
    String date = null;
    String duration = null;

    parser.beginObject();
    while (parser.hasNext()) {
        String prop = parser.nextName();
        if (AUDIO_PROPERTY.equals(prop)) {
            parser.beginArray();
            if (parser.hasNext()) {
                parser.beginObject();
                while (parser.hasNext()) {
                    String audioProp = parser.nextName();
                    if (SOURCES_PROPERTY.equals(audioProp)) {
                        parser.beginObject();
                        while (parser.hasNext()) {
                            String sourcesProp = parser.nextName();
                            if (URL_PROPERTY.equals(sourcesProp)) {
                                url = StringUtils.nonEmpty(parser.nextString());
                            } else {
                                parser.skipValue();
                            }
                        }
                        parser.endObject();
                    } else if (ID_PROPERTY.equals(audioProp)) {
                        id = parser.nextLong();
                    } else if (DATE_PROPERTY.equals(audioProp)) {
                        date = extractDate(parser.nextString());
                    } else if (DURATION_PROPERTY.equals(audioProp)) {
                        duration = extractDuration(parser.nextString());
                    } else {
                        parser.skipValue();
                    }
                }
                parser.endObject();
            }
            while (parser.hasNext()) {
                parser.skipValue();
            }
            parser.endArray();
        } else if (NAME_PROPERTY.equals(prop)) {
            name = StringUtils.nonEmpty(parser.nextString());
        } else if (DESCRIPTION_PROPERTY.equals(prop)) {
            description = StringUtils.nonEmpty(parser.nextString());
            if (description != null) {
                description = LayoutUtils.clean(description);
            }
        } else {
            parser.skipValue();
        }
    }
    parser.endObject();

    if (url == null || name == null) {
        return null;
    }
    if (id == 0) {
        id = StringUtils.parseLong(extractId(url), 0);
        if (id == 0) {
            return null;
        }
    }
    Record record = new Record(id, name, url, uri);
    record.setDescription(description);
    record.setDate(date);
    record.setDuration(duration);
    return record;
}
 
開發者ID:kalikov,項目名稱:lighthouse,代碼行數:74,代碼來源:PodcastJsonParser.java

示例5: readReviewsArray

import android.util.JsonReader; //導入方法依賴的package包/類
List<PlaceReview> readReviewsArray(JsonReader reader) throws IOException {
    List<PlaceReview> reviews = new ArrayList<>();

    reader.beginArray();
    while (reader.hasNext()) {
        List<RatingAspect> aspects = null;
        String authorName = null;
        String authorUrl = null;
        String language = null;
        int rating = -1;
        String text = null;
        long time = -1L;

        reader.beginObject();
        while (reader.hasNext()) {
            switch (reader.nextName()) {
                case "aspects":
                    aspects = readAspectsArray(reader);
                    break;
                case "author_name":
                    authorName = reader.nextString();
                    break;
                case "author_url":
                    authorUrl = reader.nextString();
                    break;
                case "language":
                    language = reader.nextString();
                    break;
                case "rating":
                    rating = reader.nextInt();
                    break;
                case "text":
                    text = reader.nextString();
                    break;
                case "time":
                    time = reader.nextLong();
                    break;
                default:
                    reader.skipValue();
                    break;
            }
        }
        reader.endObject();
        reviews.add(new PlaceReview(aspects, authorName, authorUrl, language, rating, text, time));
    }
    reader.endArray();
    return reviews;
}
 
開發者ID:seatgeek,項目名稱:android-PlacesAutocompleteTextView,代碼行數:49,代碼來源:AndroidPlacesApiJsonParser.java

示例6: parseSetDataJson

import android.util.JsonReader; //導入方法依賴的package包/類
typVok parseSetDataJson( JsonReader reader ) throws IOException {
	reader.beginObject();
	typVok rowData = new typVok();

	while ( reader.hasNext() ) {
		String name = reader.nextName();
		if ( name.equals( "term" )) {
			rowData.Wort = reader.nextString();
		}
		else if ( name.equals( "id" )) {
			long id = reader.nextLong();
			rowData.z = 0;
		}
		else if ( name.equals( "definition" )) {
			rowData.Bed1 = reader.nextString();
			rowData.Bed2 = "";
			rowData.Bed3 = "";
		}
		else if ( name.equals( "image" )) {
			try
			{
				reader.beginObject();
				while ( reader.hasNext() ) {
					String strName = reader.nextName();
					if ( strName.equals( "url" )) {
						String value = "<link://" + reader.nextString() + " " + _main.getString(R.string.picture) +  "/>";
						rowData.Kom = value;
					}
					else
					{
						reader.skipValue();
					}
				}
				reader.endObject();
			}
			catch (Throwable exception)
			{
				reader.skipValue();
				//String value = "<link://" + reader.nextString() + "/>";
				//rowData.Kom = value;
			}

		}
		else {
			reader.skipValue();
		}
	}
	reader.endObject();
	if (lib.libString.IsNullOrEmpty(rowData.Bed1)) {
		rowData.Bed1 = rowData.Kom;
		rowData.Bed2 = "";
		rowData.Bed3 = "";
	}
	return rowData ;
}
 
開發者ID:jhmgbl,項目名稱:learnforandroidfragAS,代碼行數:56,代碼來源:fragFileChooserQuizlet.java

示例7: load

import android.util.JsonReader; //導入方法依賴的package包/類
@Override
public boolean load() {
    clear();
    try {
        InputStream in = SIAApp.SIA_APP.openFileInput("news");
        JsonReader reader = new JsonReader(new InputStreamReader(in));
        reader.beginArray();
        while(reader.hasNext()) {
            reader.beginObject();
            Entry s = new Entry();

            while(reader.hasNext()) {
                String name = reader.nextName();
                switch (name) {
                    case "id":
                        s.id = reader.nextString();
                        break;
                    case "date":
                        s.date = new Date(reader.nextLong());
                        break;
                    case "topic":
                        s.topic = reader.nextString();
                        break;
                    case "source":
                        s.source = reader.nextString();
                        break;
                    case "title":
                        s.title = reader.nextString();
                        break;
                    case "text":
                        s.text = reader.nextString();
                        break;
                    default:
                        reader.skipValue();
                        break;
                }
            }
            reader.endObject();
            add(s);
        }
        reader.endArray();
        reader.close();
    } catch(Exception e) {
        Log.w("ggvp", "News file does not exist");
        return false;
    }

    return true;
}
 
開發者ID:Cedgetec,項目名稱:SchulinfoApp-android,代碼行數:50,代碼來源:News.java

示例8: load

import android.util.JsonReader; //導入方法依賴的package包/類
public boolean load() {
    clear();
    try {
        InputStream in = SIAApp.SIA_APP.openFileInput("exams");
        JsonReader reader = new JsonReader(new InputStreamReader(in));
        reader.beginArray();
        while(reader.hasNext()) {
            reader.beginObject();
            ExamItem s = new ExamItem();

            while(reader.hasNext()) {
                String name = reader.nextName();
                switch (name) {
                    case "date":
                        s.date = new Date(reader.nextLong());
                        break;
                    case "clazz":
                        s.clazz = reader.nextString();
                        break;
                    case "lesson":
                        s.lesson = reader.nextString();
                        break;
                    case "length":
                        s.length = reader.nextString();
                        break;
                    case "subject":
                        s.subject = reader.nextString();
                        break;
                    case "teacher":
                        s.teacher = reader.nextString();
                        break;
                    case "selected":
                        s.selected = reader.nextBoolean();
                        break;
                    default:
                        reader.skipValue();
                        break;
                }
            }
            reader.endObject();
            add(s);
        }
        reader.endArray();
        reader.close();
    } catch(Exception e) {
        Log.w("ggvp", "Exams file does not exist");
        return false;
    }

    return true;
}
 
開發者ID:Cedgetec,項目名稱:SchulinfoApp-android,代碼行數:52,代碼來源:Exams.java

示例9: load

import android.util.JsonReader; //導入方法依賴的package包/類
public void load(String file) throws Exception {
    clear();
    special.clear();

    InputStream in = SIAApp.SIA_APP.openFileInput(file);
    JsonReader reader = new JsonReader(new InputStreamReader(in));
    reader.beginObject();
    while(reader.hasNext()) {
        String name = reader.nextName();
        switch (name) {
            case "date":
                date = new Date(reader.nextLong());
                break;
            case "messages":
                reader.beginArray();
                while (reader.hasNext()) {
                    special.add(reader.nextString());
                }
                reader.endArray();
                break;
            case "entries":
                reader.beginArray();
                while (reader.hasNext()) {
                    reader.beginObject();
                    Entry e = new Entry();
                    e.date = date;
                    while (reader.hasNext()) {
                        String name2 = reader.nextName();
                        switch (name2) {
                            case "class":
                                e.clazz = reader.nextString();
                                break;
                            case "lesson":
                                e.lesson = reader.nextString();
                                break;
                            case "teacher":
                                e.teacher = reader.nextString();
                                break;
                            case "subject":
                                e.subject = reader.nextString();
                                break;
                            case "comment":
                                e.comment = reader.nextString();
                                break;
                            case "type":
                                e.type = reader.nextString();
                                break;
                            case "room":
                                e.room = reader.nextString();
                                break;
                            case "repsub":
                                e.repsub = reader.nextString();
                                break;
                            default:
                                reader.skipValue();
                                break;
                        }

                    }

                    add(e);
                    reader.endObject();
                }
                reader.endArray();
                break;
            default:
                reader.skipValue();
                break;
        }
    }
    reader.endObject();
    reader.close();
}
 
開發者ID:Cedgetec,項目名稱:SchulinfoApp-android,代碼行數:74,代碼來源:Subst.java


注:本文中的android.util.JsonReader.nextLong方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。