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