本文整理汇总了Java中com.facebook.infer.annotation.Assertions.assumeNotNull方法的典型用法代码示例。如果您正苦于以下问题:Java Assertions.assumeNotNull方法的具体用法?Java Assertions.assumeNotNull怎么用?Java Assertions.assumeNotNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.infer.annotation.Assertions
的用法示例。
在下文中一共展示了Assertions.assumeNotNull方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
示例2: collectDrawView
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
final DrawView collectDrawView(
float left,
float top,
float right,
float bottom,
float clipLeft,
float clipTop,
float clipRight,
float clipBottom) {
Assertions.assumeNotNull(mDrawView);
if (mDrawView == EMPTY_DRAW_VIEW) {
// This is the first time we have collected this DrawView, but we have to create a new
// DrawView anyway, as reactTag is final, and our DrawView instance is the static copy.
mDrawView = new DrawView(getReactTag());
}
// avoid path clipping if overflow: visible
float clipRadius = mClipToBounds ? mClipRadius : 0.0f;
// We have the correct react tag, but we may need a new copy with updated bounds. If the bounds
// match or were never set, the same view is returned.
mDrawView = mDrawView.collectDrawView(
left,
top,
right,
bottom,
left + mLogicalOffset.left,
top + mLogicalOffset.top,
right + mLogicalOffset.right,
bottom + mLogicalOffset.bottom,
clipLeft,
clipTop,
clipRight,
clipBottom,
clipRadius);
return mDrawView;
}
示例3: measureHelper
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
private void measureHelper(int reactTag, boolean relativeToWindow, Callback callback) {
FlatShadowNode node = (FlatShadowNode) resolveShadowNode(reactTag);
if (node.mountsToView()) {
mStateBuilder.ensureBackingViewIsCreated(node);
if (relativeToWindow) {
super.measureInWindow(reactTag, callback);
} else {
super.measure(reactTag, callback);
}
return;
}
// virtual nodes do not have values for width and height, so get these values
// from the first non-virtual parent node
while (node != null && node.isVirtual()) {
node = (FlatShadowNode) node.getParent();
}
if (node == null) {
// everything is virtual, this shouldn't happen so just silently return
return;
}
float width = node.getLayoutWidth();
float height = node.getLayoutHeight();
boolean nodeMountsToView = node.mountsToView();
// this is to avoid double-counting xInParent and yInParent when we visit
// the while loop, below.
float xInParent = nodeMountsToView ? node.getLayoutX() : 0;
float yInParent = nodeMountsToView ? node.getLayoutY() : 0;
while (!node.mountsToView()) {
if (!node.isVirtual()) {
xInParent += node.getLayoutX();
yInParent += node.getLayoutY();
}
node = Assertions.assumeNotNull((FlatShadowNode) node.getParent());
}
float parentWidth = node.getLayoutWidth();
float parentHeight = node.getLayoutHeight();
FlatUIViewOperationQueue operationsQueue = mStateBuilder.getOperationsQueue();
operationsQueue.enqueueMeasureVirtualView(
node.getReactTag(),
xInParent / parentWidth,
yInParent / parentHeight,
width / parentWidth,
height / parentHeight,
relativeToWindow,
callback);
}
示例4: getHierarchy
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
GenericDraweeHierarchy getHierarchy() {
return (GenericDraweeHierarchy) Assertions.assumeNotNull(mDraweeController.getHierarchy());
}
示例5: onNewResult
import com.facebook.infer.annotation.Assertions; //导入方法依赖的package包/类
@Override
public void onNewResult(DataSource<CloseableReference<CloseableImage>> dataSource) {
if (!dataSource.isFinished()) {
// only interested in final image, no need to close the dataSource
return;
}
try {
if (mDataSource != dataSource) {
// Shouldn't ever happen, but let's be safe (dataSource got closed by callback still fired?)
return;
}
mDataSource = null;
CloseableReference<CloseableImage> imageReference = dataSource.getResult();
if (imageReference == null) {
// Shouldn't ever happen, but let's be safe (dataSource got closed by callback still fired?)
return;
}
CloseableImage image = imageReference.get();
if (!(image instanceof CloseableBitmap)) {
// only bitmaps are supported
imageReference.close();
return;
}
mImageRef = imageReference;
Bitmap bitmap = getBitmap();
if (bitmap == null) {
// Shouldn't ever happen, but let's be safe.
return;
}
BitmapUpdateListener listener = Assertions.assumeNotNull(mBitmapUpdateListener);
listener.onBitmapReady(bitmap);
listener.onImageLoadEvent(ImageLoadEvent.ON_LOAD);
listener.onImageLoadEvent(ImageLoadEvent.ON_LOAD_END);
} finally {
dataSource.close();
}
}