Example usage for android.util JsonWriter value

List of usage examples for android.util JsonWriter value

Introduction

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

Prototype

public JsonWriter value(Number value) throws IOException 

Source Link

Document

Encodes value .

Usage

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 w  w.ja v  a2 s . co 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: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   ww w .ja v  a  2  s .  com*/
    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();
}