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;
}
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;
}
}
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);
}
}
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;
}
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);
}
Aggregations