Java Code Examples for com.facebook.react.bridge.WritableNativeMap#putInt()

The following examples show how to use com.facebook.react.bridge.WritableNativeMap#putInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QimRNBModule.java    From imsdk-android with MIT License 6 votes vote down vote up
/**
 * 获取日历功能城市列表
 *
 * @param callback
 */
@ReactMethod
public void getTripCity(Callback callback) {

    List<CityLocal.DataBean> list = IMDatabaseManager.getInstance().getCityList();
    WritableNativeMap map = new WritableNativeMap();
    WritableNativeArray array = new WritableNativeArray();
    for (int i = 0; i < list.size(); i++) {
        WritableNativeMap item = new WritableNativeMap();
        item.putString("CityName", list.get(i).getCityName());
        item.putInt("CityId", list.get(i).getId());
        array.pushMap(item);
    }
    map.putBoolean("ok", true);
    map.putArray("cityList", array);
    callback.invoke(map);

}
 
Example 2
Source File: QimRNBModule.java    From imsdk-android with MIT License 6 votes vote down vote up
/**
 * 获取日历功能区域列表
 *
 * @param callback
 */
@ReactMethod
public void getTripArea(Callback callback) {
    List<AreaLocal.DataBean.ListBean> list = IMDatabaseManager.getInstance().getAreaList();
    WritableNativeMap map = new WritableNativeMap();
    WritableNativeArray array = new WritableNativeArray();
    for (int i = 0; i < list.size(); i++) {
        WritableNativeMap item = new WritableNativeMap();
        item.putString("AddressName", list.get(i).getAreaName());
        item.putInt("AddressNumber", list.get(i).getAreaID());
        item.putString("rStartTime", list.get(i).getMorningStarts());
        item.putString("rEndTime", list.get(i).getEveningEnds());
        array.pushMap(item);
    }
    map.putBoolean("ok", true);
    map.putArray("areaList", array);
    callback.invoke(map);


}
 
Example 3
Source File: AccountManagerModule.java    From react-native-account-manager with MIT License 6 votes vote down vote up
@ReactMethod
public void getAccountsByType (String accountType, Promise promise) {
		manager = AccountManager.get(_reactContext);
		Account[] account_list = manager.getAccountsByType(accountType);
		WritableNativeArray result = new WritableNativeArray();

		for(Account account: account_list)
		{
			Integer index = indexForAccount(account);

			WritableNativeMap account_object = new WritableNativeMap();
			account_object.putInt("_index", (int)index);
			account_object.putString("name", account.name);
			account_object.putString("type", account.type);
			result.pushMap(account_object);
		}

		promise.resolve(result);
}
 
Example 4
Source File: AccountManagerModule.java    From react-native-account-manager with MIT License 6 votes vote down vote up
@ReactMethod
public void addAccountExplicitly (String accountType, String userName, String password, Promise promise) {
	manager = AccountManager.get(_reactContext);
	Account account = new Account(userName, accountType);
	Integer index = indexForAccount(account);
	Bundle userdata = new Bundle();

	if(false == manager.addAccountExplicitly(account, password, userdata)){
		promise.reject("Account with username already exists!");
		return;
	}

	WritableNativeMap result = new WritableNativeMap();
	result.putInt("_index", (int)index);
	result.putString("name", account.name);
	result.putString("type", account.type);

	promise.resolve(result);
	return;
}
 
Example 5
Source File: QtalkPlugin.java    From imsdk-android with MIT License 5 votes vote down vote up
private WritableNativeMap parseFound(FoundConfiguration foundConfiguration) {
    WritableNativeMap map = new WritableNativeMap();
    WritableNativeArray groupList = new WritableNativeArray();
    for (int i = 0; i < foundConfiguration.getData().size(); i++) {
        FoundConfiguration.DataBean data = foundConfiguration.getData().get(i);
        WritableNativeMap item = new WritableNativeMap();
        item.putString("groupIcon", data.getGroupIcon());
        item.putInt("groupId", data.getGroupId());
        item.putString("groupName", data.getGroupName());
        WritableNativeArray array = new WritableNativeArray();
        for (int j = 0; j < data.getMembers().size(); j++) {
            FoundConfiguration.DataBean.MembersBean membersBean = data.getMembers().get(j);
            WritableNativeMap mem = new WritableNativeMap();
            mem.putString("memberAction", membersBean.getMemberAction());
            mem.putString("memberIcon", membersBean.getMemberIcon());
            mem.putString("memberName", membersBean.getMemberName());
            mem.putInt("memberId", membersBean.getMemberId());
            mem.putString("Entrance", membersBean.getEntrance());
            mem.putString("Bundle", membersBean.getBundle());
            mem.putString("Version", membersBean.getVersion() + "");
            mem.putString("BundleUrls", membersBean.getBundleUrls());
            mem.putString("Module", membersBean.getModule());
            mem.putString("AppType", membersBean.getAppType() + "");
            mem.putBoolean("showNativeNav", membersBean.isShowNativeNav());
            mem.putString("navTitle", membersBean.getNavTitle());
            mem.putString("appParams", membersBean.getProperties());
            array.pushMap(mem);
        }
        item.putArray("members", array);
        groupList.pushMap(item);
    }
    map.putBoolean("isOk", true);
    map.putArray("data", groupList);

    return map;
}
 
Example 6
Source File: QimRNBModule.java    From imsdk-android with MIT License 5 votes vote down vote up
@ReactMethod
    public void getTOTP(final Callback callback) {
//
        if (TextUtils.isEmpty(CurrentPreference.getInstance().getVerifyKey())) {
            WritableNativeMap map = new WritableNativeMap();
            map.putString("totp", "000000");
            map.putInt("time", 0);
            callback.invoke(map);
            return;
        }
        String seret = String.format("u=%s&k=%s", CurrentPreference.getInstance().getPreferenceUserId(), CurrentPreference.getInstance().getVerifyKey());
        long timeStampSec = System.currentTimeMillis() - CurrentPreference.getInstance().getServerTimeDiff();
        long timestamp = Long.parseLong(String.format("%010d", timeStampSec));
        OtpProvider otp = new OtpProvider();
        String totp = "";
        try {
            totp = otp.computePin(seret, timestamp, null);
        } catch (Exception e) {
            totp = "000000";
            e.printStackTrace();
        }
        WritableNativeMap success = new WritableNativeMap();
        success.putString("totp", totp);
        success.putDouble("time", timestamp);
        callback.invoke(success);


    }
 
Example 7
Source File: QimRNBModule.java    From imsdk-android with MIT License 5 votes vote down vote up
public void getGroupMemberFromDB(String groupId, Callback callback) {
    List<GroupMember> groupMemberList = ConnectionUtil.getInstance().SelectGroupMemberByGroupId(groupId);
    if (ListUtil.isEmpty(groupMemberList)) {
        return;
    }
    WritableNativeArray array = new WritableNativeArray();
    int per = 2;
    for (int i = 0; i < groupMemberList.size(); i++) {
        GroupMember gm = groupMemberList.get(i);
        WritableNativeMap map = new WritableNativeMap();
        String affiliation = gm.getAffiliation();
        map.putString("affiliation", affiliation);
        map.putString("headerUri", TextUtils.isEmpty(gm.getHeaderSrc()) ? defaultUserImage : gm.getHeaderSrc());
        String xmppid = gm.getMemberId();
        if (CurrentPreference.getInstance().getPreferenceUserId().equals(xmppid)) {
            if (!TextUtils.isEmpty(affiliation)) {
                per = Integer.parseInt(affiliation);
            }
        }
        map.putString("xmppjid", xmppid);
        map.putString("jid", gm.getGroupId());
        map.putString("name", gm.getName());
        array.pushMap(map);

    }
    WritableNativeMap re = new WritableNativeMap();
    re.putArray("GroupMembers", array);
    re.putBoolean("ok", true);
    re.putString("GroupId", groupId);
    re.putInt("permissions", per);
    if (callback != null) {
        callback.invoke(re);
    } else {
        sendEvent("updateGroupMember", re);
    }
}
 
Example 8
Source File: BrightcovePlayerAccount.java    From react-native-brightcove-player with MIT License 5 votes vote down vote up
private NativeArray collectNativePlaylist(String accountId, Playlist playlist) {
    WritableNativeArray result = new WritableNativeArray();
    for (Video video : playlist.getVideos()) {
        WritableNativeMap map = new WritableNativeMap();
        map.putString(CALLBACK_KEY_ACCOUNT_ID, accountId);
        map.putString(CALLBACK_KEY_VIDEO_ID, video.getId());
        map.putString(CALLBACK_KEY_REFERENCE_ID, video.getReferenceId());
        map.putString(CALLBACK_KEY_NAME, video.getName());
        map.putString(CALLBACK_KEY_DESCRIPTION, video.getDescription());
        map.putInt(CALLBACK_KEY_DURATION, video.getDuration());
        result.pushMap(map);
    }
    return result;
}
 
Example 9
Source File: JSONEncoder.java    From react-native-google-fitness with MIT License 5 votes vote down vote up
private static WritableMap convertDataSource(DataSource ds) {
    WritableNativeMap map = new WritableNativeMap();
    map.putInt("type", ds.getType());
    map.putString("name", ds.getName());
    map.putString("appPackageName", ds.getAppPackageName());
    map.putString("streamIdentifier", ds.getStreamIdentifier());
    return map;
}
 
Example 10
Source File: JSONEncoder.java    From react-native-google-fitness with MIT License 5 votes vote down vote up
public static WritableNativeArray convertBuckets(List<Bucket> buckets) {
    WritableNativeArray jsonBuckets = new WritableNativeArray();
    for (Bucket bucket : buckets) {
        WritableNativeMap jsonBucket = new WritableNativeMap();
        jsonBucket.putString("start", dateFormat.format(bucket.getStartTime(TimeUnit.MILLISECONDS)));
        jsonBucket.putString("end", dateFormat.format(bucket.getEndTime(TimeUnit.MILLISECONDS)));
        jsonBucket.putInt("type", bucket.getBucketType());
        jsonBucket.putString("activity", bucket.getActivity());
        jsonBucket.putArray("dataSets", convertDataSets(bucket.getDataSets()));
        jsonBuckets.pushMap(jsonBucket);
    }
    return jsonBuckets;
}
 
Example 11
Source File: DisplayMetricsHolder.java    From react-native-GPay with MIT License 5 votes vote down vote up
private static WritableNativeMap getPhysicalPixelsNativeMap(DisplayMetrics displayMetrics, double fontScale) {
  final WritableNativeMap result = new WritableNativeMap();
  result.putInt("width", displayMetrics.widthPixels);
  result.putInt("height", displayMetrics.heightPixels);
  result.putDouble("scale", displayMetrics.density);
  result.putDouble("fontScale", fontScale);
  result.putDouble("densityDpi", displayMetrics.densityDpi);
  return result;
}
 
Example 12
Source File: OutputConverter.java    From react-native-tensorflow with Apache License 2.0 5 votes vote down vote up
public static WritableMap convert(Output output) {
    WritableNativeMap shapeMap = new WritableNativeMap();
    shapeMap.putInt("numDimensions", output.shape().numDimensions());

    WritableNativeMap map = new WritableNativeMap();
    map.putInt("index", output.index());
    map.putString("dataType", output.dataType().name());
    map.putMap("shape", shapeMap);

    return map;
}
 
Example 13
Source File: QimRNBModule.java    From imsdk-android with MIT License 4 votes vote down vote up
@ReactMethod
    public void appConfig(Callback callback) {
        try {


            WritableNativeMap map = new WritableNativeMap();
            map.putString("userId", CurrentPreference.getInstance().getUserid());
            map.putString("clientIp", "192.168.0.1");
            map.putString("domain", QtalkNavicationService.getInstance().getXmppdomain());
//            map.putString("token", CurrentPreference.getInstance().getToken());
//            map.putString("q_auth", CurrentPreference.getInstance().getVerifyKey() == null ? "404" : CurrentPreference.getInstance().getVerifyKey());
            map.putString("ckey", getCKey());
            map.putString("httpHost", QtalkNavicationService.getInstance().getJavaUrl());
            map.putString("fileUrl", QtalkNavicationService.getInstance().getInnerFiltHttpHost());
            map.putString("qcAdminHost", QtalkNavicationService.getInstance().getQcadminHost());
            if (QtalkNavicationService.getInstance().isShowOrganizational()) {
                map.putInt("showOrganizational", 1);
            } else {
                map.putInt("showOrganizational", 0);
            }
            map.putBoolean("showServiceState", CurrentPreference.getInstance().isMerchants());
            map.putBoolean("isQtalk", CommonConfig.isQtalk);
            map.putBoolean("isShowWorkWorld", GlobalConfigManager.isQtalkPlat() && IMDatabaseManager.getInstance().SelectWorkWorldPremissions());

            Object metaData = getApplicationMetaData("EASY_TRIP");
            boolean isEasyTrip = metaData == null ? true : (boolean) metaData;
            map.putBoolean("isEasyTrip", isEasyTrip);
            map.putBoolean("isShowRedPackage", !GlobalConfigManager.isStartalkPlat());
            map.putBoolean("isShowGroupQRCode",true);
            map.putBoolean("isShowLocalQuickSearch",true);

            map.putBoolean("notNeedShowLeaderInfo",TextUtils.isEmpty(QtalkNavicationService.getInstance().getLeaderurl()));
            map.putBoolean("notNeedShowMobileInfo",TextUtils.isEmpty(QtalkNavicationService.getInstance().getMobileurl()));
            map.putBoolean("notNeedShowEmailInfo",TextUtils.isEmpty(QtalkNavicationService.getInstance().getEmail()));

            map.putBoolean("isToCManager",DataUtils.getInstance(CommonConfig.globalContext).getPreferences(Constants.Preferences.isAdminFlag + "_" + QtalkNavicationService.getInstance().getXmppdomain(),false));

            if(GlobalConfigManager.isQtalkPlat()){
                map.putInt("nativeAppType", 2);
            }else if(GlobalConfigManager.isQchatPlat()){
                map.putInt("nativeAppType", 1);
            }else if(GlobalConfigManager.isStartalkPlat()){
                map.putInt("nativeAppType", 0);
            }
//            map.putDouble("timestamp", System.currentTimeMillis());
            callback.invoke(map);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }