本文整理汇总了Java中com.facebook.react.bridge.JSApplicationIllegalArgumentException类的典型用法代码示例。如果您正苦于以下问题:Java JSApplicationIllegalArgumentException类的具体用法?Java JSApplicationIllegalArgumentException怎么用?Java JSApplicationIllegalArgumentException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JSApplicationIllegalArgumentException类属于com.facebook.react.bridge包,在下文中一共展示了JSApplicationIllegalArgumentException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setTextAlign
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
@ReactProp(name = ViewProps.TEXT_ALIGN)
public void setTextAlign(ReactEditText view, @Nullable String textAlign) {
if (textAlign == null || "auto".equals(textAlign)) {
view.setGravityHorizontal(Gravity.NO_GRAVITY);
} else if ("left".equals(textAlign)) {
view.setGravityHorizontal(Gravity.LEFT);
} else if ("right".equals(textAlign)) {
view.setGravityHorizontal(Gravity.RIGHT);
} else if ("center".equals(textAlign)) {
view.setGravityHorizontal(Gravity.CENTER_HORIZONTAL);
} else if ("justify".equals(textAlign)) {
// Fallback gracefully for cross-platform compat instead of error
view.setGravityHorizontal(Gravity.LEFT);
} else {
throw new JSApplicationIllegalArgumentException("Invalid textAlign: " + textAlign);
}
}
示例2: setTextBreakStrategy
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
@Override
public void setTextBreakStrategy(@Nullable String textBreakStrategy) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return;
}
if (textBreakStrategy == null || "simple".equals(textBreakStrategy)) {
mTextBreakStrategy = Layout.BREAK_STRATEGY_SIMPLE;
} else if ("highQuality".equals(textBreakStrategy)) {
mTextBreakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY;
} else if ("balanced".equals(textBreakStrategy)) {
mTextBreakStrategy = Layout.BREAK_STRATEGY_BALANCED;
} else {
throw new JSApplicationIllegalArgumentException("Invalid textBreakStrategy: " + textBreakStrategy);
}
}
示例3: showPopupMenu
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
/**
* Show a {@link PopupMenu}.
*
* @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
* needs to be the tag of a native view (shadow views can not be anchors)
* @param items the menu items as an array of strings
* @param success will be called with the position of the selected item as the first argument, or
* no arguments if the menu is dismissed
*/
public void showPopupMenu(int reactTag, ReadableArray items, Callback success) {
UiThreadUtil.assertOnUiThread();
View anchor = mTagsToViews.get(reactTag);
if (anchor == null) {
throw new JSApplicationIllegalArgumentException("Could not find view with tag " + reactTag);
}
PopupMenu popupMenu = new PopupMenu(getReactContextForView(reactTag), anchor);
Menu menu = popupMenu.getMenu();
for (int i = 0; i < items.size(); i++) {
menu.add(Menu.NONE, Menu.NONE, i, items.getString(i));
}
PopupMenuCallbackHandler handler = new PopupMenuCallbackHandler(success);
popupMenu.setOnMenuItemClickListener(handler);
popupMenu.setOnDismissListener(handler);
popupMenu.show();
}
示例4: getStyleFromString
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
static int getStyleFromString(@Nullable String styleStr) {
if (styleStr == null) {
throw new JSApplicationIllegalArgumentException(
"ProgressBar needs to have a style, null received");
} else if (styleStr.equals("Horizontal")) {
return android.R.attr.progressBarStyleHorizontal;
} else if (styleStr.equals("Small")) {
return android.R.attr.progressBarStyleSmall;
} else if (styleStr.equals("Large")) {
return android.R.attr.progressBarStyleLarge;
} else if (styleStr.equals("Inverse")) {
return android.R.attr.progressBarStyleInverse;
} else if (styleStr.equals("SmallInverse")) {
return android.R.attr.progressBarStyleSmallInverse;
} else if (styleStr.equals("LargeInverse")) {
return android.R.attr.progressBarStyleLargeInverse;
} else if (styleStr.equals("Normal")) {
return android.R.attr.progressBarStyle;
} else {
throw new JSApplicationIllegalArgumentException("Unknown ProgressBar style: " + styleStr);
}
}
示例5: setPosition
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
@ReactProp(name = ViewProps.POSITION)
public void setPosition(@Nullable String position) {
if (isVirtual()) {
return;
}
if (position == null) {
setPositionType(YogaPositionType.RELATIVE);
return;
}
switch (position) {
case "relative": {
setPositionType(YogaPositionType.RELATIVE);
break;
}
case "absolute": {
setPositionType(YogaPositionType.ABSOLUTE);
break;
}
default: {
throw new JSApplicationIllegalArgumentException(
"invalid value for position: " + position);
}
}
}
示例6: receiveCommand
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
@Override
public void receiveCommand(ReactViewGroup root, int commandId, @Nullable ReadableArray args) {
switch (commandId) {
case CMD_HOTSPOT_UPDATE: {
if (args == null || args.size() != 2) {
throw new JSApplicationIllegalArgumentException(
"Illegal number of arguments for 'updateHotspot' command");
}
if (Build.VERSION.SDK_INT >= 21) {
float x = PixelUtil.toPixelFromDIP(args.getDouble(0));
float y = PixelUtil.toPixelFromDIP(args.getDouble(1));
root.drawableHotspotChanged(x, y);
}
break;
}
case CMD_SET_PRESSED: {
if (args == null || args.size() != 1) {
throw new JSApplicationIllegalArgumentException(
"Illegal number of arguments for 'setPressed' command");
}
root.setPressed(args.getBoolean(0));
break;
}
}
}
示例7: setTextBreakStrategy
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
@ReactProp(name = ViewProps.TEXT_BREAK_STRATEGY)
public void setTextBreakStrategy(@Nullable String textBreakStrategy) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return;
}
if (textBreakStrategy == null || "highQuality".equals(textBreakStrategy)) {
mTextBreakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY;
} else if ("simple".equals(textBreakStrategy)) {
mTextBreakStrategy = Layout.BREAK_STRATEGY_SIMPLE;
} else if ("balanced".equals(textBreakStrategy)) {
mTextBreakStrategy = Layout.BREAK_STRATEGY_BALANCED;
} else {
throw new JSApplicationIllegalArgumentException("Invalid textBreakStrategy: " + textBreakStrategy);
}
markUpdated();
}
示例8: setDisplay
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
@ReactProp(name = ViewProps.DISPLAY)
public void setDisplay(@Nullable String display) {
if (isVirtual()) {
return;
}
if (display == null) {
setDisplay(YogaDisplay.FLEX);
return;
}
switch (display) {
case "flex": {
setDisplay(YogaDisplay.FLEX);
break;
}
case "none": {
setDisplay(YogaDisplay.NONE);
break;
}
default: {
throw new JSApplicationIllegalArgumentException(
"invalid value for display: " + display);
}
}
}
示例9: toScaleType
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
/**
* Converts JS resize modes into {@code ScalingUtils.ScaleType}.
* See {@code ImageResizeMode.js}.
*/
public static ScalingUtils.ScaleType toScaleType(@Nullable String resizeModeValue) {
if ("contain".equals(resizeModeValue)) {
return ScalingUtils.ScaleType.FIT_CENTER;
}
if ("cover".equals(resizeModeValue)) {
return ScalingUtils.ScaleType.CENTER_CROP;
}
if ("stretch".equals(resizeModeValue)) {
return ScalingUtils.ScaleType.FIT_XY;
}
if ("center".equals(resizeModeValue)) {
return ScalingUtils.ScaleType.CENTER_INSIDE;
}
if (resizeModeValue == null) {
// Use the default. Never use null.
return defaultValue();
}
throw new JSApplicationIllegalArgumentException(
"Invalid resize mode: '" + resizeModeValue + "'");
}
示例10: getPhotos
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
/**
* Get photos from {@link MediaStore.Images}, most recent first.
*
* @param params a map containing the following keys:
* <ul>
* <li>first (mandatory): a number representing the number of photos to fetch</li>
* <li>
* after (optional): a cursor that matches page_info[end_cursor] returned by a
* previous call to {@link #getPhotos}
* </li>
* <li>groupName (optional): an album name</li>
* <li>
* mimeType (optional): restrict returned images to a specific mimetype (e.g.
* image/jpeg)
* </li>
* </ul>
* @param promise the Promise to be resolved when the photos are loaded; for a format of the
* parameters passed to this callback, see {@code getPhotosReturnChecker} in CameraRoll.js
*/
@ReactMethod
public void getPhotos(final ReadableMap params, final Promise promise) {
int first = params.getInt("first");
String after = params.hasKey("after") ? params.getString("after") : null;
String groupName = params.hasKey("groupName") ? params.getString("groupName") : null;
ReadableArray mimeTypes = params.hasKey("mimeTypes")
? params.getArray("mimeTypes")
: null;
if (params.hasKey("groupTypes")) {
throw new JSApplicationIllegalArgumentException("groupTypes is not supported on Android");
}
new GetPhotosTask(
getReactApplicationContext(),
first,
after,
groupName,
mimeTypes,
promise)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
示例11: getInitialURL
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
/**
* Return the URL the activity was started with
*
* @param promise a promise which is resolved with the initial URL
*/
@ReactMethod
public void getInitialURL(Promise promise) {
try {
Activity currentActivity = getCurrentActivity();
String initialURL = null;
if (currentActivity != null) {
Intent intent = currentActivity.getIntent();
String action = intent.getAction();
Uri uri = intent.getData();
if (Intent.ACTION_VIEW.equals(action) && uri != null) {
initialURL = uri.toString();
}
}
promise.resolve(initialURL);
} catch (Exception e) {
promise.reject(new JSApplicationIllegalArgumentException(
"Could not get the initial URL : " + e.getMessage()));
}
}
示例12: canOpenURL
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
/**
* Determine whether or not an installed app can handle a given URL.
*
* @param url the URL to open
* @param promise a promise that is always resolved with a boolean argument
*/
@ReactMethod
public void canOpenURL(String url, Promise promise) {
if (url == null || url.isEmpty()) {
promise.reject(new JSApplicationIllegalArgumentException("Invalid URL: " + url));
return;
}
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
// We need Intent.FLAG_ACTIVITY_NEW_TASK since getReactApplicationContext() returns
// the ApplicationContext instead of the Activity context.
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
boolean canOpen =
intent.resolveActivity(getReactApplicationContext().getPackageManager()) != null;
promise.resolve(canOpen);
} catch (Exception e) {
promise.reject(new JSApplicationIllegalArgumentException(
"Could not check if URL '" + url + "' can be opened: " + e.getMessage()));
}
}
示例13: setFlexWrap
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
@ReactProp(name = ViewProps.FLEX_WRAP)
public void setFlexWrap(@Nullable String flexWrap) {
if (isVirtual()) {
return;
}
if (flexWrap == null) {
setFlexWrap(YogaWrap.NO_WRAP);
return;
}
switch (flexWrap) {
case "nowrap": {
setFlexWrap(YogaWrap.NO_WRAP);
break;
}
case "wrap": {
setFlexWrap(YogaWrap.WRAP);
break;
}
default: {
throw new JSApplicationIllegalArgumentException(
"invalid value for flexWrap: " + flexWrap);
}
}
}
示例14: updateViewProp
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
public void updateViewProp(
ViewManager viewManager,
View viewToUpdate,
ReactStylesDiffMap props) {
try {
if (mIndex == null) {
VIEW_MGR_ARGS[0] = viewToUpdate;
VIEW_MGR_ARGS[1] = extractProperty(props);
mSetter.invoke(viewManager, VIEW_MGR_ARGS);
Arrays.fill(VIEW_MGR_ARGS, null);
} else {
VIEW_MGR_GROUP_ARGS[0] = viewToUpdate;
VIEW_MGR_GROUP_ARGS[1] = mIndex;
VIEW_MGR_GROUP_ARGS[2] = extractProperty(props);
mSetter.invoke(viewManager, VIEW_MGR_GROUP_ARGS);
Arrays.fill(VIEW_MGR_GROUP_ARGS, null);
}
} catch (Throwable t) {
FLog.e(ViewManager.class, "Error while updating prop " + mPropName, t);
throw new JSApplicationIllegalArgumentException("Error while updating property '" +
mPropName + "' of a view managed by: " + viewManager.getName(), t);
}
}
示例15: updateShadowNodeProp
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; //导入依赖的package包/类
public void updateShadowNodeProp(
ReactShadowNode nodeToUpdate,
ReactStylesDiffMap props) {
try {
if (mIndex == null) {
SHADOW_ARGS[0] = extractProperty(props);
mSetter.invoke(nodeToUpdate, SHADOW_ARGS);
Arrays.fill(SHADOW_ARGS, null);
} else {
SHADOW_GROUP_ARGS[0] = mIndex;
SHADOW_GROUP_ARGS[1] = extractProperty(props);
mSetter.invoke(nodeToUpdate, SHADOW_GROUP_ARGS);
Arrays.fill(SHADOW_GROUP_ARGS, null);
}
} catch (Throwable t) {
FLog.e(ViewManager.class, "Error while updating prop " + mPropName, t);
throw new JSApplicationIllegalArgumentException("Error while updating property '" +
mPropName + "' in shadow node of type: " + nodeToUpdate.getViewClass(), t);
}
}