Search in sources :

Example 81 with NonNull

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;
    }
}
Also used : InflateException(android.view.InflateException) IOException(java.io.IOException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) InflateException(android.view.InflateException) NonNull(android.annotation.NonNull)

Example 82 with NonNull

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;
}
Also used : Bitmap(android.graphics.Bitmap) Paint(android.graphics.Paint) Point(android.graphics.Point) NonNull(android.annotation.NonNull)

Example 83 with NonNull

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;
    }
}
Also used : Locale(java.util.Locale) ULocale(android.icu.util.ULocale) Size(android.annotation.Size) NonNull(android.annotation.NonNull)

Example 84 with NonNull

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;
}
Also used : ArrayList(java.util.ArrayList) UserInfo(android.content.pm.UserInfo) NonNull(android.annotation.NonNull)

Example 85 with NonNull

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;
}
Also used : XmlPullParser(org.xmlpull.v1.XmlPullParser) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException) NonNull(android.annotation.NonNull)

Aggregations

NonNull (android.annotation.NonNull)322 ArrayList (java.util.ArrayList)46 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)45 IOException (java.io.IOException)35 ComponentName (android.content.ComponentName)25 File (java.io.File)22 XmlPullParser (org.xmlpull.v1.XmlPullParser)20 Intent (android.content.Intent)18 EphemeralResolveInfo (android.content.pm.EphemeralResolveInfo)16 ResolveInfo (android.content.pm.ResolveInfo)16 Bundle (android.os.Bundle)15 RemoteException (android.os.RemoteException)15 FileNotFoundException (java.io.FileNotFoundException)15 Paint (android.graphics.Paint)14 PackageParser (android.content.pm.PackageParser)12 ContentResolver (android.content.ContentResolver)10 UserInfo (android.content.pm.UserInfo)10 StorageManager (android.os.storage.StorageManager)10 VolumeInfo (android.os.storage.VolumeInfo)10 KeyCharacteristics (android.security.keymaster.KeyCharacteristics)10