Example usage for com.facebook.react.bridge ReadableType Number

List of usage examples for com.facebook.react.bridge ReadableType Number

Introduction

In this page you can find the example usage for com.facebook.react.bridge ReadableType Number.

Prototype

ReadableType Number

To view the source code for com.facebook.react.bridge ReadableType Number.

Click Source Link

Usage

From source file:com.hijridatepicker.HijriDatePickerAndroidModule.java

License:Open Source License

private boolean parseOptionsWithKey(String ARG_KEY, ReadableMap options, Bundle args, Promise promise) {
    ReadableType argDateType = options.getType(ARG_KEY);
    if (ReadableType.String.equals(argDateType)) {
        try {/*from  w w  w .  ja  va 2  s .c  o  m*/
            long milliSeconds = 0;
            milliSeconds = (long) convertHijriDateToGregorianMilliseconds(options.getString(ARG_KEY));
            args.putLong(ARG_KEY, milliSeconds);
            return true;
        } catch (PatternSyntaxException | IndexOutOfBoundsException | NumberFormatException e) {
            promise.reject(ERROR_PARSING_OPTIONS, "Exception happened while parsing " + ARG_KEY
                    + " we only accept object of Date or String with the format \"dd-MM-yyyy\" in Hijri");
            return false;
        }
    } else if (ReadableType.Number.equals(argDateType)) {
        args.putLong(ARG_KEY, (long) options.getDouble(ARG_KEY));
        return true;
    } else {
        promise.reject(ERROR_PARSING_OPTIONS, "Exception happened while parsing " + ARG_KEY
                + " we only accept object of Date or String with the format \"dd-MM-yyyy\" in Hijri");
        return false;
    }
}