Example usage for android.util JsonWriter beginArray

List of usage examples for android.util JsonWriter beginArray

Introduction

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

Prototype

public JsonWriter beginArray() throws IOException 

Source Link

Document

Begins encoding a new array.

Usage

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

/**
 * @param writer//from   w  w  w  . ja  v a  2s .  c o m
 * @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 w  ww  .  j a v  a  2  s .  c  om
        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();

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

    for (ShotLog shotLog : shotLogs) {
        writeShotLog(writer, shotLog);//ww  w  .jav a 2  s .  co  m
    }
    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();
    for (Song song : queue) {
        jsonWriter.beginObject();// w  w w.ja v a 2s  .co m
        jsonWriter.name(song.getId());
        if (playingSong.getId().equals(song.getId())) {
            jsonWriter.value(currentTIme);
        } else {
            jsonWriter.value(0);
        }
        jsonWriter.endObject();

    }
    jsonWriter.endArray();
}