当前位置: 首页>>代码示例>>Java>>正文


Java WritableMap.putString方法代码示例

本文整理汇总了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;
}
 
开发者ID:taplytics,项目名称:taplytics-react-native,代码行数:17,代码来源:TRNBroadcastReceiver.java

示例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);
}
 
开发者ID:angellsl10,项目名称:react-native-webrtc,代码行数:25,代码来源:DataChannelObserver.java

示例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;
}
 
开发者ID:ccm-innovation,项目名称:react-native-twilio-chat,代码行数:18,代码来源:RCTConvert.java

示例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()));
  }
}
 
开发者ID:quan-to,项目名称:react-native-pgp,代码行数:32,代码来源:Module.java

示例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;
}
 
开发者ID:ccm-innovation,项目名称:react-native-twilio-chat,代码行数:11,代码来源:RCTConvert.java

示例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;
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:12,代码来源:TimePickerDialogModule.java

示例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);
}
 
开发者ID:MacKentoch,项目名称:react-native-ibeacons,代码行数:14,代码来源:BeaconsAndroidModule.java

示例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);
}
 
开发者ID:ccm-innovation,项目名称:react-native-twilio-chat,代码行数:9,代码来源:RCTTwilioChatClient.java

示例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;
}
 
开发者ID:KingBarbarian,项目名称:react-native-android-new-crosswalk,代码行数:9,代码来源:ErrorEvent.java

示例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;
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:13,代码来源:DatePickerDialogModule.java

示例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);
}
 
开发者ID:ccm-innovation,项目名称:react-native-twilio-chat,代码行数:9,代码来源:RCTTwilioChatClient.java

示例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);
}
 
开发者ID:hiteshsahu,项目名称:React-Native-Music-Player,代码行数:33,代码来源:MusicPlayerModule.java

示例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);
}
 
开发者ID:rafaellincoln,项目名称:react-native-telephony,代码行数:12,代码来源:TelephonyModule.java


注:本文中的com.facebook.react.bridge.WritableMap.putString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。