Example usage for android.util JsonWriter endArray

List of usage examples for android.util JsonWriter endArray

Introduction

In this page you can find the example usage for android.util JsonWriter endArray.

Prototype

public JsonWriter endArray() throws IOException 

Source Link

Document

Ends encoding the current array.

Usage

From source file:com.fuzz.android.limelight.util.JSONTool.java

/**
 * @param writer/*from   w  w w .ja va  2s .c  om*/
 * @param chapters the list of BaseChapter objects and ChapterTransition objects to be written
 *                 in JSON
 * @throws IOException
 */
public static void writeChapterArray(JsonWriter writer, ArrayList<Chapter> chapters) throws IOException {
    writer.beginArray();
    for (Chapter chapter : chapters) {
        if (chapter.getType() == 0) {
            ChapterTransition transition = (ChapterTransition) chapter;
            writeTransition(writer, transition);
        } else if (chapter.getType() == 1) {
            BaseChapter baseChapter = (BaseChapter) chapter;
            writeChapter(writer, baseChapter);
        }
    }
    writer.endArray();
}

From source file:org.opensilk.music.ui2.loader.PluginLoader.java

public void writeDisabledPlugins(List<ComponentName> plugins) {
    StringWriter sw = new StringWriter(100);
    JsonWriter jw = new JsonWriter(sw);
    try {/*from ww w.jav a2  s  .  c o  m*/
        jw.beginArray();
        for (ComponentName cn : plugins) {
            jw.value(cn.flattenToString());
        }
        jw.endArray();
        Timber.v("Write disabled plugins=" + sw.toString());
        settings.putString(PREF_DISABLED_PLUGINS, sw.toString());
    } catch (IOException e) {
        settings.remove(PREF_DISABLED_PLUGINS);
    } finally {
        IOUtils.closeQuietly(jw);
    }
}

From source file:at.ac.tuwien.caa.docscan.logic.DataLog.java

private void writeList(JsonWriter writer, ArrayList<ShotLog> shotLogs) throws IOException {

    writer.beginArray();//  w  w w  .j av a  2  s .c o m

    if (shotLogs == null)
        shotLogs = new ArrayList<>();

    for (ShotLog shotLog : shotLogs) {
        writeShotLog(writer, shotLog);
    }
    writer.endArray();

}

From source file:ngo.music.soundcloudplayer.controller.SongController.java

private void writePlayedSongs(Song playingSong, ArrayList<Song> queue, JsonWriter jsonWriter, long currentTIme)
        throws IOException {
    // TODO Auto-generated method stub

    jsonWriter.beginArray();//from  w w w .  j  a  v  a2  s .c  o m
    for (Song song : queue) {
        jsonWriter.beginObject();
        jsonWriter.name(song.getId());
        if (playingSong.getId().equals(song.getId())) {
            jsonWriter.value(currentTIme);
        } else {
            jsonWriter.value(0);
        }
        jsonWriter.endObject();

    }
    jsonWriter.endArray();
}