Java Code Examples for com.facebook.react.bridge.ReadableMap.isNull()

The following are Jave code examples for showing how to use isNull() of the com.facebook.react.bridge.ReadableMap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: RNLearn_Project1   File: ReactPickerManager.java   Source Code and License Vote up 6 votes
private View getView(int position, View convertView, ViewGroup parent, boolean isDropdown) {
  ReadableMap item = getItem(position);

  if (convertView == null) {
    int layoutResId = isDropdown
        ? android.R.layout.simple_spinner_dropdown_item
        : android.R.layout.simple_spinner_item;
    convertView = mInflater.inflate(layoutResId, parent, false);
  }

  TextView textView = (TextView) convertView;
  textView.setText(item.getString("label"));
  if (!isDropdown && mPrimaryTextColor != null) {
    textView.setTextColor(mPrimaryTextColor);
  } else if (item.hasKey("color") && !item.isNull("color")) {
    textView.setTextColor(item.getInt("color"));
  }

  return convertView;
}
 
Example 2
Project: RNLearn_Project1   File: ReactTextShadowNode.java   Source Code and License Vote up 6 votes
@ReactProp(name = PROP_SHADOW_OFFSET)
public void setTextShadowOffset(ReadableMap offsetMap) {
  mTextShadowOffsetDx = 0;
  mTextShadowOffsetDy = 0;

  if (offsetMap != null) {
    if (offsetMap.hasKey(PROP_SHADOW_OFFSET_WIDTH) &&
        !offsetMap.isNull(PROP_SHADOW_OFFSET_WIDTH)) {
      mTextShadowOffsetDx =
          PixelUtil.toPixelFromDIP(offsetMap.getDouble(PROP_SHADOW_OFFSET_WIDTH));
    }
    if (offsetMap.hasKey(PROP_SHADOW_OFFSET_HEIGHT) &&
        !offsetMap.isNull(PROP_SHADOW_OFFSET_HEIGHT)) {
      mTextShadowOffsetDy =
          PixelUtil.toPixelFromDIP(offsetMap.getDouble(PROP_SHADOW_OFFSET_HEIGHT));
    }
  }

  markUpdated();
}
 
Example 3
Project: RNLearn_Project1   File: DatePickerDialogModule.java   Source Code and License Vote up 6 votes
private Bundle createFragmentArguments(ReadableMap options) {
  final Bundle args = new Bundle();
  if (options.hasKey(ARG_DATE) && !options.isNull(ARG_DATE)) {
    args.putLong(ARG_DATE, (long) options.getDouble(ARG_DATE));
  }
  if (options.hasKey(ARG_MINDATE) && !options.isNull(ARG_MINDATE)) {
    args.putLong(ARG_MINDATE, (long) options.getDouble(ARG_MINDATE));
  }
  if (options.hasKey(ARG_MAXDATE) && !options.isNull(ARG_MAXDATE)) {
    args.putLong(ARG_MAXDATE, (long) options.getDouble(ARG_MAXDATE));
  }
  if (options.hasKey(ARG_MODE) && !options.isNull(ARG_MODE)) {
    args.putString(ARG_MODE, options.getString(ARG_MODE));
  }
  return args;
}
 
Example 4
Project: RNLearn_Project1   File: ExceptionsManagerModule.java   Source Code and License Vote up 6 votes
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();
}
 
Example 5
Project: RNLearn_Project1   File: StackTraceHelper.java   Source Code and License Vote up 6 votes
/**
 * Convert a JavaScript stack trace (see {@code parseErrorStack} JS module) to an array of
 * {@link StackFrame}s.
 */
public static StackFrame[] convertJsStackTrace(@Nullable ReadableArray stack) {
  int size = stack != null ? stack.size() : 0;
  StackFrame[] result = new StackFrame[size];
  for (int i = 0; i < size; i++) {
    ReadableMap frame = stack.getMap(i);
    String methodName = frame.getString("methodName");
    String fileName = frame.getString("file");
    int lineNumber = -1;
    if (frame.hasKey(LINE_NUMBER_KEY) && !frame.isNull(LINE_NUMBER_KEY)) {
      lineNumber = frame.getInt(LINE_NUMBER_KEY);
    }
    int columnNumber = -1;
    if (frame.hasKey(COLUMN_KEY) && !frame.isNull(COLUMN_KEY)) {
      columnNumber = frame.getInt(COLUMN_KEY);
    }
    result[i] = new StackFrameImpl(fileName, methodName, lineNumber, columnNumber);
  }
  return result;
}
 
Example 6
Project: RNLearn_Project1   File: ReactPickerManager.java   Source Code and License Vote up 6 votes
private View getView(int position, View convertView, ViewGroup parent, boolean isDropdown) {
  ReadableMap item = getItem(position);

  if (convertView == null) {
    int layoutResId = isDropdown
        ? android.R.layout.simple_spinner_dropdown_item
        : android.R.layout.simple_spinner_item;
    convertView = mInflater.inflate(layoutResId, parent, false);
  }

  TextView textView = (TextView) convertView;
  textView.setText(item.getString("label"));
  if (!isDropdown && mPrimaryTextColor != null) {
    textView.setTextColor(mPrimaryTextColor);
  } else if (item.hasKey("color") && !item.isNull("color")) {
    textView.setTextColor(item.getInt("color"));
  }

  return convertView;
}
 
Example 7
Project: RNLearn_Project1   File: ReactTextShadowNode.java   Source Code and License Vote up 6 votes
@ReactProp(name = PROP_SHADOW_OFFSET)
public void setTextShadowOffset(ReadableMap offsetMap) {
  mTextShadowOffsetDx = 0;
  mTextShadowOffsetDy = 0;

  if (offsetMap != null) {
    if (offsetMap.hasKey(PROP_SHADOW_OFFSET_WIDTH) &&
        !offsetMap.isNull(PROP_SHADOW_OFFSET_WIDTH)) {
      mTextShadowOffsetDx =
          PixelUtil.toPixelFromDIP(offsetMap.getDouble(PROP_SHADOW_OFFSET_WIDTH));
    }
    if (offsetMap.hasKey(PROP_SHADOW_OFFSET_HEIGHT) &&
        !offsetMap.isNull(PROP_SHADOW_OFFSET_HEIGHT)) {
      mTextShadowOffsetDy =
          PixelUtil.toPixelFromDIP(offsetMap.getDouble(PROP_SHADOW_OFFSET_HEIGHT));
    }
  }

  markUpdated();
}
 
Example 8
Project: RNLearn_Project1   File: DatePickerDialogModule.java   Source Code and License Vote up 6 votes
private Bundle createFragmentArguments(ReadableMap options) {
  final Bundle args = new Bundle();
  if (options.hasKey(ARG_DATE) && !options.isNull(ARG_DATE)) {
    args.putLong(ARG_DATE, (long) options.getDouble(ARG_DATE));
  }
  if (options.hasKey(ARG_MINDATE) && !options.isNull(ARG_MINDATE)) {
    args.putLong(ARG_MINDATE, (long) options.getDouble(ARG_MINDATE));
  }
  if (options.hasKey(ARG_MAXDATE) && !options.isNull(ARG_MAXDATE)) {
    args.putLong(ARG_MAXDATE, (long) options.getDouble(ARG_MAXDATE));
  }
  if (options.hasKey(ARG_MODE) && !options.isNull(ARG_MODE)) {
    args.putString(ARG_MODE, options.getString(ARG_MODE));
  }
  return args;
}
 
Example 9
Project: RNLearn_Project1   File: ExceptionsManagerModule.java   Source Code and License Vote up 6 votes
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();
}
 
Example 10
Project: RNLearn_Project1   File: StackTraceHelper.java   Source Code and License Vote up 6 votes
/**
 * Convert a JavaScript stack trace (see {@code parseErrorStack} JS module) to an array of
 * {@link StackFrame}s.
 */
public static StackFrame[] convertJsStackTrace(@Nullable ReadableArray stack) {
  int size = stack != null ? stack.size() : 0;
  StackFrame[] result = new StackFrame[size];
  for (int i = 0; i < size; i++) {
    ReadableMap frame = stack.getMap(i);
    String methodName = frame.getString("methodName");
    String fileName = frame.getString("file");
    int lineNumber = -1;
    if (frame.hasKey(LINE_NUMBER_KEY) && !frame.isNull(LINE_NUMBER_KEY)) {
      lineNumber = frame.getInt(LINE_NUMBER_KEY);
    }
    int columnNumber = -1;
    if (frame.hasKey(COLUMN_KEY) && !frame.isNull(COLUMN_KEY)) {
      columnNumber = frame.getInt(COLUMN_KEY);
    }
    result[i] = new StackFrameImpl(fileName, methodName, lineNumber, columnNumber);
  }
  return result;
}
 
Example 11
Project: RNLearn_Project1   File: TimePickerDialogModule.java   Source Code and License Vote up 5 votes
private Bundle createFragmentArguments(ReadableMap options) {
  final Bundle args = new Bundle();
  if (options.hasKey(ARG_HOUR) && !options.isNull(ARG_HOUR)) {
    args.putInt(ARG_HOUR, options.getInt(ARG_HOUR));
  }
  if (options.hasKey(ARG_MINUTE) && !options.isNull(ARG_MINUTE)) {
    args.putInt(ARG_MINUTE, options.getInt(ARG_MINUTE));
  }
  if (options.hasKey(ARG_IS24HOUR) && !options.isNull(ARG_IS24HOUR)) {
    args.putBoolean(ARG_IS24HOUR, options.getBoolean(ARG_IS24HOUR));
  }
  return args;
}
 
Example 12
Project: RNLearn_Project1   File: ExceptionsManagerModule.java   Source Code and License Vote up 5 votes
static private String stackFrameToModuleId(ReadableMap frame) {
  if (frame.hasKey("file") &&
      !frame.isNull("file") &&
      frame.getType("file") == ReadableType.String) {
    final Matcher matcher = mJsModuleIdPattern.matcher(frame.getString("file"));
    if (matcher.find()) {
      return matcher.group(1) + ":";
    }
  }
  return "";
}
 
Example 13
Project: RNLearn_Project1   File: TimePickerDialogModule.java   Source Code and License Vote up 5 votes
private Bundle createFragmentArguments(ReadableMap options) {
  final Bundle args = new Bundle();
  if (options.hasKey(ARG_HOUR) && !options.isNull(ARG_HOUR)) {
    args.putInt(ARG_HOUR, options.getInt(ARG_HOUR));
  }
  if (options.hasKey(ARG_MINUTE) && !options.isNull(ARG_MINUTE)) {
    args.putInt(ARG_MINUTE, options.getInt(ARG_MINUTE));
  }
  if (options.hasKey(ARG_IS24HOUR) && !options.isNull(ARG_IS24HOUR)) {
    args.putBoolean(ARG_IS24HOUR, options.getBoolean(ARG_IS24HOUR));
  }
  return args;
}
 
Example 14
Project: RNLearn_Project1   File: ExceptionsManagerModule.java   Source Code and License Vote up 5 votes
static private String stackFrameToModuleId(ReadableMap frame) {
  if (frame.hasKey("file") &&
      !frame.isNull("file") &&
      frame.getType("file") == ReadableType.String) {
    final Matcher matcher = mJsModuleIdPattern.matcher(frame.getString("file"));
    if (matcher.find()) {
      return matcher.group(1) + ":";
    }
  }
  return "";
}