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


Java WritableMap.putArray方法代碼示例

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


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

示例1: createRangingResponse

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
private WritableMap createRangingResponse(Collection<Beacon> beacons, Region region) {
    WritableMap map = new WritableNativeMap();
    map.putString("identifier", region.getUniqueId());
    map.putString("uuid", region.getId1() != null ? region.getId1().toString() : "");
    WritableArray a = new WritableNativeArray();
    for (Beacon beacon : beacons) {
        WritableMap b = new WritableNativeMap();
        b.putString("uuid", beacon.getId1().toString());
        b.putInt("major", beacon.getId2().toInt());
        b.putInt("minor", beacon.getId3().toInt());
        b.putInt("rssi", beacon.getRssi());
        b.putDouble("distance", beacon.getDistance());
        b.putString("proximity", getProximity(beacon.getDistance()));
        a.pushMap(b);
    }
    map.putArray("beacons", a);
    return map;
}
 
開發者ID:MacKentoch,項目名稱:react-native-ibeacons,代碼行數:19,代碼來源:BeaconsAndroidModule.java

示例2: jsonToReact

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap jsonToReact(JSONObject jsonObject) throws JSONException {
    WritableMap writableMap = Arguments.createMap();
    Iterator iterator = jsonObject.keys();
    while(iterator.hasNext()) {
        String key = (String) iterator.next();
        Object value = jsonObject.get(key);
        if (value instanceof Float || value instanceof Double) {
            writableMap.putDouble(key, jsonObject.getDouble(key));
        } else if (value instanceof Number) {
            writableMap.putInt(key, jsonObject.getInt(key));
        } else if (value instanceof String) {
            writableMap.putString(key, jsonObject.getString(key));
        } else if (value instanceof JSONObject) {
            writableMap.putMap(key,jsonToReact(jsonObject.getJSONObject(key)));
        } else if (value instanceof JSONArray){
            writableMap.putArray(key, jsonToReact(jsonObject.getJSONArray(key)));
        } else if (value == JSONObject.NULL){
            writableMap.putNull(key);
        }
    }

    return writableMap;
}
 
開發者ID:whitedogg13,項目名稱:react-native-nfc-manager,代碼行數:24,代碼來源:JsonConvert.java

示例3: Paginator

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap Paginator(Object paginator, String sid, String type) {
    WritableMap map = Arguments.createMap();
    WritableMap _paginator = Arguments.createMap();
    switch (type) {
        case "Channel":
            _paginator.putArray("items", Channels(((Paginator<Channel>)paginator).getItems()));
            _paginator.putBoolean("hasNextPage", ((Paginator<Channel>)paginator).hasNextPage());
            break;
        case "ChannelDescriptor":
            _paginator.putArray("items", ChannelDescriptors(((Paginator<ChannelDescriptor>)paginator).getItems()));
            _paginator.putBoolean("hasNextPage", ((Paginator<ChannelDescriptor>)paginator).hasNextPage());
            break;
        case "Member":
            _paginator.putArray("items", Members(((Paginator<Member>)paginator).getItems()));
            _paginator.putBoolean("hasNextPage", ((Paginator<Member>)paginator).hasNextPage());
            break;
    }
    map.putString("sid", sid);
    map.putString("type", type);
    map.putMap("paginator", _paginator);
    return map;
}
 
開發者ID:ccm-innovation,項目名稱:react-native-twilio-chat,代碼行數:23,代碼來源:RCTConvert.java

示例4: onReceive

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
  Logger.debug(TAG, "onReceive");
  Bundle results = getResultExtras(true);
  WritableMap data = Arguments.createMap();
  if (results.containsKey(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE))
  {
    String languagePreference =
        results.getString(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE);
    data.putString("languagePreference", languagePreference);
  }
  if (results.containsKey(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES))
  {
    List<String> supportedLanguages =
        results.getStringArrayList(
            RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES);
    WritableArray languages =
        Arguments.fromArray(supportedLanguages.toArray(new String[0]));
    data.putArray("supportedLanguages", languages);
  }

  emit(SUPPORTED_LOCALES, data);
}
 
開發者ID:marshmelloX,項目名稱:react-native-stt,代碼行數:24,代碼來源:LocalesBroadcastReceiver.java

示例5: convertJsonToMap

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
    WritableMap map = new WritableNativeMap();

    Iterator<String> iterator = jsonObject.keys();
    while (iterator.hasNext()) {
        String key = iterator.next();
        Object value = jsonObject.get(key);
        if (value instanceof JSONObject) {
            map.putMap(key, convertJsonToMap((JSONObject) value));
        } else if (value instanceof JSONArray) {
            map.putArray(key, convertJsonToArray((JSONArray) value));
        } else if (value instanceof  Boolean) {
            map.putBoolean(key, (Boolean) value);
        } else if (value instanceof  Integer) {
            map.putInt(key, (Integer) value);
        } else if (value instanceof  Double) {
            map.putDouble(key, (Double) value);
        } else if (value instanceof String)  {
            map.putString(key, (String) value);
        } else {
            map.putString(key, value.toString());
        }
    }
    return map;
}
 
開發者ID:salathegroup,項目名稱:react-native-scandit,代碼行數:26,代碼來源:ReactBridgeHelpers.java

示例6: toWritableMap

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap toWritableMap(Map<String, Object> map) {
  WritableMap writableMap = Arguments.createMap();
  Iterator iterator = map.entrySet().iterator();

  while (iterator.hasNext()) {
    Map.Entry pair = (Map.Entry)iterator.next();
    Object value = pair.getValue();

    if (value == null) {
      writableMap.putNull((String) pair.getKey());
    } else if (value instanceof Boolean) {
      writableMap.putBoolean((String) pair.getKey(), (Boolean) value);
    } else if (value instanceof Double) {
      writableMap.putDouble((String) pair.getKey(), (Double) value);
    } else if (value instanceof Integer) {
      writableMap.putInt((String) pair.getKey(), (Integer) value);
    } else if (value instanceof String) {
      writableMap.putString((String) pair.getKey(), (String) value);
    } else if (value instanceof Map) {
      writableMap.putMap((String) pair.getKey(), MapUtil.toWritableMap((Map<String, Object>) value));
    } else if (value.getClass() != null && value.getClass().isArray()) {
      writableMap.putArray((String) pair.getKey(), ArrayUtil.toWritableArray((Object[]) value));
    }

    iterator.remove();
  }

  return writableMap;
}
 
開發者ID:davidstoneham,項目名稱:react-native-mssql,代碼行數:30,代碼來源:MapUtil.java

示例7: onBufferReceived

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
@Override
public void onBufferReceived(byte[] buffer) {
  Log.d(TAG, "onBufferReceived");
  if (isEnabled(ListenerEvents.ON_BUFFER_RECEIVED)) {
    WritableMap data = Arguments.createMap();
    data.putArray("buffer", ArgumentsConverter.fromArray(buffer));
    emit(ListenerEvents.ON_BUFFER_RECEIVED, data);
  }
}
 
開發者ID:de-code,項目名稱:react-native-android-speech-recognizer,代碼行數:10,代碼來源:ListenerMapRecognitionListener.java

示例8: fromBundle

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap fromBundle(Bundle bundle) {
  WritableMap map = Arguments.createMap();
  for (String key: bundle.keySet()) {
    Object value = bundle.get(key);
    if (value == null) {
      map.putNull(key);
    } else if (value.getClass().isArray()) {
      map.putArray(key, Arguments.fromArray(value));
    } else if (value instanceof String) {
      map.putString(key, (String) value);
    } else if (value instanceof Number) {
      if (value instanceof Integer) {
        map.putInt(key, (Integer) value);
      } else {
        map.putDouble(key, ((Number) value).doubleValue());
      }
    } else if (value instanceof Boolean) {
      map.putBoolean(key, (Boolean) value);
    } else if (value instanceof Bundle) {
      map.putMap(key, fromBundle((Bundle) value));
    } else if (value instanceof List) {
      map.putArray(key, fromArray(((List) value).toArray()));
    } else {
      throw new IllegalArgumentException("Could not convert " + value.getClass());
    }
  }
  return map;
}
 
開發者ID:de-code,項目名稱:react-native-android-speech-recognizer,代碼行數:29,代碼來源:ArgumentsConverter.java

示例9: jsonToWritableMap

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap jsonToWritableMap(JSONObject jsonObject) {
    WritableMap writableMap = new WritableNativeMap();

    if (jsonObject == null) {
        return null;
    }


    Iterator<String> iterator = jsonObject.keys();
    if (!iterator.hasNext()) {
        return null;
    }


    try {
        while (iterator.hasNext()) {
            String key = iterator.next();
            Object value = jsonObject.get(key);
            if (value == null) {
                writableMap.putNull(key);
            } else if (value instanceof Boolean) {
                writableMap.putBoolean(key, (Boolean) value);
            } else if (value instanceof Integer) {
                writableMap.putInt(key, (Integer) value);
            } else if (value instanceof Double) {
                writableMap.putDouble(key, (Double) value);
            } else if (value instanceof String) {
                writableMap.putString(key, (String) value);
            } else if (value instanceof JSONObject) {
                writableMap.putMap(key, jsonToWritableMap((JSONObject) value));
            } else if (value instanceof JSONArray) {
                writableMap.putArray(key, jsonArrayToWritableArray((JSONArray) value));
            }
        }
    } catch (JSONException ex){
            // Do nothing and fail silently
    }

    return writableMap;
}
 
開發者ID:ccm-innovation,項目名稱:react-native-twilio-chat,代碼行數:41,代碼來源:RCTConvert.java

示例10: toWritableMap

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap toWritableMap(Map<String, Object> map) {
    WritableMap writableMap = Arguments.createMap();
    Iterator iterator = map.entrySet().iterator();

    while (iterator.hasNext()) {
        Map.Entry pair = (Map.Entry) iterator.next();
        Object value = pair.getValue();

        if (value == null) {
            writableMap.putNull((String) pair.getKey());
        } else if (value instanceof Boolean) {
            writableMap.putBoolean((String) pair.getKey(), (Boolean) value);
        } else if (value instanceof Double) {
            writableMap.putDouble((String) pair.getKey(), (Double) value);
        } else if (value instanceof Integer) {
            writableMap.putInt((String) pair.getKey(), (Integer) value);
        } else if (value instanceof String) {
            writableMap.putString((String) pair.getKey(), (String) value);
        } else if (value instanceof Map) {
            writableMap.putMap((String) pair.getKey(), MapUtil.toWritableMap((Map<String, Object>) value));
        } else if (value.getClass() != null && value.getClass().isArray()) {
            writableMap.putArray((String) pair.getKey(), ArrayUtil.toWritableArray((Object[]) value));
        }

        iterator.remove();
    }

    return writableMap;
}
 
開發者ID:dangerfarms,項目名稱:react-native-batch,代碼行數:30,代碼來源:MapUtil.java

示例11: toWritableMap

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap toWritableMap(Map<String, Object> map) {
    WritableMap writableMap = Arguments.createMap();
    Iterator iterator = map.entrySet().iterator();

    while (iterator.hasNext()) {
        Map.Entry pair = (Map.Entry)iterator.next();
        Object value = pair.getValue();

        if (value == null) {
            writableMap.putNull((String) pair.getKey());
        } else if (value instanceof Boolean) {
            writableMap.putBoolean((String) pair.getKey(), (Boolean) value);
        } else if (value instanceof Double) {
            writableMap.putDouble((String) pair.getKey(), (Double) value);
        } else if (value instanceof Integer) {
            writableMap.putInt((String) pair.getKey(), (Integer) value);
        } else if (value instanceof String) {
            writableMap.putString((String) pair.getKey(), (String) value);
        } else if (value instanceof Map) {
            writableMap.putMap((String) pair.getKey(), MapUtil.toWritableMap((Map<String, Object>) value));
        } else if (value.getClass() != null && value.getClass().isArray()) {
            writableMap.putArray((String) pair.getKey(), ArrayUtil.toWritableArray((Object[]) value));
        }

        iterator.remove();
    }

    return writableMap;
}
 
開發者ID:CanalTP,項目名稱:RNNavitiaSDK,代碼行數:30,代碼來源:MapUtil.java

示例12: onBufferReceived

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
@Override
public void onBufferReceived(byte[] buffer) {
  Logger.debug(TAG, "onBufferReceived");
  WritableMap data = Arguments.createMap();
  data.putArray("buffer", Arguments.fromArray(buffer));
  emit(SPEECH_TO_TEXT, data);
}
 
開發者ID:marshmelloX,項目名稱:react-native-stt,代碼行數:8,代碼來源:SpeechRecognitionListener.java

示例13: putEdges

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
private static void putEdges(
    ContentResolver resolver,
    Cursor photos,
    WritableMap response,
    int limit) {
  WritableArray edges = new WritableNativeArray();
  photos.moveToFirst();
  int idIndex = photos.getColumnIndex(Images.Media._ID);
  int mimeTypeIndex = photos.getColumnIndex(Images.Media.MIME_TYPE);
  int groupNameIndex = photos.getColumnIndex(Images.Media.BUCKET_DISPLAY_NAME);
  int dateTakenIndex = photos.getColumnIndex(Images.Media.DATE_TAKEN);
  int widthIndex = IS_JELLY_BEAN_OR_LATER ? photos.getColumnIndex(Images.Media.WIDTH) : -1;
  int heightIndex = IS_JELLY_BEAN_OR_LATER ? photos.getColumnIndex(Images.Media.HEIGHT) : -1;
  int longitudeIndex = photos.getColumnIndex(Images.Media.LONGITUDE);
  int latitudeIndex = photos.getColumnIndex(Images.Media.LATITUDE);

  for (int i = 0; i < limit && !photos.isAfterLast(); i++) {
    WritableMap edge = new WritableNativeMap();
    WritableMap node = new WritableNativeMap();
    boolean imageInfoSuccess =
        putImageInfo(resolver, photos, node, idIndex, widthIndex, heightIndex);
    if (imageInfoSuccess) {
      putBasicNodeInfo(photos, node, mimeTypeIndex, groupNameIndex, dateTakenIndex);
      putLocationInfo(photos, node, longitudeIndex, latitudeIndex);

      edge.putMap("node", node);
      edges.pushMap(edge);
    } else {
      // we skipped an image because we couldn't get its details (e.g. width/height), so we
      // decrement i in order to correctly reach the limit, if the cursor has enough rows
      i--;
    }
    photos.moveToNext();
  }
  response.putArray("edges", edges);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:37,代碼來源:CameraRollManager.java

示例14: convertJsonToMap

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
  WritableMap map = new WritableNativeMap();

  Iterator<String> iterator = jsonObject.keys();
  while (iterator.hasNext()) {
    String key = iterator.next();
    Object value = jsonObject.get(key);
    if (value instanceof JSONObject) {
      map.putMap(key, convertJsonToMap((JSONObject) value));
    } else if (value instanceof JSONArray) {
      map.putArray(key, convertJsonToArray((JSONArray) value));
    } else if (value instanceof Boolean) {
      map.putBoolean(key, (Boolean) value);
    } else if (value instanceof Integer) {
      map.putInt(key, (Integer) value);
    } else if (value instanceof Double) {
      System.out.println("double");
      map.putDouble(key, (Double) value);
    } else if (value instanceof String) {
      map.putString(key, (String) value);
      System.out.println("string");
    } else {
      map.putString(key, value.toString());
    }
  }
  return map;
}
 
開發者ID:humaniq,項目名稱:react-native-android-library-humaniq-api,代碼行數:28,代碼來源:ModelConverterUtils.java

示例15: didScan

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public void didScan(ScanSession scanSession) {
    List<Barcode> newBarcodes = scanSession.getNewlyRecognizedCodes();

    WritableArray newlyRecognizedCodes = Arguments.createArray();
    for (Barcode barcode: newBarcodes) {
        newlyRecognizedCodes.pushMap(ScanditBarcodeHelpers.barcodeToWritableMap(barcode));
    }

    WritableMap event = Arguments.createMap();
    event.putArray(NEWLY_RECOGNIZED_CODES, newlyRecognizedCodes);

    eventDispatcher.dispatchEvent(new DidScanEvent(picker.getId(), event));
}
 
開發者ID:salathegroup,項目名稱:react-native-scandit,代碼行數:14,代碼來源:SGScanditPicker.java


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