本文整理汇总了Java中com.facebook.infer.annotation.Assertions.assertNotNull方法的典型用法代码示例。如果您正苦于以下问题:Java Assertions.assertNotNull方法的具体用法?Java Assertions.assertNotNull怎么用?Java Assertions.assertNotNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.infer.annotation.Assertions
的用法示例。
在下文中一共展示了Assertions.assertNotNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertNodeDoesNotNeedCustomLayoutForChildren
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
private void assertNodeDoesNotNeedCustomLayoutForChildren(ReactShadowNode node) {
ViewManager viewManager = Assertions.assertNotNull(mViewManagers.get(node.getViewClass()));
ViewGroupManager viewGroupManager;
if (viewManager instanceof ViewGroupManager) {
viewGroupManager = (ViewGroupManager) viewManager;
} else {
throw new IllegalViewOperationException("Trying to use view " + node.getViewClass() +
" as a parent, but its Manager doesn't extends ViewGroupManager");
}
if (viewGroupManager != null && viewGroupManager.needsCustomLayoutForChildren()) {
throw new IllegalViewOperationException(
"Trying to measure a view using measureLayout/measureLayoutRelativeToParent relative to" +
" an ancestor that requires custom layout for it's children (" + node.getViewClass() +
"). Use measure instead.");
}
}
示例2: receiveCommand
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
@Override
public void receiveCommand(
ReactViewPager viewPager,
int commandType,
@Nullable ReadableArray args) {
Assertions.assertNotNull(viewPager);
Assertions.assertNotNull(args);
switch (commandType) {
case COMMAND_SET_PAGE: {
viewPager.setCurrentItemFromJs(args.getInt(0), true);
return;
}
case COMMAND_SET_PAGE_WITHOUT_ANIMATION: {
viewPager.setCurrentItemFromJs(args.getInt(0), false);
return;
}
default:
throw new IllegalArgumentException(String.format(
"Unsupported command %d received by %s.",
commandType,
getClass().getSimpleName()));
}
}
示例3: 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()));
}
}
示例4: getDebugServerHost
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
public String getDebugServerHost() {
// Check host setting first. If empty try to detect emulator type and use default
// hostname for those
String hostFromSettings = mPreferences.getString(PREFS_DEBUG_SERVER_HOST_KEY, null);
if (!TextUtils.isEmpty(hostFromSettings)) {
return Assertions.assertNotNull(hostFromSettings);
}
String host = AndroidInfoHelpers.getServerHost();
if (host.equals(AndroidInfoHelpers.DEVICE_LOCALHOST)) {
FLog.w(
TAG,
"You seem to be running on device. Run 'adb reverse tcp:8081 tcp:8081' " +
"to forward the debug server's port to the device.");
}
return host;
}
示例5: onSensorChanged
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
if (sensorEvent.timestamp - mLastTimestamp < MIN_TIME_BETWEEN_SAMPLES_MS) {
return;
}
Assertions.assertNotNull(mTimestamps);
Assertions.assertNotNull(mMagnitudes);
float ax = sensorEvent.values[0];
float ay = sensorEvent.values[1];
float az = sensorEvent.values[2];
mLastTimestamp = sensorEvent.timestamp;
mTimestamps[mCurrentIndex] = sensorEvent.timestamp;
mMagnitudes[mCurrentIndex] = Math.sqrt(ax * ax + ay * ay + az * az);
maybeDispatchShake(sensorEvent.timestamp);
mCurrentIndex = (mCurrentIndex + 1) % MAX_SAMPLES;
}
示例6: setRemoveClippedSubviews
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
@Override
public void setRemoveClippedSubviews(boolean removeClippedSubviews) {
if (removeClippedSubviews == mRemoveClippedSubviews) {
return;
}
mRemoveClippedSubviews = removeClippedSubviews;
if (removeClippedSubviews) {
mClippingRect = new Rect();
ReactClippingViewGroupHelper.calculateClippingRect(this, mClippingRect);
mAllChildrenCount = getChildCount();
int initialSize = Math.max(12, mAllChildrenCount);
mAllChildren = new View[initialSize];
mChildrenLayoutChangeListener = new ChildrenLayoutChangeListener(this);
for (int i = 0; i < mAllChildrenCount; i++) {
View child = getChildAt(i);
mAllChildren[i] = child;
child.addOnLayoutChangeListener(mChildrenLayoutChangeListener);
}
updateClippingRect();
} else {
// Add all clipped views back, deallocate additional arrays, remove layoutChangeListener
Assertions.assertNotNull(mClippingRect);
Assertions.assertNotNull(mAllChildren);
Assertions.assertNotNull(mChildrenLayoutChangeListener);
for (int i = 0; i < mAllChildrenCount; i++) {
mAllChildren[i].removeOnLayoutChangeListener(mChildrenLayoutChangeListener);
}
getDrawingRect(mClippingRect);
updateClippingToRect(mClippingRect);
mAllChildren = null;
mClippingRect = null;
mAllChildrenCount = 0;
mChildrenLayoutChangeListener = null;
}
}
示例7: enableFpsListener
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
private void enableFpsListener() {
if (isScrollPerfLoggingEnabled()) {
Assertions.assertNotNull(mFpsListener);
Assertions.assertNotNull(mScrollPerfTag);
mFpsListener.enable(mScrollPerfTag);
}
}
示例8: updateSubviewClipStatus
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
private void updateSubviewClipStatus(View subview) {
if (!mRemoveClippedSubviews || getParent() == null) {
return;
}
Assertions.assertNotNull(mClippingRect);
Assertions.assertNotNull(mAllChildren);
// do fast check whether intersect state changed
sHelperRect.set(subview.getLeft(), subview.getTop(), subview.getRight(), subview.getBottom());
boolean intersects = mClippingRect
.intersects(sHelperRect.left, sHelperRect.top, sHelperRect.right, sHelperRect.bottom);
// If it was intersecting before, should be attached to the parent
boolean oldIntersects = (subview.getParent() != null);
if (intersects != oldIntersects) {
int clippedSoFar = 0;
for (int i = 0; i < mAllChildrenCount; i++) {
if (mAllChildren[i] == subview) {
updateSubviewClipStatus(mClippingRect, i, clippedSoFar);
break;
}
if (mAllChildren[i].getParent() == null) {
clippedSoFar++;
}
}
}
}
示例9: initDisplayMetrics
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
public static void initDisplayMetrics(Context context) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
DisplayMetricsHolder.setWindowDisplayMetrics(displayMetrics);
DisplayMetrics screenDisplayMetrics = new DisplayMetrics();
screenDisplayMetrics.setTo(displayMetrics);
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Assertions.assertNotNull(
wm,
"WindowManager is null!");
Display display = wm.getDefaultDisplay();
// Get the real display metrics if we are using API level 17 or higher.
// The real metrics include system decor elements (e.g. soft menu bar).
//
// See: http://developer.android.com/reference/android/view/Display.html#getRealMetrics(android.util.DisplayMetrics)
if (Build.VERSION.SDK_INT >= 17) {
display.getRealMetrics(screenDisplayMetrics);
} else {
// For 14 <= API level <= 16, we need to invoke getRawHeight and getRawWidth to get the real dimensions.
// Since react-native only supports API level 16+ we don't have to worry about other cases.
//
// Reflection exceptions are rethrown at runtime.
//
// See: http://stackoverflow.com/questions/14341041/how-to-get-real-screen-height-and-width/23861333#23861333
try {
Method mGetRawH = Display.class.getMethod("getRawHeight");
Method mGetRawW = Display.class.getMethod("getRawWidth");
screenDisplayMetrics.widthPixels = (Integer) mGetRawW.invoke(display);
screenDisplayMetrics.heightPixels = (Integer) mGetRawH.invoke(display);
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
throw new RuntimeException("Error getting real dimensions for API level < 17", e);
}
}
DisplayMetricsHolder.setScreenDisplayMetrics(screenDisplayMetrics);
}
示例10: getFpsInfo
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
/**
* Returns the FpsInfo as if stop had been called at the given upToTimeMs. Only valid if
* monitoring was started with {@link #startAndRecordFpsAtEachFrame()}.
*/
public @Nullable FpsInfo getFpsInfo(long upToTimeMs) {
Assertions.assertNotNull(mTimeToFps, "FPS was not recorded at each frame!");
Map.Entry<Long, FpsInfo> bestEntry = mTimeToFps.floorEntry(upToTimeMs);
if (bestEntry == null) {
return null;
}
return bestEntry.getValue();
}
示例11: updateClippingRect
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
@Override
public void updateClippingRect() {
if (!mRemoveClippedSubviews) {
return;
}
Assertions.assertNotNull(mClippingRect);
Assertions.assertNotNull(mAllChildren);
ReactClippingViewGroupHelper.calculateClippingRect(this, mClippingRect);
updateClippingToRect(mClippingRect);
}
示例12: getJavaScriptModule
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
public synchronized <T extends JavaScriptModule> T getJavaScriptModule(
CatalystInstance instance,
ExecutorToken executorToken,
Class<T> moduleInterface) {
HashMap<Class<? extends JavaScriptModule>, JavaScriptModule> instancesForContext =
mModuleInstances.get(executorToken);
if (instancesForContext == null) {
instancesForContext = new HashMap<>();
mModuleInstances.put(executorToken, instancesForContext);
}
JavaScriptModule module = instancesForContext.get(moduleInterface);
if (module != null) {
return (T) module;
}
JavaScriptModuleRegistration registration =
Assertions.assertNotNull(
mModuleRegistrations.get(moduleInterface),
"JS module " + moduleInterface.getSimpleName() + " hasn't been registered!");
JavaScriptModule interfaceProxy = (JavaScriptModule) Proxy.newProxyInstance(
moduleInterface.getClassLoader(),
new Class[]{moduleInterface},
new JavaScriptModuleInvocationHandler(executorToken, instance, registration));
instancesForContext.put(moduleInterface, interfaceProxy);
return (T) interfaceProxy;
}
示例13: build
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
public CatalystInstanceImpl build() {
return new CatalystInstanceImpl(
Assertions.assertNotNull(mReactQueueConfigurationSpec),
Assertions.assertNotNull(mJSExecutor),
Assertions.assertNotNull(mRegistry),
Assertions.assertNotNull(mJSModuleRegistry),
Assertions.assertNotNull(mJSBundleLoader),
Assertions.assertNotNull(mNativeModuleCallExceptionHandler));
}
示例14: updateClippingRect
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
@Override
public void updateClippingRect() {
if (!mRemoveClippedSubviews) {
return;
}
Assertions.assertNotNull(mClippingRect);
ReactClippingViewGroupHelper.calculateClippingRect(this, mClippingRect);
View contentView = getChildAt(0);
if (contentView instanceof ReactClippingViewGroup) {
((ReactClippingViewGroup) contentView).updateClippingRect();
}
}
示例15: startActivityForResult
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
/**
* Same as {@link Activity#startActivityForResult(Intent, int)}, this just redirects the call to
* the current activity. Returns whether the activity was started, as this might fail if this
* was called before the context is in the right state.
*/
public boolean startActivityForResult(Intent intent, int code, Bundle bundle) {
Activity activity = getCurrentActivity();
Assertions.assertNotNull(activity);
activity.startActivityForResult(intent, code, bundle);
return true;
}