本文整理汇总了Java中com.facebook.react.bridge.ReadableType.Number方法的典型用法代码示例。如果您正苦于以下问题:Java ReadableType.Number方法的具体用法?Java ReadableType.Number怎么用?Java ReadableType.Number使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.react.bridge.ReadableType
的用法示例。
在下文中一共展示了ReadableType.Number方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildCreateQuery
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
private StringBuilder buildCreateQuery(String tableName, ReadableMap props, List<String> keys) {
final StringBuilder queryBuilder = new StringBuilder("CREATE TABLE IF NOT EXISTS ").append(tableName).append(" ");
queryBuilder.append("(");
queryBuilder.append("id INTEGER PRIMARY KEY AUTOINCREMENT");
for (String key : keys) {
String propType = null;
if(props.getType(key) == ReadableType.Boolean) {
propType = "BOOLEAN";
} else if(props.getType(key) == ReadableType.String) {
propType = "TEXT";
} else if(props.getType(key) == ReadableType.Number) {
propType = "DOUBLE";
}
if(propType != null) {
queryBuilder.append(", ").append(key).append(" ").append(propType);
}
}
queryBuilder.append(")");
return queryBuilder;
}
示例2: buildQueryArgument
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
private ArrayList<String> buildQueryArgument(List<String> keys, ReadableMap query) {
final ArrayList<String> arguments = new ArrayList<>();
for (String key : keys) {
ReadableType type = query.getType(key);
if(type == ReadableType.Boolean) {
arguments.add(String.valueOf(query.getBoolean(key)));
} else if(type == ReadableType.Number) {
arguments.add(String.valueOf(query.getDouble(key)));
} else if(type == ReadableType.String) {
arguments.add(String.valueOf(query.getString(key)));
}
}
return arguments;
}
示例3: stackTraceToString
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
private String stackTraceToString(String message, ReadableArray stack) {
StringBuilder stringBuilder = new StringBuilder(message).append(", stack:\n");
for (int i = 0; i < stack.size(); i++) {
ReadableMap frame = stack.getMap(i);
stringBuilder
.append(frame.getString("methodName"))
.append("@")
.append(stackFrameToModuleId(frame))
.append(frame.getInt("lineNumber"));
if (frame.hasKey("column") &&
!frame.isNull("column") &&
frame.getType("column") == ReadableType.Number) {
stringBuilder
.append(":")
.append(frame.getInt("column"));
}
stringBuilder.append("\n");
}
return stringBuilder.toString();
}
示例4: stackTraceToString
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
private String stackTraceToString(String message, ReadableArray stack) {
StringBuilder stringBuilder = new StringBuilder(message).append(", stack:\n");
for (int i = 0; i < stack.size(); i++) {
ReadableMap frame = stack.getMap(i);
stringBuilder
.append(frame.getString("methodName"))
.append("@")
.append(frame.getInt("lineNumber"));
if (frame.hasKey("column") &&
!frame.isNull("column") &&
frame.getType("column") == ReadableType.Number) {
stringBuilder
.append(":")
.append(frame.getInt("column"));
}
stringBuilder.append("\n");
}
return stringBuilder.toString();
}
示例5: stackTraceToString
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
private String stackTraceToString(String message, ReadableArray stack) {
StringBuilder stringBuilder = new StringBuilder(message).append(", stack:\n");
for (int i = 0; i < stack.size(); i++) {
ReadableMap frame = stack.getMap(i);
stringBuilder
.append(frame.getString("methodName"))
.append("@")
.append(stackFrameToModuleId(frame))
.append(frame.getInt("lineNumber"));
if (frame.hasKey("column") &&
!frame.isNull("column") &&
frame.getType("column") == ReadableType.Number) {
stringBuilder
.append(":")
.append(frame.getInt("column"));
}
stringBuilder.append("\n");
}
return stringBuilder.toString();
}
示例6: exec
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
public void exec(final String sql, final ReadableArray values) {
SQLiteStatement statement = Assertions.assertNotNull(db).compileStatement(sql);
db.beginTransaction();
try {
for (int i=0; i < values.size(); i++) {
if (values.getType(i) == ReadableType.Number) {
statement.bindLong(i+1, values.getInt(i));
} else {
statement.bindString(i+1, values.getString(i));
}
}
statement.execute();
db.setTransactionSuccessful();
} catch (Exception e) {
throw e;
} finally {
db.endTransaction();
}
}
示例7: getUserProperties
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
private Map<String, Object> getUserProperties(ReadableMap properties) {
ReadableMapKeySetIterator iterator = properties.keySetIterator();
Map<String, Object> userProperties = new HashMap<>();
while (iterator.hasNextKey()) {
String key = iterator.nextKey();
ReadableType type = properties.getType(key);
if (type == ReadableType.Boolean) {
userProperties.put(key, properties.getBoolean(key));
} else if (type == ReadableType.Number) {
userProperties.put(key, properties.getDouble(key));
} else if (type == ReadableType.String) {
userProperties.put(key, properties.getString(key));
}
}
return userProperties;
}
示例8: extractMapValue
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
private Object extractMapValue(ReadableMap params, HashMap<String, Object> paramsMap, String key) {
Object mapValue;
if (ReadableType.Number == params.getType(key)) {
try {
mapValue = params.getInt(key);
} catch (UnexpectedNativeTypeException e) {
mapValue = params.getDouble(key);
}
} else {
mapValue = paramsMap.get(key);
}
return mapValue;
}
示例9: prepareInsertContentValues
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
private ContentValues prepareInsertContentValues(ReadableMap props, List<String> keys) {
final ContentValues contentValues = new ContentValues();
for (String key : keys) {
if(props.getType(key) == ReadableType.Boolean) {
contentValues.put(key, props.getBoolean(key));
} else if(props.getType(key) == ReadableType.Number) {
contentValues.put(key, props.getDouble(key));
} else if(props.getType(key) == ReadableType.String) {
contentValues.put(key, props.getString(key));
}
}
return contentValues;
}
示例10: prepareUpdateContentValues
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
private ContentValues prepareUpdateContentValues(ReadableMap props, List<String> keys) {
final ContentValues contentValues = new ContentValues();
for (String key : keys) {
if(props.getType(key) == ReadableType.Boolean) {
contentValues.put(key, props.getBoolean(key));
} else if(props.getType(key) == ReadableType.Number) {
contentValues.put(key, props.getDouble(key));
} else if(props.getType(key) == ReadableType.String) {
contentValues.put(key, props.getString(key));
}
}
return contentValues;
}
示例11: setWidth
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
/**
* Besides width/height, all other layout props on inline images are ignored
*/
@Override
public void setWidth(Dynamic width) {
if (width.getType() == ReadableType.Number) {
mWidth = (float) width.asDouble();
} else {
throw new JSApplicationIllegalArgumentException(
"Inline images must not have percentage based width");
}
}
示例12: setHeight
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
@Override
public void setHeight(Dynamic height) {
if (height.getType() == ReadableType.Number) {
mHeight = (float) height.asDouble();
} else {
throw new JSApplicationIllegalArgumentException(
"Inline images must not have percentage based height");
}
}
示例13: getResultCodeFromPayload
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
/**
* Returns the result_code from the ReadableMap payload or RESULT_OK if none found. <p> Throws
* IllegalArgumentException if the resultCode is not a number.
*/
private static int getResultCodeFromPayload(ReadableMap payload) {
if (payload == null) {
return Activity.RESULT_OK;
}
if (!payload.hasKey(RESULT_CODE)) {
return Activity.RESULT_OK;
}
if (payload.getType(RESULT_CODE) != ReadableType.Number) {
throw new IllegalArgumentException("Found non-integer resultCode.");
}
return payload.getInt(RESULT_CODE);
}
示例14: createRemindersForEvent
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
private void createRemindersForEvent(ContentResolver resolver, int eventID, ReadableArray reminders) {
Cursor cursor = CalendarContract.Reminders.query(resolver, eventID, new String[] {
CalendarContract.Reminders._ID
});
while (cursor.moveToNext()) {
long reminderId = cursor.getLong(0);
Uri reminderUri = ContentUris.withAppendedId(CalendarContract.Reminders.CONTENT_URI, reminderId);
resolver.delete(reminderUri, null, null);
}
cursor.close();
for (int i = 0; i < reminders.size(); i++) {
ReadableMap reminder = reminders.getMap(i);
ReadableType type = reminder.getType("date");
if (type == ReadableType.Number) {
int minutes = reminder.getInt("date");
ContentValues reminderValues = new ContentValues();
reminderValues.put(CalendarContract.Reminders.EVENT_ID, eventID);
reminderValues.put(CalendarContract.Reminders.MINUTES, minutes);
reminderValues.put(CalendarContract.Reminders.METHOD, CalendarContract.Reminders.METHOD_ALERT);
resolver.insert(CalendarContract.Reminders.CONTENT_URI, reminderValues);
}
}
}
示例15: findEvents
import com.facebook.react.bridge.ReadableType; //导入方法依赖的package包/类
private WritableNativeArray findEvents(Dynamic startDate, Dynamic endDate, ReadableArray calendars) {
String dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
Calendar eStartDate = Calendar.getInstance();
Calendar eEndDate = Calendar.getInstance();
try {
if (startDate.getType() == ReadableType.String) {
eStartDate.setTime(sdf.parse(startDate.asString()));
} else if (startDate.getType() == ReadableType.Number) {
eStartDate.setTimeInMillis((long)startDate.asDouble());
}
if (startDate.getType() == ReadableType.String) {
eEndDate.setTime(sdf.parse(endDate.asString()));
} else if (startDate.getType() == ReadableType.Number) {
eEndDate.setTimeInMillis((long)endDate.asDouble());
}
} catch (ParseException e) {
e.printStackTrace();
}
Cursor cursor;
ContentResolver cr = reactContext.getContentResolver();
Uri.Builder uriBuilder = CalendarContract.Instances.CONTENT_URI.buildUpon();
ContentUris.appendId(uriBuilder, eStartDate.getTimeInMillis());
ContentUris.appendId(uriBuilder, eEndDate.getTimeInMillis());
Uri uri = uriBuilder.build();
String selection = "((" + CalendarContract.Instances.BEGIN + " >= " + eStartDate.getTimeInMillis() + ") " +
"AND (" + CalendarContract.Instances.END + " <= " + eEndDate.getTimeInMillis() + ") " +
"AND (" + CalendarContract.Instances.VISIBLE + " = 1) ";
if (calendars.size() > 0) {
String calendarQuery = "AND (";
for (int i = 0; i < calendars.size(); i++) {
calendarQuery += CalendarContract.Instances.CALENDAR_ID + " = " + calendars.getString(i);
if (i != calendars.size() - 1) {
calendarQuery += " OR ";
}
}
calendarQuery += ")";
selection += calendarQuery;
}
selection += ")";
cursor = cr.query(uri, new String[]{
CalendarContract.Instances.EVENT_ID,
CalendarContract.Instances.TITLE,
CalendarContract.Instances.DESCRIPTION,
CalendarContract.Instances.BEGIN,
CalendarContract.Instances.END,
CalendarContract.Instances.ALL_DAY,
CalendarContract.Instances.EVENT_LOCATION,
CalendarContract.Instances.RRULE,
CalendarContract.Instances.CALENDAR_ID,
CalendarContract.Instances.AVAILABILITY,
CalendarContract.Instances.HAS_ALARM
}, selection, null, null);
return serializeEvents(cursor);
}