Search in sources :

Example 16 with Nullable

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

the class ShortcutInfo method getIntents.

/**
     * Return the intent set with {@link Builder#setIntents(Intent[])}.
     *
     * <p>Launcher apps <b>cannot</b> see the intents.  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#setIntents(Intent[])
     */
@Nullable
public Intent[] getIntents() {
    final Intent[] ret = new Intent[mIntents.length];
    for (int i = 0; i < ret.length; i++) {
        ret[i] = new Intent(mIntents[i]);
        setIntentExtras(ret[i], mIntentPersistableExtrases[i]);
    }
    return ret;
}
Also used : Intent(android.content.Intent) Nullable(android.annotation.Nullable)

Example 17 with Nullable

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

the class Activity method getParentActivityIntent.

/**
     * Obtain an {@link Intent} that will launch an explicit target activity specified by
     * this activity's logical parent. The logical parent is named in the application's manifest
     * by the {@link android.R.attr#parentActivityName parentActivityName} attribute.
     * Activity subclasses may override this method to modify the Intent returned by
     * super.getParentActivityIntent() or to implement a different mechanism of retrieving
     * the parent intent entirely.
     *
     * @return a new Intent targeting the defined parent of this activity or null if
     *         there is no valid parent.
     */
@Nullable
public Intent getParentActivityIntent() {
    final String parentName = mActivityInfo.parentActivityName;
    if (TextUtils.isEmpty(parentName)) {
        return null;
    }
    // If the parent itself has no parent, generate a main activity intent.
    final ComponentName target = new ComponentName(this, parentName);
    try {
        final ActivityInfo parentInfo = getPackageManager().getActivityInfo(target, 0);
        final String parentActivity = parentInfo.parentActivityName;
        final Intent parentIntent = parentActivity == null ? Intent.makeMainActivity(target) : new Intent().setComponent(target);
        return parentIntent;
    } catch (NameNotFoundException e) {
        Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName + "' in manifest");
        return null;
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ComponentName(android.content.ComponentName) Intent(android.content.Intent) Nullable(android.annotation.Nullable)

Example 18 with Nullable

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

the class Resources method getColorStateList.

/**
     * Returns a themed color state list associated with a particular resource
     * ID. The resource may contain either a single raw color value or a
     * complex {@link ColorStateList} holding multiple possible colors.
     *
     * @param id The desired resource identifier of a {@link ColorStateList},
     *           as generated by the aapt tool. This integer encodes the
     *           package, type, and resource entry. The value 0 is an invalid
     *           identifier.
     * @param theme The theme used to style the color attributes, may be
     *              {@code null}.
     *
     * @throws NotFoundException Throws NotFoundException if the given ID does
     *         not exist.
     *
     * @return A themed ColorStateList object containing either a single solid
     *         color or multiple colors that can be selected based on a state.
     */
@Nullable
public ColorStateList getColorStateList(@ColorRes int id, @Nullable Theme theme) throws NotFoundException {
    final TypedValue value = obtainTempTypedValue();
    try {
        final ResourcesImpl impl = mResourcesImpl;
        impl.getValue(id, value, true);
        return impl.loadColorStateList(this, value, id, theme);
    } finally {
        releaseTempTypedValue(value);
    }
}
Also used : TypedValue(android.util.TypedValue) Nullable(android.annotation.Nullable)

Example 19 with Nullable

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

the class ProgressBar method getTintTarget.

/**
     * Returns the drawable to which a tint or tint mode should be applied.
     *
     * @param layerId id of the layer to modify
     * @param shouldFallback whether the base drawable should be returned
     *                       if the id does not exist
     * @return the drawable to modify
     */
@Nullable
private Drawable getTintTarget(int layerId, boolean shouldFallback) {
    Drawable layer = null;
    final Drawable d = mProgressDrawable;
    if (d != null) {
        mProgressDrawable = d.mutate();
        if (d instanceof LayerDrawable) {
            layer = ((LayerDrawable) d).findDrawableByLayerId(layerId);
        }
        if (shouldFallback && layer == null) {
            layer = d;
        }
    }
    return layer;
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) AnimationDrawable(android.graphics.drawable.AnimationDrawable) Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable) ClipDrawable(android.graphics.drawable.ClipDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Nullable(android.annotation.Nullable)

Example 20 with Nullable

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

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)

Aggregations

Nullable (android.annotation.Nullable)368 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 FileNotFoundException (java.io.FileNotFoundException)28 File (java.io.File)26 Resources (android.content.res.Resources)25 Implementation (org.robolectric.annotation.Implementation)25 CppAssetManager2 (org.robolectric.res.android.CppAssetManager2)24 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)24 Configuration (android.content.res.Configuration)22 ResourcesImpl (android.content.res.ResourcesImpl)20 Drawable (android.graphics.drawable.Drawable)20 TypedArray (android.content.res.TypedArray)17 ByteBuffer (java.nio.ByteBuffer)16 ComponentName (android.content.ComponentName)15 ResolveInfo (android.content.pm.ResolveInfo)15 NotFoundException (android.content.res.Resources.NotFoundException)15