Search in sources :

Example 96 with Nullable

use of android.annotation.Nullable in project android_frameworks_base by crdroidandroid.

the class CascadingMenuPopup method findParentViewForSubmenu.

/**
     * Attempts to find the view for the menu item that owns the specified
     * submenu.
     *
     * @param parentInfo info for the parent menu
     * @param submenu the submenu whose parent view should be obtained
     * @return the parent view, or {@code null} if one could not be found
     */
@Nullable
private View findParentViewForSubmenu(@NonNull CascadingMenuInfo parentInfo, @NonNull MenuBuilder submenu) {
    final MenuItem owner = findMenuItemForSubmenu(parentInfo.menu, submenu);
    if (owner == null) {
        // Couldn't find the submenu owner.
        return null;
    }
    // The adapter may be wrapped. Adjust the index if necessary.
    final int headersCount;
    final MenuAdapter menuAdapter;
    final ListView listView = parentInfo.getListView();
    final ListAdapter listAdapter = listView.getAdapter();
    if (listAdapter instanceof HeaderViewListAdapter) {
        final HeaderViewListAdapter headerAdapter = (HeaderViewListAdapter) listAdapter;
        headersCount = headerAdapter.getHeadersCount();
        menuAdapter = (MenuAdapter) headerAdapter.getWrappedAdapter();
    } else {
        headersCount = 0;
        menuAdapter = (MenuAdapter) listAdapter;
    }
    // Find the index within the menu adapter's data set of the menu item.
    int ownerPosition = AbsListView.INVALID_POSITION;
    for (int i = 0, count = menuAdapter.getCount(); i < count; i++) {
        if (owner == menuAdapter.getItem(i)) {
            ownerPosition = i;
            break;
        }
    }
    if (ownerPosition == AbsListView.INVALID_POSITION) {
        // Couldn't find the owner within the menu adapter.
        return null;
    }
    // Adjust the index for the adapter used to display views.
    ownerPosition += headersCount;
    // Adjust the index for the visible views.
    final int ownerViewPosition = ownerPosition - listView.getFirstVisiblePosition();
    if (ownerViewPosition < 0 || ownerViewPosition >= listView.getChildCount()) {
        // Not visible on screen.
        return null;
    }
    return listView.getChildAt(ownerViewPosition);
}
Also used : AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) HeaderViewListAdapter(android.widget.HeaderViewListAdapter) MenuItem(android.view.MenuItem) HeaderViewListAdapter(android.widget.HeaderViewListAdapter) ListAdapter(android.widget.ListAdapter) Nullable(android.annotation.Nullable)

Example 97 with Nullable

use of android.annotation.Nullable in project android_frameworks_base by crdroidandroid.

the class MediaCodec method getInputBuffer.

/**
     * Returns a {@link java.nio.Buffer#clear cleared}, writable ByteBuffer
     * object for a dequeued input buffer index to contain the input data.
     *
     * After calling this method any ByteBuffer or Image object
     * previously returned for the same input index MUST no longer
     * be used.
     *
     * @param index The index of a client-owned input buffer previously
     *              returned from a call to {@link #dequeueInputBuffer},
     *              or received via an onInputBufferAvailable callback.
     *
     * @return the input buffer, or null if the index is not a dequeued
     * input buffer, or if the codec is configured for surface input.
     *
     * @throws IllegalStateException if not in the Executing state.
     * @throws MediaCodec.CodecException upon codec error.
     */
@Nullable
public ByteBuffer getInputBuffer(int index) {
    ByteBuffer newBuffer = getBuffer(true, /* input */
    index);
    synchronized (mBufferLock) {
        invalidateByteBuffer(mCachedInputBuffers, index);
        mDequeuedInputBuffers.put(index, newBuffer);
    }
    return newBuffer;
}
Also used : ByteBuffer(java.nio.ByteBuffer) Nullable(android.annotation.Nullable)

Example 98 with Nullable

use of android.annotation.Nullable in project android_frameworks_base by crdroidandroid.

the class ResourcesManager method findKeyForResourceImplLocked.

/**
     * Find the ResourcesKey that this ResourcesImpl object is associated with.
     * @return the ResourcesKey or null if none was found.
     */
@Nullable
private ResourcesKey findKeyForResourceImplLocked(@NonNull ResourcesImpl resourceImpl) {
    final int refCount = mResourceImpls.size();
    for (int i = 0; i < refCount; i++) {
        WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.valueAt(i);
        ResourcesImpl impl = weakImplRef != null ? weakImplRef.get() : null;
        if (impl != null && resourceImpl == impl) {
            return mResourceImpls.keyAt(i);
        }
    }
    return null;
}
Also used : ResourcesImpl(android.content.res.ResourcesImpl) Nullable(android.annotation.Nullable)

Example 99 with Nullable

use of android.annotation.Nullable in project android_frameworks_base by crdroidandroid.

the class ResourcesManager method createResourcesImpl.

@Nullable
private ResourcesImpl createResourcesImpl(@NonNull ResourcesKey key) {
    final DisplayAdjustments daj = new DisplayAdjustments(key.mOverrideConfiguration);
    daj.setCompatibilityInfo(key.mCompatInfo);
    final AssetManager assets = createAssetManager(key);
    if (assets == null) {
        return null;
    }
    final DisplayMetrics dm = getDisplayMetrics(key.mDisplayId, daj);
    final Configuration config = generateConfig(key, dm);
    final ResourcesImpl impl = new ResourcesImpl(assets, dm, config, daj);
    if (DEBUG) {
        Slog.d(TAG, "- creating impl=" + impl + " with key: " + key);
    }
    return impl;
}
Also used : AssetManager(android.content.res.AssetManager) Configuration(android.content.res.Configuration) DisplayAdjustments(android.view.DisplayAdjustments) ResourcesImpl(android.content.res.ResourcesImpl) DisplayMetrics(android.util.DisplayMetrics) Nullable(android.annotation.Nullable)

Example 100 with Nullable

use of android.annotation.Nullable in project android_frameworks_base by crdroidandroid.

the class ShortcutInfo method getIntent.

/**
     * Returns the intent that is executed when the user selects this shortcut.
     * If setIntents() was used, then return the last intent in the array.
     *
     * <p>Launcher apps <b>cannot</b> see the intent.  If a {@link ShortcutInfo} is
     * obtained via {@link LauncherApps}, then this method will always return null.
     * Launchers can only start a shortcut intent with {@link LauncherApps#startShortcut}.
     *
     * @see Builder#setIntent(Intent)
     */
@Nullable
public Intent getIntent() {
    if (mIntents == null || mIntents.length == 0) {
        return null;
    }
    final int last = mIntents.length - 1;
    final Intent intent = new Intent(mIntents[last]);
    return setIntentExtras(intent, mIntentPersistableExtrases[last]);
}
Also used : Intent(android.content.Intent) Nullable(android.annotation.Nullable)

Aggregations

Nullable (android.annotation.Nullable)313 RemoteException (android.os.RemoteException)40 Intent (android.content.Intent)39 DeadObjectException (android.os.DeadObjectException)35 ICancellationSignal (android.os.ICancellationSignal)35 IOException (java.io.IOException)29 File (java.io.File)26 Resources (android.content.res.Resources)25 FileNotFoundException (java.io.FileNotFoundException)24 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)24 Configuration (android.content.res.Configuration)20 ResourcesImpl (android.content.res.ResourcesImpl)20 Drawable (android.graphics.drawable.Drawable)20 ComponentName (android.content.ComponentName)15 NotFoundException (android.content.res.Resources.NotFoundException)15 Cursor (android.database.Cursor)15 ParcelFileDescriptor (android.os.ParcelFileDescriptor)15 TypedValue (android.util.TypedValue)15 ByteBuffer (java.nio.ByteBuffer)15 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)15