use of android.annotation.NonNull in project android_frameworks_base by DirtyUnicorns.
the class DrawableInflater method inflateFromClass.
@NonNull
private Drawable inflateFromClass(@NonNull String className) {
try {
Constructor<? extends Drawable> constructor;
synchronized (CONSTRUCTOR_MAP) {
constructor = CONSTRUCTOR_MAP.get(className);
if (constructor == null) {
final Class<? extends Drawable> clazz = mClassLoader.loadClass(className).asSubclass(Drawable.class);
constructor = clazz.getConstructor();
CONSTRUCTOR_MAP.put(className, constructor);
}
}
return constructor.newInstance();
} catch (NoSuchMethodException e) {
final InflateException ie = new InflateException("Error inflating class " + className);
ie.initCause(e);
throw ie;
} catch (ClassCastException e) {
// If loaded class is not a Drawable subclass.
final InflateException ie = new InflateException("Class is not a Drawable " + className);
ie.initCause(e);
throw ie;
} catch (ClassNotFoundException e) {
// If loadClass fails, we should propagate the exception.
final InflateException ie = new InflateException("Class not found " + className);
ie.initCause(e);
throw ie;
} catch (Exception e) {
final InflateException ie = new InflateException("Error inflating class " + className);
ie.initCause(e);
throw ie;
}
}
use of android.annotation.NonNull in project android_frameworks_base by DirtyUnicorns.
the class View method updateDisplayListIfDirty.
/**
* Gets the RenderNode for the view, and updates its DisplayList (if needed and supported)
* @hide
*/
@NonNull
public RenderNode updateDisplayListIfDirty() {
final RenderNode renderNode = mRenderNode;
if (!canHaveDisplayList()) {
// can't populate RenderNode, don't try
return renderNode;
}
if ((mPrivateFlags & PFLAG_DRAWING_CACHE_VALID) == 0 || !renderNode.isValid() || (mRecreateDisplayList)) {
// children to restore/recreate theirs
if (renderNode.isValid() && !mRecreateDisplayList) {
mPrivateFlags |= PFLAG_DRAWN | PFLAG_DRAWING_CACHE_VALID;
mPrivateFlags &= ~PFLAG_DIRTY_MASK;
dispatchGetDisplayList();
// no work needed
return renderNode;
}
// If we got here, we're recreating it. Mark it as such to ensure that
// we copy in child display lists into ours in drawChild()
mRecreateDisplayList = true;
int width = mRight - mLeft;
int height = mBottom - mTop;
int layerType = getLayerType();
final DisplayListCanvas canvas = renderNode.start(width, height);
canvas.setHighContrastText(mAttachInfo.mHighContrastText);
try {
if (layerType == LAYER_TYPE_SOFTWARE) {
buildDrawingCache(true);
Bitmap cache = getDrawingCache(true);
if (cache != null) {
canvas.drawBitmap(cache, 0, 0, mLayerPaint);
}
} else {
computeScroll();
canvas.translate(-mScrollX, -mScrollY);
mPrivateFlags |= PFLAG_DRAWN | PFLAG_DRAWING_CACHE_VALID;
mPrivateFlags &= ~PFLAG_DIRTY_MASK;
// Fast path for layouts with no backgrounds
if ((mPrivateFlags & PFLAG_SKIP_DRAW) == PFLAG_SKIP_DRAW) {
dispatchDraw(canvas);
if (mOverlay != null && !mOverlay.isEmpty()) {
mOverlay.getOverlayView().draw(canvas);
}
} else {
draw(canvas);
}
}
} finally {
renderNode.end(canvas);
setDisplayListProperties(renderNode);
}
} else {
mPrivateFlags |= PFLAG_DRAWN | PFLAG_DRAWING_CACHE_VALID;
mPrivateFlags &= ~PFLAG_DIRTY_MASK;
}
return renderNode;
}
use of android.annotation.NonNull in project android_frameworks_base by DirtyUnicorns.
the class LocaleList method getDefault.
/**
* The result is guaranteed to include the default Locale returned by Locale.getDefault(), but
* not necessarily at the top of the list. The default locale not being at the top of the list
* is an indication that the system has set the default locale to one of the user's other
* preferred locales, having concluded that the primary preference is not supported but a
* secondary preference is.
*
* <p>Note that the default LocaleList would change if Locale.setDefault() is called. This
* method takes that into account by always checking the output of Locale.getDefault() and
* recalculating the default LocaleList if needed.</p>
*/
@NonNull
@Size(min = 1)
public static LocaleList getDefault() {
final Locale defaultLocale = Locale.getDefault();
synchronized (sLock) {
if (!defaultLocale.equals(sLastDefaultLocale)) {
sLastDefaultLocale = defaultLocale;
// locale list. So let's recalculate the locale list.
if (sDefaultLocaleList != null && defaultLocale.equals(sDefaultLocaleList.get(0))) {
// default locale list, so we don't need to construct a new locale list.
return sDefaultLocaleList;
}
sDefaultLocaleList = new LocaleList(defaultLocale, sLastExplicitlySetLocaleList);
sDefaultAdjustedLocaleList = sDefaultLocaleList;
}
// sDefaultLocaleList.
return sDefaultLocaleList;
}
}
use of android.annotation.NonNull in project android_frameworks_base by DirtyUnicorns.
the class PackageManagerSettingsTests method createFakeUsers.
@NonNull
private List<UserInfo> createFakeUsers() {
ArrayList<UserInfo> users = new ArrayList<>();
users.add(new UserInfo(UserHandle.USER_SYSTEM, "test user", UserInfo.FLAG_INITIALIZED));
return users;
}
use of android.annotation.NonNull in project android_frameworks_base by DirtyUnicorns.
the class ParserFactory method create.
@NonNull
private static XmlPullParser create(@NonNull InputStream stream, @Nullable String name, long size, boolean isLayout) throws XmlPullParserException {
XmlPullParser parser = instantiateParser(name);
stream = readAndClose(stream, name, size);
parser.setInput(stream, ENCODING);
if (isLayout) {
try {
return new LayoutParserWrapper(parser).peekTillLayoutStart();
} catch (IOException e) {
throw new XmlPullParserException(null, parser, e);
}
}
return parser;
}
Aggregations