Search in sources :

Example 76 with NonNull

use of android.annotation.NonNull in project android_frameworks_base by AOSPA.

the class MenuPopupHelper method createPopup.

/**
     * Creates the popup and assigns cached properties.
     *
     * @return an initialized popup
     */
@NonNull
private MenuPopup createPopup() {
    final WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    final Display display = windowManager.getDefaultDisplay();
    final Point displaySize = new Point();
    display.getRealSize(displaySize);
    final int smallestWidth = Math.min(displaySize.x, displaySize.y);
    final int minSmallestWidthCascading = mContext.getResources().getDimensionPixelSize(com.android.internal.R.dimen.cascading_menus_min_smallest_width);
    final boolean enableCascadingSubmenus = smallestWidth >= minSmallestWidthCascading;
    final MenuPopup popup;
    if (enableCascadingSubmenus) {
        popup = new CascadingMenuPopup(mContext, mAnchorView, mPopupStyleAttr, mPopupStyleRes, mOverflowOnly);
    } else {
        popup = new StandardMenuPopup(mContext, mMenu, mAnchorView, mPopupStyleAttr, mPopupStyleRes, mOverflowOnly);
    }
    // Assign immutable properties.
    popup.addMenu(mMenu);
    popup.setOnDismissListener(mInternalOnDismissListener);
    // Assign mutable properties. These may be reassigned later.
    popup.setAnchorView(mAnchorView);
    popup.setCallback(mPresenterCallback);
    popup.setForceShowIcon(mForceShowIcon);
    popup.setGravity(mDropDownGravity);
    return popup;
}
Also used : Point(android.graphics.Point) Point(android.graphics.Point) WindowManager(android.view.WindowManager) Display(android.view.Display) NonNull(android.annotation.NonNull)

Example 77 with NonNull

use of android.annotation.NonNull in project android_frameworks_base by AOSPA.

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 78 with NonNull

use of android.annotation.NonNull in project android_frameworks_base by AOSPA.

the class AnimatedVectorDrawable method ensureAnimatorSet.

@NonNull
private void ensureAnimatorSet() {
    if (mAnimatorSetFromXml == null) {
        // TODO: Skip the AnimatorSet creation and init the VectorDrawableAnimator directly
        // with a list of LocalAnimators.
        mAnimatorSetFromXml = new AnimatorSet();
        mAnimatedVectorState.prepareLocalAnimators(mAnimatorSetFromXml, mRes);
        mAnimatorSet.init(mAnimatorSetFromXml);
        mRes = null;
    }
}
Also used : AnimatorSet(android.animation.AnimatorSet) NonNull(android.annotation.NonNull)

Example 79 with NonNull

use of android.annotation.NonNull in project android_frameworks_base by AOSPA.

the class ResourcesImpl method loadXmlResourceParser.

/**
     * Loads an XML parser for the specified file.
     *
     * @param file the path for the XML file to parse
     * @param id the resource identifier for the file
     * @param assetCookie the asset cookie for the file
     * @param type the type of resource (used for logging)
     * @return a parser for the specified XML file
     * @throws NotFoundException if the file could not be loaded
     */
@NonNull
XmlResourceParser loadXmlResourceParser(@NonNull String file, @AnyRes int id, int assetCookie, @NonNull String type) throws NotFoundException {
    if (id != 0) {
        try {
            synchronized (mCachedXmlBlocks) {
                final int[] cachedXmlBlockCookies = mCachedXmlBlockCookies;
                final String[] cachedXmlBlockFiles = mCachedXmlBlockFiles;
                final XmlBlock[] cachedXmlBlocks = mCachedXmlBlocks;
                // First see if this block is in our cache.
                final int num = cachedXmlBlockFiles.length;
                for (int i = 0; i < num; i++) {
                    if (cachedXmlBlockCookies[i] == assetCookie && cachedXmlBlockFiles[i] != null && cachedXmlBlockFiles[i].equals(file)) {
                        return cachedXmlBlocks[i].newParser();
                    }
                }
                // Not in the cache, create a new block and put it at
                // the next slot in the cache.
                final XmlBlock block = mAssets.openXmlBlockAsset(assetCookie, file);
                if (block != null) {
                    final int pos = (mLastCachedXmlBlockIndex + 1) % num;
                    mLastCachedXmlBlockIndex = pos;
                    final XmlBlock oldBlock = cachedXmlBlocks[pos];
                    if (oldBlock != null) {
                        oldBlock.close();
                    }
                    cachedXmlBlockCookies[pos] = assetCookie;
                    cachedXmlBlockFiles[pos] = file;
                    cachedXmlBlocks[pos] = block;
                    return block.newParser();
                }
            }
        } catch (Exception e) {
            final NotFoundException rnf = new NotFoundException("File " + file + " from xml type " + type + " resource ID #0x" + Integer.toHexString(id));
            rnf.initCause(e);
            throw rnf;
        }
    }
    throw new NotFoundException("File " + file + " from xml type " + type + " resource ID #0x" + Integer.toHexString(id));
}
Also used : NotFoundException(android.content.res.Resources.NotFoundException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) NotFoundException(android.content.res.Resources.NotFoundException) NonNull(android.annotation.NonNull)

Example 80 with NonNull

use of android.annotation.NonNull in project android_frameworks_base by AOSPA.

the class ResourcesImpl method getQuantityText.

@NonNull
CharSequence getQuantityText(@PluralsRes int id, int quantity) throws NotFoundException {
    PluralRules rule = getPluralRule();
    CharSequence res = mAssets.getResourceBagText(id, attrForQuantityCode(rule.select(quantity)));
    if (res != null) {
        return res;
    }
    res = mAssets.getResourceBagText(id, ID_OTHER);
    if (res != null) {
        return res;
    }
    throw new NotFoundException("Plural resource ID #0x" + Integer.toHexString(id) + " quantity=" + quantity + " item=" + rule.select(quantity));
}
Also used : PluralRules(android.icu.text.PluralRules) NotFoundException(android.content.res.Resources.NotFoundException) 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