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


Java JsonWriter.beginArray方法代碼示例

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


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

示例1: writeActions

import android.util.JsonWriter; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.KITKAT)
private void writeActions(JsonWriter writer, Notification notification) throws IOException {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }

    if (notification.actions != null) {
        Log.d(TAG, "writing action");
        writer.name("actions");
        writer.beginArray();
        for (Notification.Action a : notification.actions) {
            Log.d(TAG, "writing action : " + a.title.toString());
            writer.beginObject();
            writer.name("title").value(a.title.toString());
            writer.endObject();
        }
        writer.endArray();
    }
}
 
開發者ID:RomascuAndrei,項目名稱:BTNotifierAndroid,代碼行數:20,代碼來源:Message.java

示例2: listToJsonStr

import android.util.JsonWriter; //導入方法依賴的package包/類
public static String listToJsonStr(final List<Object> list) {
    if (list == null || list.isEmpty()) {
        return EMPTY_STRING;
    }
    final StringWriter sw = new StringWriter();
    final JsonWriter writer = new JsonWriter(sw);
    try {
        writer.beginArray();
        for (final Object o : list) {
            writer.beginObject();
            if (o instanceof Integer) {
                writer.name(INTEGER_CLASS_NAME).value((Integer)o);
            } else if (o instanceof String) {
                writer.name(STRING_CLASS_NAME).value((String)o);
            }
            writer.endObject();
        }
        writer.endArray();
        return sw.toString();
    } catch (final IOException e) {
    } finally {
        close(writer);
    }
    return EMPTY_STRING;
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:26,代碼來源:JsonUtils.java

示例3: serializeRepresentation

import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void serializeRepresentation(JsonWriter writer) throws IOException {
    writer.beginObject();

    writer.name(ARGS);
    writer.beginArray();
    writer.value(getValue(MODE_MASTER));
    writer.value(getValue(MODE_RED));
    writer.value(getValue(MODE_YELLOW));
    writer.value(getValue(MODE_GREEN));
    writer.value(getValue(MODE_CYAN));
    writer.value(getValue(MODE_BLUE));
    writer.value(getValue(MODE_MAGENTA));
    writer.endArray();
    writer.endObject();
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:17,代碼來源:FilterChanSatRepresentation.java

示例4: serializeRepresentation

import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void serializeRepresentation(JsonWriter writer) throws IOException {
    writer.beginObject();
    {
        writer.name(NAME_TAG);
        writer.value(getName());
        for (int i = 0; i < mSplines.length; i++) {
            writer.name(SERIALIZATION_NAME + i);
            writer.beginArray();
            int nop = mSplines[i].getNbPoints();
            for (int j = 0; j < nop; j++) {
                ControlPoint p = mSplines[i].getPoint(j);
                writer.beginArray();
                writer.value(p.x);
                writer.value(p.y);
                writer.endArray();
            }
            writer.endArray();
        }

    }
    writer.endObject();
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:24,代碼來源:FilterCurvesRepresentation.java

示例5: serializeRepresentation

import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void serializeRepresentation(JsonWriter writer) throws IOException {
    writer.beginObject();
    writer.name(ELLIPSE);
    writer.beginArray();
    writer.value(mCenterX);
    writer.value(mCenterY);
    writer.value(mRadiusX);
    writer.value(mRadiusY);
    writer.endArray();

    writer.name(ARGS);
    writer.beginArray();
    writer.value(mParamVignette.getValue());
    writer.value(mParamExposure.getValue());
    writer.value(mParamSaturation.getValue());
    writer.value(mParamContrast.getValue());
    writer.value(mParamFalloff.getValue());
    writer.endArray();
    writer.endObject();
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:22,代碼來源:FilterVignetteRepresentation.java

示例6: save

import android.util.JsonWriter; //導入方法依賴的package包/類
public void save() {
    try {
        OutputStream out = SIAApp.SIA_APP.openFileOutput("mensa", Context.MODE_PRIVATE);
        JsonWriter writer = new JsonWriter(new OutputStreamWriter(out));

        writer.setIndent("  ");
        writer.beginArray();
        for(MensaItem s : this) {
            writer.beginObject();

            writer.name("id").value(s.id);
            writer.name("date").value(s.date);
            writer.name("meal").value(s.meal);
            writer.name("garnish").value(s.garnish);
            writer.name("dessert").value(s.dessert);
            writer.name("vegetarian").value(s.vegetarian);
            writer.name("image").value(s.image);

            writer.endObject();
        }
        writer.endArray();
        writer.close();
    } catch(Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:Cedgetec,項目名稱:SchulinfoApp-android,代碼行數:27,代碼來源:Mensa.java

示例7: writeToJSON

import android.util.JsonWriter; //導入方法依賴的package包/類
private void writeToJSON(OutputStream out, Date date, Location loc) throws IOException {
    FileOutputStream outputStream;
    JsonWriter writer = new JsonWriter(new OutputStreamWriter(out, "UTF-8"));
    writer.setIndent("  ");
    writer.beginArray();

    writer.beginObject();
    writer.name("Date").value(date.toString());

    writer.name("Location");
    writer.beginArray();
    writer.value(loc.getLatitude());
    writer.value(loc.getLongitude());
    writer.endArray();

    writer.endObject();
    writer.close();
}
 
開發者ID:alexdao,項目名稱:footstep,代碼行數:19,代碼來源:MainActivity.java

示例8: toJSON

import android.util.JsonWriter; //導入方法依賴的package包/類
public String toJSON(Context context) {
    StringWriter out = new StringWriter();
    JsonWriter writer = new JsonWriter(out);

    try {
        writer.beginObject();
        writer.name("event").value(event);

        writer.name("eventItems");
        writer.beginArray();

        if (type == SendType.SMS) {
            toJsonSMessage(context, writer, sMessage);
        } else if (type == SendType.NOTI) {
            for (StatusBarNotification sbn : notifications) {
                toJsonNotification(context, writer, sbn);
            }
        }
        writer.endArray();
        writer.endObject();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return out.toString();
}
 
開發者ID:holylobster,項目名稱:nuntius-android,代碼行數:27,代碼來源:Message.java

示例9: save

import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void save() {
    try {
        OutputStream out = SIAApp.SIA_APP.openFileOutput("news", Context.MODE_PRIVATE);
        JsonWriter writer = new JsonWriter(new OutputStreamWriter(out));

        writer.setIndent("  ");
        writer.beginArray();
        for(Entry s : this) {
            writer.beginObject();

            writer.name("id").value(s.id);
            writer.name("date").value(s.date.getTime());
            writer.name("topic").value(s.topic);
            writer.name("source").value(s.source);
            writer.name("title").value(s.title);
            writer.name("text").value(s.text);

            writer.endObject();
        }
        writer.endArray();
        writer.close();
    } catch(Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:Cedgetec,項目名稱:SchulinfoApp-android,代碼行數:27,代碼來源:News.java

示例10: write

import android.util.JsonWriter; //導入方法依賴的package包/類
public boolean write(final List<Person> persons,
		final OutputStream personStream) {
	final OutputStreamWriter ouw = new OutputStreamWriter(personStream,
			Charsets.UTF_8);
	final JsonWriter writer = new JsonWriter(ouw);
	try {
		writer.beginArray();
		for (final Person person : persons) {
			writePerson(person, writer);
		}
		writer.endArray();
		writer.close();
		return true;
	} catch (final IOException e) {
		Closeables.closeQuietly(writer);
	} finally {
		Closeables.closeQuietly(writer);
	}

	return false;
}
 
開發者ID:rduerig,項目名稱:nansai,代碼行數:22,代碼來源:PersonFileWriter.java

示例11: writeDisabledPlugins

import android.util.JsonWriter; //導入方法依賴的package包/類
public void writeDisabledPlugins(List<ComponentName> plugins) {
    StringWriter sw = new StringWriter(100);
    JsonWriter jw = new JsonWriter(sw);
    try {
        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);
    }
}
 
開發者ID:OpenSilk,項目名稱:Orpheus,代碼行數:18,代碼來源:PluginLoader.java

示例12: writeMessagesArray

import android.util.JsonWriter; //導入方法依賴的package包/類
public void writeMessagesArray(JsonWriter writer, List<LatLng> mesgs)
		throws IOException {
	
	writer.beginArray();
	if(null != mesgs) {
		for (LatLng message : mesgs) {
			writeMessage(writer, message);
		}
	} else {
		Log.e(TAG, "file don't contain geo data");
	}
	// record this step place
	writeThisStep(writer);

	writer.endArray();
}
 
開發者ID:youtaya,項目名稱:crabapple,代碼行數:17,代碼來源:StepRelateFragment.java

示例13: getInitializedJsonWriterLocked

import android.util.JsonWriter; //導入方法依賴的package包/類
/**
 * Return a JsonWriter for this ResearchLog.  It is initialized the first time this method is
 * called.  The cached value is returned in future calls.
 *
 * @throws IOException if opening the JsonWriter is not possible
 */
public JsonWriter getInitializedJsonWriterLocked() throws IOException {
    if (mJsonWriter != null) return mJsonWriter;
    if (mFile == null) throw new FileNotFoundException();
    try {
        final JsonWriter jsonWriter = createJsonWriter(mContext, mFile);
        if (jsonWriter == null) throw new IOException("Could not create JsonWriter");

        jsonWriter.beginArray();
        mJsonWriter = jsonWriter;
        mHasWrittenData = true;
        return mJsonWriter;
    } catch (final IOException e) {
        if (DEBUG) {
            Log.w(TAG, "Exception when creating JsonWriter", e);
            Log.w(TAG, "Closing JsonWriter");
        }
        if (mJsonWriter != null) mJsonWriter.close();
        mJsonWriter = null;
        throw e;
    }
}
 
開發者ID:slightfoot,項目名稱:android-kioskime,代碼行數:28,代碼來源:ResearchLog.java

示例14: writeJson

import android.util.JsonWriter; //導入方法依賴的package包/類
static void writeJson(final SuggestedWords words, final JsonWriter jsonWriter)
        throws IOException {
    jsonWriter.beginObject();
    jsonWriter.name("typedWordValid").value(words.mTypedWordValid);
    jsonWriter.name("willAutoCorrect")
            .value(words.mWillAutoCorrect);
    jsonWriter.name("isPunctuationSuggestions")
            .value(words.mIsPunctuationSuggestions);
    jsonWriter.name("isObsoleteSuggestions").value(words.mIsObsoleteSuggestions);
    jsonWriter.name("isPrediction").value(words.mIsPrediction);
    jsonWriter.name("words");
    jsonWriter.beginArray();
    final int size = words.size();
    for (int j = 0; j < size; j++) {
        final SuggestedWordInfo wordInfo = words.getInfo(j);
        jsonWriter.value(wordInfo.toString());
    }
    jsonWriter.endArray();
    jsonWriter.endObject();
}
 
開發者ID:slightfoot,項目名稱:android-kioskime,代碼行數:21,代碼來源:JsonUtils.java

示例15: saveCache

import android.util.JsonWriter; //導入方法依賴的package包/類
/**
 * Save the cache to the specified location
 */
public static void saveCache()
{
	File file = new File(mClassCachePath + ".json");

	try
	{
		BufferedWriter out = new BufferedWriter(new FileWriter(file, false));

		JsonWriter writer = new JsonWriter(out);
		writer.setIndent("  ");
		writer.beginArray();

		for (CachedProfile item : mClassMap.values())
		{
			if (item.getUsed())
			{
				writer.beginObject();
				writer.name(TARGET_KEY).value(item.getTargetPath());
				writer.name(CLASS_KEY).value(item.getClassPath());
				writer.name(HOOK_KEY).value(item.getHookVersion());
				writer.name(MODULE_KEY).value(item.getModuleVersion());
				writer.name(SIMILARITY_KEY).value(item.getSimilarity());
				writer.endObject();
			}


		}

		writer.endArray();
		writer.close();
	}
	catch (Exception ex)
	{
		Log.e(TAG, "Failed to save profile cache");
		ex.printStackTrace();
	}
}
 
開發者ID:Nordskog,項目名稱:ClassHunter,代碼行數:41,代碼來源:ProfileCache.java


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