本文整理汇总了Java中com.facebook.infer.annotation.Assertions类的典型用法代码示例。如果您正苦于以下问题:Java Assertions类的具体用法?Java Assertions怎么用?Java Assertions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Assertions类属于com.facebook.infer.annotation包,在下文中一共展示了Assertions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: receiveCommand
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
@Override
public void receiveCommand(SketchViewContainer root, int commandId, @Nullable ReadableArray args) {
Assertions.assertNotNull(root);
switch (commandId) {
case COMMAND_CLEAR_SKETCH:
root.sketchView.clear();
return;
case COMMAND_CHANGE_TOOL:
Assertions.assertNotNull(args);
int toolId = args.getInt(0);
root.sketchView.setToolType(toolId);
return;
case COMMAND_SAVE_SKETCH:
try {
SketchFile sketchFile = root.saveToLocalCache();
onSaveSketch(root, sketchFile);
return;
} catch (IOException e) {
e.printStackTrace();
}
default:
throw new IllegalArgumentException(String.format(Locale.ENGLISH, "Unsupported command %d.", commandId));
}
}
示例2: onKeyUp
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
/**
* Helper to forward onKeyUp commands from our host Activity.
* This allows ReactFragment to handle double tap reloads and dev menus
*
* @param keyCode keyCode
* @param event event
* @return true if we handled onKeyUp
*/
@SuppressWarnings("unused")
public boolean onKeyUp(int keyCode, KeyEvent event) {
boolean handled = false;
if (getReactNativeHost().getUseDeveloperSupport() && getReactNativeHost().hasInstance()) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
getReactNativeHost().getReactInstanceManager().showDevOptionsDialog();
handled = true;
}
boolean didDoubleTapR = Assertions.assertNotNull(mDoubleTapReloadRecognizer).didDoubleTapR(keyCode, getActivity().getCurrentFocus());
if (didDoubleTapR) {
getReactNativeHost().getReactInstanceManager().getDevSupportManager().handleReloadJS();
handled = true;
}
}
return handled;
}
示例3: createReactInstanceManager
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
protected ReactInstanceManager createReactInstanceManager() {
ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
.setApplication(mApplication)
.setJSMainModuleName(getJSMainModuleName())
.setUseDeveloperSupport(getUseDeveloperSupport())
.setRedBoxHandler(getRedBoxHandler())
.setUIImplementationProvider(getUIImplementationProvider())
.setInitialLifecycleState(LifecycleState.BEFORE_CREATE);
for (ReactPackage reactPackage : getPackages()) {
builder.addPackage(reactPackage);
}
String jsBundleFile = getJSBundleFile();
if (jsBundleFile != null) {
builder.setJSBundleFile(jsBundleFile);
} else {
builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
}
return builder.build();
}
示例4: measure
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
@Override
public long measure(
YogaNode node,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode) {
// measure() should never be called before setThemedContext()
EditText editText = Assertions.assertNotNull(mEditText);
int fontSize = getFontSize();
editText.setTextSize(
TypedValue.COMPLEX_UNIT_PX,
fontSize == UNSET ?
(int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)) : fontSize);
if (mNumberOfLines != UNSET) {
editText.setLines(mNumberOfLines);
}
editText.measure(
MeasureUtil.getMeasureSpec(width, widthMode),
MeasureUtil.getMeasureSpec(height, heightMode));
return YogaMeasureOutput.make(editText.getMeasuredWidth(), editText.getMeasuredHeight());
}
示例5: receiveCommand
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
@Override
public void receiveCommand(
final RNSparkButton view,
int commandType,
@Nullable ReadableArray args) {
Assertions.assertNotNull(view);
Assertions.assertNotNull(args);
switch (commandType) {
case COMMAND_PLAY_ANIMATION: {
view.playAnimation();
return;
}
default:
throw new IllegalArgumentException(String.format(
"Unsupported command %d received by %s.",
commandType,
getClass().getSimpleName()));
}
}
示例6: addViewWithSubviewClippingEnabled
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
void addViewWithSubviewClippingEnabled(View child, int index, LayoutParams params) {
Assertions.assertCondition(mRemoveClippedSubviews);
Assertions.assertNotNull(mClippingRect);
Assertions.assertNotNull(mAllChildren);
addInArray(child, index);
// we add view as "clipped" and then run {@link #updateSubviewClipStatus} to conditionally
// attach it
int clippedSoFar = 0;
for (int i = 0; i < index; i++) {
if (mAllChildren[i].getParent() == null) {
clippedSoFar++;
}
}
updateSubviewClipStatus(mClippingRect, index, clippedSoFar);
child.addOnLayoutChangeListener(mChildrenLayoutChangeListener);
}
示例7: ReactEditText
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
public ReactEditText(Context context) {
super(context);
setFocusableInTouchMode(false);
mInputMethodManager = (InputMethodManager)
Assertions.assertNotNull(getContext().getSystemService(Context.INPUT_METHOD_SERVICE));
mDefaultGravityHorizontal =
getGravity() & (Gravity.HORIZONTAL_GRAVITY_MASK | Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK);
mDefaultGravityVertical = getGravity() & Gravity.VERTICAL_GRAVITY_MASK;
mNativeEventCount = 0;
mMostRecentEventCount = 0;
mIsSettingTextFromJS = false;
mIsJSSettingFocus = false;
mBlurOnSubmit = true;
mDisableFullscreen = false;
mListeners = null;
mTextWatcherDelegator = null;
mStagedInputType = getInputType();
mKeyListener = new InternalKeyListener();
mScrollWatcher = null;
}
示例8: finishTask
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
/**
* Finish a JS task. Doesn't actually stop the task on the JS side, only removes it from the list
* of active tasks and notifies listeners. A task can only be finished once.
*
* @param taskId the unique id returned by {@link #startTask}.
*/
public synchronized void finishTask(final int taskId) {
Assertions.assertCondition(
mActiveTasks.remove(taskId),
"Tried to finish non-existent task with id " + taskId + ".");
Runnable timeout = mTaskTimeouts.get(taskId);
if (timeout != null) {
mHandler.removeCallbacks(timeout);
mTaskTimeouts.remove(taskId);
}
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run() {
for (HeadlessJsTaskEventListener listener : mHeadlessJsTaskEventListeners) {
listener.onHeadlessJsTaskFinish(taskId);
}
}
});
}
示例9: addGrandchildren
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
private void addGrandchildren(
ReactShadowNode nativeParent,
ReactShadowNode child,
int index) {
Assertions.assertCondition(!nativeParent.isLayoutOnly());
// `child` can't hold native children. Add all of `child`'s children to `parent`.
int currentIndex = index;
for (int i = 0; i < child.getChildCount(); i++) {
ReactShadowNode grandchild = child.getChildAt(i);
Assertions.assertCondition(grandchild.getNativeParent() == null);
if (grandchild.isLayoutOnly()) {
// Adding this child could result in adding multiple native views
int grandchildCountBefore = nativeParent.getNativeChildCount();
addLayoutOnlyNode(nativeParent, grandchild, currentIndex);
int grandchildCountAfter = nativeParent.getNativeChildCount();
currentIndex += grandchildCountAfter - grandchildCountBefore;
} else {
addNonLayoutNode(nativeParent, grandchild, currentIndex);
currentIndex++;
}
}
}
示例10: updateSubviewClipStatus
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
private void updateSubviewClipStatus(Rect clippingRect, int idx, int clippedSoFar) {
View child = Assertions.assertNotNull(mAllChildren)[idx];
sHelperRect.set(child.getLeft(), child.getTop(), child.getRight(), child.getBottom());
boolean intersects = clippingRect
.intersects(sHelperRect.left, sHelperRect.top, sHelperRect.right, sHelperRect.bottom);
boolean needUpdateClippingRecursive = false;
// We never want to clip children that are being animated, as this can easily break layout :
// when layout animation changes size and/or position of views contained inside a listview that
// clips offscreen children, we need to ensure that, when view exits the viewport, final size
// and position is set prior to removing the view from its listview parent.
// Otherwise, when view gets re-attached again, i.e when it re-enters the viewport after scroll,
// it won't be size and located properly.
Animation animation = child.getAnimation();
boolean isAnimating = animation != null && !animation.hasEnded();
if (!intersects && child.getParent() != null && !isAnimating) {
// We can try saving on invalidate call here as the view that we remove is out of visible area
// therefore invalidation is not necessary.
super.removeViewsInLayout(idx - clippedSoFar, 1);
needUpdateClippingRecursive = true;
} else if (intersects && child.getParent() == null) {
super.addViewInLayout(child, idx - clippedSoFar, sDefaultLayoutParam, true);
invalidate();
needUpdateClippingRecursive = true;
} else if (intersects) {
// If there is any intersection we need to inform the child to update its clipping rect
needUpdateClippingRecursive = true;
}
if (needUpdateClippingRecursive) {
if (child instanceof ReactClippingViewGroup) {
// we don't use {@link sHelperRect} until the end of this loop, therefore it's safe
// to call this method that may write to the same {@link sHelperRect} object.
ReactClippingViewGroup clippingChild = (ReactClippingViewGroup) child;
if (clippingChild.getRemoveClippedSubviews()) {
clippingChild.updateClippingRect();
}
}
}
}
示例11: canCoalesce
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
@Override
public boolean canCoalesce() {
// We can coalesce move events but not start/end events. Coalescing move events should probably
// append historical move data like MotionEvent batching does. This is left as an exercise for
// the reader.
switch (Assertions.assertNotNull(mTouchEventType)) {
case START:
case END:
case CANCEL:
return false;
case MOVE:
return true;
default:
throw new RuntimeException("Unknown touch event type: " + mTouchEventType);
}
}
示例12: removeViewWithSubviewClippingEnabled
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
void removeViewWithSubviewClippingEnabled(View view) {
Assertions.assertCondition(mRemoveClippedSubviews);
Assertions.assertNotNull(mClippingRect);
Assertions.assertNotNull(mAllChildren);
view.removeOnLayoutChangeListener(mChildrenLayoutChangeListener);
int index = indexOfChildInAllChildren(view);
if (mAllChildren[index].getParent() != null) {
int clippedSoFar = 0;
for (int i = 0; i < index; i++) {
if (mAllChildren[i].getParent() == null) {
clippedSoFar++;
}
}
super.removeViewsInLayout(index - clippedSoFar, 1);
}
removeFromArray(index);
}
示例13: doFrame
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
@Override
public void doFrame(long frameTimeNanos) {
if (isPaused.get() && !isRunningTasks.get()) {
return;
}
// If the JS thread is busy for multiple frames we cancel any other pending runnable.
if (mCurrentIdleCallbackRunnable != null) {
mCurrentIdleCallbackRunnable.cancel();
}
mCurrentIdleCallbackRunnable = new IdleCallbackRunnable(frameTimeNanos);
getReactApplicationContext().runOnJSQueueThread(mCurrentIdleCallbackRunnable);
Assertions.assertNotNull(mReactChoreographer).postFrameCallback(
ReactChoreographer.CallbackType.IDLE_EVENT,
this);
}
示例14: removeAndDisposeAllChildren
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
public void removeAndDisposeAllChildren() {
if (getChildCount() == 0) {
return;
}
int decrease = 0;
for (int i = getChildCount() - 1; i >= 0; i--) {
if (mYogaNode != null && !mYogaNode.isMeasureDefined()) {
mYogaNode.removeChildAt(i);
}
ReactShadowNode toRemove = getChildAt(i);
toRemove.mParent = null;
toRemove.dispose();
decrease += toRemove.mIsLayoutOnly ? toRemove.mTotalNativeChildren : 1;
}
Assertions.assertNotNull(mChildren).clear();
markUpdated();
mTotalNativeChildren -= decrease;
updateNativeChildrenCountInParent(-decrease);
}
示例15: createTypeface
import com.facebook.infer.annotation.Assertions; //导入依赖的package包/类
private static Typeface createTypeface(String fontFamilyName, int style) {
String extension = EXTENSIONS[style];
StringBuilder fileNameBuffer = new StringBuilder(32)
.append(FONTS_ASSET_PATH)
.append(fontFamilyName)
.append(extension);
int length = fileNameBuffer.length();
for (String fileExtension : FILE_EXTENSIONS) {
String fileName = fileNameBuffer.append(fileExtension).toString();
try {
return Typeface.createFromAsset(sAssetManager, fileName);
} catch (RuntimeException e) {
// unfortunately Typeface.createFromAsset throws an exception instead of returning null
// if the typeface doesn't exist
fileNameBuffer.setLength(length);
}
}
return Assertions.assumeNotNull(Typeface.create(fontFamilyName, style));
}