本文整理匯總了Java中com.facebook.react.bridge.WritableMap.putString方法的典型用法代碼示例。如果您正苦於以下問題:Java WritableMap.putString方法的具體用法?Java WritableMap.putString怎麽用?Java WritableMap.putString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.facebook.react.bridge.WritableMap
的用法示例。
在下文中一共展示了WritableMap.putString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getIntentData
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
private WritableMap getIntentData(Intent intent) {
WritableMap data = Arguments.createMap();
JSONObject dataObject = new JSONObject();
try {
if (intent.hasExtra("tl_id")) {
dataObject.put("tl_id", intent.getExtras().getString("tl_id"));
}
if (intent.hasExtra("custom_keys")) {
dataObject.put("custom_keys", new JSONObject(intent.getExtras().getString("custom_keys")));
}
} catch (Throwable ignored) {
//Ignore the bad JSON for now. Log here as you please.
}
data.putString("value", dataObject.toString());
return data;
}
示例2: onMessage
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
@Override
public void onMessage(DataChannel.Buffer buffer) {
WritableMap params = Arguments.createMap();
params.putInt("id", mId);
params.putInt("peerConnectionId", peerConnectionId);
byte[] bytes;
if (buffer.data.hasArray()) {
bytes = buffer.data.array();
} else {
bytes = new byte[buffer.data.remaining()];
buffer.data.get(bytes);
}
if (buffer.binary) {
params.putString("type", "binary");
params.putString("data", Base64.encodeToString(bytes, Base64.NO_WRAP));
} else {
params.putString("type", "text");
params.putString("data", new String(bytes, Charset.forName("UTF-8")));
}
webRTCModule.sendEvent("dataChannelReceiveMessage", params);
}
示例3: Message
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap Message(Message message) {
WritableMap map = Arguments.createMap();
map.putString("sid", message.getSid());
map.putInt("index", (int) message.getMessageIndex());
map.putString("author", message.getAuthor());
map.putString("body", message.getMessageBody());
map.putString("timestamp", message.getTimeStamp());
WritableMap attributes = Arguments.createMap();
try {
attributes = jsonToWritableMap(message.getAttributes());
}
catch (JSONException e) {}
map.putMap("attributes", attributes);
return map;
}
示例4: generateKeyPair
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
@ReactMethod
public void generateKeyPair(final String userId, final int numBits, final String passphrase, Promise promise) {
Log.d("ReactNativePGP", "generateKeyPair");
try {
WritableMap resultMap = Arguments.createMap();
PGPKeyRingGenerator keyGenerator = PGPUtils.generateKeyRingGenerator(userId, numBits, passphrase.toCharArray());
// public key
PGPPublicKeyRing publicKeyRing = keyGenerator.generatePublicKeyRing();
ByteArrayOutputStream publicKeyOutputStream = new ByteArrayOutputStream();
ArmoredOutputStream armoredPubOutputStream = new ArmoredOutputStream(publicKeyOutputStream);
publicKeyRing.encode(armoredPubOutputStream);
armoredPubOutputStream.close();
resultMap.putString("publicKey", publicKeyOutputStream.toString("UTF-8"));
// private key
PGPSecretKeyRing secretKeyRing = keyGenerator.generateSecretKeyRing();
ByteArrayOutputStream privateKeyOutputStream = new ByteArrayOutputStream();
ArmoredOutputStream armoredPrivOutputStream = new ArmoredOutputStream(privateKeyOutputStream);
secretKeyRing.encode(armoredPrivOutputStream);
armoredPrivOutputStream.close();
resultMap.putString("privateKey", privateKeyOutputStream.toString("UTF-8"));
resultMap.putString("fingerPrint", Utils.bytesToHex(secretKeyRing.getPublicKey().getFingerprint()));
promise.resolve(resultMap);
} catch(Exception e) {
promise.reject(new Exception(e.getMessage()));
}
}
示例5: mapToWritableMap
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
private static WritableMap mapToWritableMap(Map<String,String> map) {
if (map == null) {
return null;
}
WritableMap writableMap = Arguments.createMap();
for (String key : map.keySet()) {
writableMap.putString(key, map.get(key));
}
return writableMap;
}
示例6: onTimeSet
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
@Override
public void onTimeSet(TimePicker view, int hour, int minute) {
if (!mPromiseResolved && getReactApplicationContext().hasActiveCatalystInstance()) {
WritableMap result = new WritableNativeMap();
result.putString("action", ACTION_TIME_SET);
result.putInt("hour", hour);
result.putInt("minute", minute);
mPromise.resolve(result);
mPromiseResolved = true;
}
}
示例7: getMonitoredRegions
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
@ReactMethod
public void getMonitoredRegions(Callback callback) {
WritableArray array = new WritableNativeArray();
for (Region region: mBeaconManager.getMonitoredRegions()) {
WritableMap map = new WritableNativeMap();
map.putString("identifier", region.getUniqueId());
map.putString("uuid", region.getId1().toString());
map.putInt("major", region.getId2() != null ? region.getId2().toInt() : 0);
map.putInt("minor", region.getId3() != null ? region.getId3().toInt() : 0);
array.pushMap(map);
}
callback.invoke(array);
}
示例8: setDefaultSpeechRate
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
@ReactMethod
public void setDefaultSpeechRate(float speechRate, Promise promise) {
if(notReady(promise)) return;
int result = tts.setSpeechRate(speechRate);
if(result == TextToSpeech.SUCCESS) {
WritableMap map = Arguments.createMap();
map.putString("status", "Success");
map.putDouble("speechRate", (double)speechRate);
promise.resolve(map);
} else {
promise.reject("error", "Unable to set speech rate");
}
}
開發者ID:echo8795,項目名稱:react-native-android-text-to-speech,代碼行數:15,代碼來源:RNAndroidTextToSpeechModule.java
示例9: setDefaultPitch
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
@ReactMethod
public void setDefaultPitch(float pitch, Promise promise) {
if(notReady(promise)) return;
int result = tts.setPitch(pitch);
if(result == TextToSpeech.SUCCESS) {
WritableMap map = Arguments.createMap();
map.putString("status", "Success");
map.putDouble("pitch", (double)pitch);
promise.resolve(map);
} else {
promise.reject("error", "Unable to set pitch");
}
}
開發者ID:echo8795,項目名稱:react-native-android-text-to-speech,代碼行數:15,代碼來源:RNAndroidTextToSpeechModule.java
示例10: onToastFailed
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
@Override
public void onToastFailed(ErrorInfo errorInfo) {
WritableMap map = Arguments.createMap();
map.putString("error",errorInfo.getErrorText());
map.putString("userInfo", errorInfo.toString());
sendEvent("chatClient:toastFailed", map);
}
示例11: serializeEventData
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
private WritableMap serializeEventData () {
WritableMap eventData = Arguments.createMap();
eventData.putInt("errorNumber", errorNumber);
eventData.putString("errorMessage", errorMessage);
eventData.putString("url", url);
return eventData;
}
示例12: onDateSet
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
@Override
public void onDateSet(DatePicker view, int year, int month, int day) {
if (!mPromiseResolved && getReactApplicationContext().hasActiveCatalystInstance()) {
WritableMap result = new WritableNativeMap();
result.putString("action", ACTION_DATE_SET);
result.putInt("year", year);
result.putInt("month", month);
result.putInt("day", day);
mPromise.resolve(result);
mPromiseResolved = true;
}
}
示例13: onToastNotification
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
@Override
public void onToastNotification(String channelSid, String messageSid) {
WritableMap map = Arguments.createMap();
map.putString("channelSid", channelSid);
map.putString("messageSid", messageSid);
sendEvent("chatClient:toastReceived", map);
}
示例14: playThisSong
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
/**
* Play Song and update UI
* @param songURL
* @param songName
* @param AlbumArt
*/
@ReactMethod
public void playThisSong(String songURL, String songName, String AlbumArt) {
if (IS_SONG_PAUSED) {
DemoPlayer.getInstance().resume();
} else {
DemoPlayer.getInstance().play(songURL,
MusicPlayerModule.this);
}
IS_SONG_PAUSED = false;
//Update UI with new SOng Info
WritableMap paramsUI = Arguments.createMap();
paramsUI.putString(KEY_UPDATE_SONG_NAME, songName);
paramsUI.putString(KEY_UPDATE_ALBUM_ART, AlbumArt);
paramsUI.putString(KEY_UPDATE_DURATION, PlayerUtil.milliSecondsToTimer(DemoPlayer.getInstance().getPlayer()
.getDuration()));
paramsUI.putInt(KEY_UPDATE_SEEK_POSTION, DemoPlayer.getInstance().getProgress());
sendEvent(reactAppContext, EVENT_SONG_CHANGED, paramsUI);
//Start Progress bar update
((MainActivity) getCurrentActivity()).getSongProgressHandler().postDelayed(updateProgressTask, DELAY_MILLIS);
WritableMap params = Arguments.createMap();
params.putBoolean(KEY_SONG_PAUSED, IS_SONG_PAUSED);
params.putInt(KEY_UPDATE_SEEK_POSTION, DemoPlayer.getInstance().getProgress());
sendEvent(reactAppContext, EVENT_UPDATE_PROGRESS, params);
}
示例15: phoneDataConnectionStateUpdated
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
@Override
public void phoneDataConnectionStateUpdated(int direction) {
WritableMap map = Arguments.createMap();
map.putInt("direction", direction);
WritableMap result = Arguments.createMap();
result.putString("type", "LISTEN_DATA_CONNECTION_STATE");
result.putMap("data", map);
sendEvent(PHONE_STATE_LISTENER, result);
}