Merge "Nullability annotations for animation and graphics"

This commit is contained in:
Alan Viverette
2022-02-04 19:34:22 +00:00
committed by Android (Google) Code Review
9 changed files with 91 additions and 102 deletions

View File

@@ -3597,17 +3597,17 @@ package android.animation {
}
public static interface Animator.AnimatorListener {
method public void onAnimationCancel(android.animation.Animator);
method public default void onAnimationEnd(android.animation.Animator, boolean);
method public void onAnimationEnd(android.animation.Animator);
method public void onAnimationRepeat(android.animation.Animator);
method public default void onAnimationStart(android.animation.Animator, boolean);
method public void onAnimationStart(android.animation.Animator);
method public void onAnimationCancel(@NonNull android.animation.Animator);
method public default void onAnimationEnd(@NonNull android.animation.Animator, boolean);
method public void onAnimationEnd(@NonNull android.animation.Animator);
method public void onAnimationRepeat(@NonNull android.animation.Animator);
method public default void onAnimationStart(@NonNull android.animation.Animator, boolean);
method public void onAnimationStart(@NonNull android.animation.Animator);
}
public static interface Animator.AnimatorPauseListener {
method public void onAnimationPause(android.animation.Animator);
method public void onAnimationResume(android.animation.Animator);
method public void onAnimationPause(@NonNull android.animation.Animator);
method public void onAnimationResume(@NonNull android.animation.Animator);
}
public class AnimatorInflater {
@@ -3894,7 +3894,7 @@ package android.animation {
}
public static interface ValueAnimator.AnimatorUpdateListener {
method public void onAnimationUpdate(android.animation.ValueAnimator);
method public void onAnimationUpdate(@NonNull android.animation.ValueAnimator);
}
}
@@ -15773,9 +15773,9 @@ package android.graphics.drawable {
method public final void copyBounds(@NonNull android.graphics.Rect);
method @NonNull public final android.graphics.Rect copyBounds();
method @Nullable public static android.graphics.drawable.Drawable createFromPath(String);
method public static android.graphics.drawable.Drawable createFromResourceStream(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, String);
method @Nullable public static android.graphics.drawable.Drawable createFromResourceStream(@Nullable android.content.res.Resources, @Nullable android.util.TypedValue, @Nullable java.io.InputStream, @Nullable String);
method @Deprecated @Nullable public static android.graphics.drawable.Drawable createFromResourceStream(@Nullable android.content.res.Resources, @Nullable android.util.TypedValue, @Nullable java.io.InputStream, @Nullable String, @Nullable android.graphics.BitmapFactory.Options);
method public static android.graphics.drawable.Drawable createFromStream(java.io.InputStream, String);
method @Nullable public static android.graphics.drawable.Drawable createFromStream(@Nullable java.io.InputStream, @Nullable String);
method @NonNull public static android.graphics.drawable.Drawable createFromXml(@NonNull android.content.res.Resources, @NonNull org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
method @NonNull public static android.graphics.drawable.Drawable createFromXml(@NonNull android.content.res.Resources, @NonNull org.xmlpull.v1.XmlPullParser, @Nullable android.content.res.Resources.Theme) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
method @NonNull public static android.graphics.drawable.Drawable createFromXmlInner(@NonNull android.content.res.Resources, @NonNull org.xmlpull.v1.XmlPullParser, @NonNull android.util.AttributeSet) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
@@ -15813,10 +15813,10 @@ package android.graphics.drawable {
method public final boolean isVisible();
method public void jumpToCurrentState();
method @NonNull public android.graphics.drawable.Drawable mutate();
method protected void onBoundsChange(android.graphics.Rect);
method protected void onBoundsChange(@NonNull android.graphics.Rect);
method public boolean onLayoutDirectionChanged(int);
method protected boolean onLevelChange(int);
method protected boolean onStateChange(int[]);
method protected boolean onStateChange(@NonNull int[]);
method public static int resolveOpacity(int, int);
method public void scheduleSelf(@NonNull Runnable, long);
method public abstract void setAlpha(@IntRange(from=0, to=255) int);
@@ -15977,27 +15977,27 @@ package android.graphics.drawable {
}
public final class Icon implements android.os.Parcelable {
method public static android.graphics.drawable.Icon createWithAdaptiveBitmap(android.graphics.Bitmap);
method @NonNull public static android.graphics.drawable.Icon createWithAdaptiveBitmap(android.graphics.Bitmap);
method @NonNull public static android.graphics.drawable.Icon createWithAdaptiveBitmapContentUri(@NonNull String);
method @NonNull public static android.graphics.drawable.Icon createWithAdaptiveBitmapContentUri(@NonNull android.net.Uri);
method public static android.graphics.drawable.Icon createWithBitmap(android.graphics.Bitmap);
method public static android.graphics.drawable.Icon createWithContentUri(String);
method public static android.graphics.drawable.Icon createWithContentUri(android.net.Uri);
method public static android.graphics.drawable.Icon createWithData(byte[], int, int);
method public static android.graphics.drawable.Icon createWithFilePath(String);
method public static android.graphics.drawable.Icon createWithResource(android.content.Context, @DrawableRes int);
method public static android.graphics.drawable.Icon createWithResource(String, @DrawableRes int);
method @NonNull public static android.graphics.drawable.Icon createWithBitmap(android.graphics.Bitmap);
method @NonNull public static android.graphics.drawable.Icon createWithContentUri(String);
method @NonNull public static android.graphics.drawable.Icon createWithContentUri(android.net.Uri);
method @NonNull public static android.graphics.drawable.Icon createWithData(byte[], int, int);
method @NonNull public static android.graphics.drawable.Icon createWithFilePath(String);
method @NonNull public static android.graphics.drawable.Icon createWithResource(android.content.Context, @DrawableRes int);
method @NonNull public static android.graphics.drawable.Icon createWithResource(String, @DrawableRes int);
method public int describeContents();
method @DrawableRes public int getResId();
method @NonNull public String getResPackage();
method public int getType();
method @NonNull public android.net.Uri getUri();
method public android.graphics.drawable.Drawable loadDrawable(android.content.Context);
method public void loadDrawableAsync(android.content.Context, android.os.Message);
method public void loadDrawableAsync(android.content.Context, android.graphics.drawable.Icon.OnDrawableLoadedListener, android.os.Handler);
method public android.graphics.drawable.Icon setTint(@ColorInt int);
method @Nullable public android.graphics.drawable.Drawable loadDrawable(android.content.Context);
method public void loadDrawableAsync(@NonNull android.content.Context, @NonNull android.os.Message);
method public void loadDrawableAsync(@NonNull android.content.Context, android.graphics.drawable.Icon.OnDrawableLoadedListener, android.os.Handler);
method @NonNull public android.graphics.drawable.Icon setTint(@ColorInt int);
method @NonNull public android.graphics.drawable.Icon setTintBlendMode(@NonNull android.graphics.BlendMode);
method public android.graphics.drawable.Icon setTintList(android.content.res.ColorStateList);
method @NonNull public android.graphics.drawable.Icon setTintList(android.content.res.ColorStateList);
method @NonNull public android.graphics.drawable.Icon setTintMode(@NonNull android.graphics.PorterDuff.Mode);
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.graphics.drawable.Icon> CREATOR;

View File

@@ -987,7 +987,7 @@ package android.database.sqlite {
package android.graphics {
public final class ImageDecoder implements java.lang.AutoCloseable {
method @AnyThread @NonNull public static android.graphics.ImageDecoder.Source createSource(android.content.res.Resources, java.io.InputStream, int);
method @AnyThread @NonNull public static android.graphics.ImageDecoder.Source createSource(android.content.res.Resources, @NonNull java.io.InputStream, int);
}
public final class Rect implements android.os.Parcelable {

View File

@@ -16,6 +16,7 @@
package android.animation;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.pm.ActivityInfo.Config;
@@ -535,7 +536,7 @@ public abstract class Animator implements Cloneable {
* @param animation The started animation.
* @param isReverse Whether the animation is playing in reverse.
*/
default void onAnimationStart(Animator animation, boolean isReverse) {
default void onAnimationStart(@NonNull Animator animation, boolean isReverse) {
onAnimationStart(animation);
}
@@ -551,7 +552,7 @@ public abstract class Animator implements Cloneable {
* @param animation The animation which reached its end.
* @param isReverse Whether the animation is playing in reverse.
*/
default void onAnimationEnd(Animator animation, boolean isReverse) {
default void onAnimationEnd(@NonNull Animator animation, boolean isReverse) {
onAnimationEnd(animation);
}
@@ -560,7 +561,7 @@ public abstract class Animator implements Cloneable {
*
* @param animation The started animation.
*/
void onAnimationStart(Animator animation);
void onAnimationStart(@NonNull Animator animation);
/**
* <p>Notifies the end of the animation. This callback is not invoked
@@ -568,7 +569,7 @@ public abstract class Animator implements Cloneable {
*
* @param animation The animation which reached its end.
*/
void onAnimationEnd(Animator animation);
void onAnimationEnd(@NonNull Animator animation);
/**
* <p>Notifies the cancellation of the animation. This callback is not invoked
@@ -576,14 +577,14 @@ public abstract class Animator implements Cloneable {
*
* @param animation The animation which was canceled.
*/
void onAnimationCancel(Animator animation);
void onAnimationCancel(@NonNull Animator animation);
/**
* <p>Notifies the repetition of the animation.</p>
*
* @param animation The animation which was repeated.
*/
void onAnimationRepeat(Animator animation);
void onAnimationRepeat(@NonNull Animator animation);
}
/**
@@ -599,7 +600,7 @@ public abstract class Animator implements Cloneable {
* @param animation The animaton being paused.
* @see #pause()
*/
void onAnimationPause(Animator animation);
void onAnimationPause(@NonNull Animator animation);
/**
* <p>Notifies that the animation was resumed, after being
@@ -608,7 +609,7 @@ public abstract class Animator implements Cloneable {
* @param animation The animation being resumed.
* @see #resume()
*/
void onAnimationResume(Animator animation);
void onAnimationResume(@NonNull Animator animation);
}
/**

View File

@@ -18,6 +18,7 @@ package android.animation;
import android.annotation.CallSuper;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
@@ -1626,7 +1627,7 @@ public class ValueAnimator extends Animator implements AnimationHandler.Animatio
*
* @param animation The animation which was repeated.
*/
void onAnimationUpdate(ValueAnimator animation);
void onAnimationUpdate(@NonNull ValueAnimator animation);
}

View File

@@ -368,7 +368,7 @@ public final class ImageDecoder implements AutoCloseable {
* Further, unlike other Sources, this one is not reusable.
*/
private static class InputStreamSource extends Source {
InputStreamSource(Resources res, InputStream is, int inputDensity) {
InputStreamSource(Resources res, @NonNull InputStream is, int inputDensity) {
if (is == null) {
throw new IllegalArgumentException("The InputStream cannot be null");
}
@@ -1020,7 +1020,7 @@ public final class ImageDecoder implements AutoCloseable {
*/
@AnyThread
@NonNull
public static Source createSource(Resources res, InputStream is) {
public static Source createSource(Resources res, @NonNull InputStream is) {
return new InputStreamSource(res, is, Bitmap.getDefaultDensity());
}
@@ -1034,7 +1034,7 @@ public final class ImageDecoder implements AutoCloseable {
@AnyThread
@TestApi
@NonNull
public static Source createSource(Resources res, InputStream is, int density) {
public static Source createSource(Resources res, @NonNull InputStream is, int density) {
return new InputStreamSource(res, is, density);
}

View File

@@ -288,8 +288,7 @@ public abstract class Drawable {
*
* @return A copy of the drawable's bounds
*/
@NonNull
public final Rect copyBounds() {
public final @NonNull Rect copyBounds() {
return new Rect(mBounds);
}
@@ -308,8 +307,7 @@ public abstract class Drawable {
* @see #copyBounds()
* @see #copyBounds(android.graphics.Rect)
*/
@NonNull
public final Rect getBounds() {
public final @NonNull Rect getBounds() {
if (mBounds == ZERO_BOUNDS_RECT) {
mBounds = new Rect();
}
@@ -327,8 +325,7 @@ public abstract class Drawable {
*
* @return The dirty bounds of this drawable
*/
@NonNull
public Rect getDirtyBounds() {
public @NonNull Rect getDirtyBounds() {
return getBounds();
}
@@ -457,8 +454,7 @@ public abstract class Drawable {
*
* @see #setCallback(android.graphics.drawable.Drawable.Callback)
*/
@Nullable
public Callback getCallback() {
public @Nullable Callback getCallback() {
return mCallback != null ? mCallback.get() : null;
}
@@ -569,8 +565,7 @@ public abstract class Drawable {
* The default return value is 255 if the class does not override this method to return a value
* specific to its use of alpha.
*/
@IntRange(from=0,to=255)
public int getAlpha() {
public @IntRange(from=0,to=255) int getAlpha() {
return 0xFF;
}
@@ -999,7 +994,8 @@ public abstract class Drawable {
*
* @see android.graphics.PixelFormat
*/
@Deprecated public abstract @PixelFormat.Opacity int getOpacity();
@Deprecated
public abstract @PixelFormat.Opacity int getOpacity();
/**
* Return the appropriate opacity value for two source opacities. If
@@ -1059,7 +1055,7 @@ public abstract class Drawable {
* if it looks the same and there is no need to redraw it since its
* last state.
*/
protected boolean onStateChange(int[] state) {
protected boolean onStateChange(@NonNull int[] state) {
return false;
}
@@ -1078,7 +1074,7 @@ public abstract class Drawable {
* Override this in your subclass to change appearance if you vary based on
* the bounds.
*/
protected void onBoundsChange(Rect bounds) {
protected void onBoundsChange(@NonNull Rect bounds) {
// Stub method.
}
@@ -1209,7 +1205,8 @@ public abstract class Drawable {
/**
* Create a drawable from an inputstream
*/
public static Drawable createFromStream(InputStream is, String srcName) {
public static @Nullable Drawable createFromStream(@Nullable InputStream is,
@Nullable String srcName) {
Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, srcName != null ? srcName : "Unknown drawable");
try {
return createFromResourceStream(null, null, is, srcName);
@@ -1222,8 +1219,8 @@ public abstract class Drawable {
* Create a drawable from an inputstream, using the given resources and
* value to determine density information.
*/
public static Drawable createFromResourceStream(Resources res, TypedValue value,
InputStream is, String srcName) {
public static @Nullable Drawable createFromResourceStream(@Nullable Resources res,
@Nullable TypedValue value, @Nullable InputStream is, @Nullable String srcName) {
Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, srcName != null ? srcName : "Unknown drawable");
try {
return createFromResourceStream(res, value, is, srcName, null);
@@ -1238,8 +1235,7 @@ public abstract class Drawable {
*
* @deprecated Prefer the version without an Options object.
*/
@Nullable
public static Drawable createFromResourceStream(@Nullable Resources res,
public static @Nullable Drawable createFromResourceStream(@Nullable Resources res,
@Nullable TypedValue value, @Nullable InputStream is, @Nullable String srcName,
@Nullable BitmapFactory.Options opts) {
if (is == null) {
@@ -1281,7 +1277,8 @@ public abstract class Drawable {
return null;
}
private static Drawable getBitmapDrawable(Resources res, TypedValue value, InputStream is) {
private static Drawable getBitmapDrawable(Resources res, @Nullable TypedValue value,
@NonNull InputStream is) {
try {
ImageDecoder.Source source = null;
if (value != null) {
@@ -1369,9 +1366,9 @@ public abstract class Drawable {
* a tag in an XML document, tries to create a Drawable from that tag.
* Returns null if the tag is not a valid drawable.
*/
@NonNull
public static Drawable createFromXmlInner(@NonNull Resources r, @NonNull XmlPullParser parser,
@NonNull AttributeSet attrs) throws XmlPullParserException, IOException {
public static @NonNull Drawable createFromXmlInner(@NonNull Resources r,
@NonNull XmlPullParser parser, @NonNull AttributeSet attrs)
throws XmlPullParserException, IOException {
return createFromXmlInner(r, parser, attrs, null);
}
@@ -1381,9 +1378,8 @@ public abstract class Drawable {
* document, tries to create a Drawable from that tag. Returns {@code null}
* if the tag is not a valid drawable.
*/
@NonNull
public static Drawable createFromXmlInner(@NonNull Resources r, @NonNull XmlPullParser parser,
@NonNull AttributeSet attrs, @Nullable Theme theme)
public static @NonNull Drawable createFromXmlInner(@NonNull Resources r,
@NonNull XmlPullParser parser, @NonNull AttributeSet attrs, @Nullable Theme theme)
throws XmlPullParserException, IOException {
return createFromXmlInnerForDensity(r, parser, attrs, 0, theme);
}
@@ -1392,8 +1388,7 @@ public abstract class Drawable {
* Version of {@link #createFromXmlInner(Resources, XmlPullParser, AttributeSet, Theme)} that
* accepts an override density.
*/
@NonNull
static Drawable createFromXmlInnerForDensity(@NonNull Resources r,
static @NonNull Drawable createFromXmlInnerForDensity(@NonNull Resources r,
@NonNull XmlPullParser parser, @NonNull AttributeSet attrs, int density,
@Nullable Theme theme) throws XmlPullParserException, IOException {
return r.getDrawableInflater().inflateFromXmlForDensity(parser.getName(), parser, attrs,
@@ -1403,8 +1398,7 @@ public abstract class Drawable {
/**
* Create a drawable from file path name.
*/
@Nullable
public static Drawable createFromPath(String pathName) {
public static @Nullable Drawable createFromPath(String pathName) {
if (pathName == null) {
return null;
}

View File

@@ -61,8 +61,7 @@ public final class DrawableInflater {
* @param id the identifier of the drawable resource
* @return a drawable, or {@code null} if the drawable failed to load
*/
@Nullable
public static Drawable loadDrawable(@NonNull Context context, @DrawableRes int id) {
public static @Nullable Drawable loadDrawable(@NonNull Context context, @DrawableRes int id) {
return loadDrawable(context.getResources(), context.getTheme(), id);
}
@@ -74,9 +73,8 @@ public final class DrawableInflater {
* @param id the identifier of the drawable resource
* @return a drawable, or {@code null} if the drawable failed to load
*/
@Nullable
public static Drawable loadDrawable(
@NonNull Resources resources, @Nullable Theme theme, @DrawableRes int id) {
public static @Nullable Drawable loadDrawable(@NonNull Resources resources,
@Nullable Theme theme, @DrawableRes int id) {
return resources.getDrawable(id, theme);
}
@@ -111,8 +109,7 @@ public final class DrawableInflater {
* @throws XmlPullParserException
* @throws IOException
*/
@NonNull
public Drawable inflateFromXml(@NonNull String name, @NonNull XmlPullParser parser,
public @NonNull Drawable inflateFromXml(@NonNull String name, @NonNull XmlPullParser parser,
@NonNull AttributeSet attrs, @Nullable Theme theme)
throws XmlPullParserException, IOException {
return inflateFromXmlForDensity(name, parser, attrs, 0, theme);
@@ -122,8 +119,7 @@ public final class DrawableInflater {
* Version of {@link #inflateFromXml(String, XmlPullParser, AttributeSet, Theme)} that accepts
* an override density.
*/
@NonNull
Drawable inflateFromXmlForDensity(@NonNull String name, @NonNull XmlPullParser parser,
@NonNull Drawable inflateFromXmlForDensity(@NonNull String name, @NonNull XmlPullParser parser,
@NonNull AttributeSet attrs, int density, @Nullable Theme theme)
throws XmlPullParserException, IOException {
// Inner classes must be referenced as Outer$Inner, but XML tag names
@@ -146,9 +142,8 @@ public final class DrawableInflater {
return drawable;
}
@NonNull
@SuppressWarnings("deprecation")
private Drawable inflateFromTag(@NonNull String name) {
private @Nullable Drawable inflateFromTag(@NonNull String name) {
switch (name) {
case "selector":
return new StateListDrawable();
@@ -195,8 +190,7 @@ public final class DrawableInflater {
}
}
@NonNull
private Drawable inflateFromClass(@NonNull String className) {
private @NonNull Drawable inflateFromClass(@NonNull String className) {
try {
Constructor<? extends Drawable> constructor;
synchronized (CONSTRUCTOR_MAP) {

View File

@@ -352,7 +352,7 @@ public abstract class DrawableWrapper extends Drawable implements Drawable.Callb
}
@Override
protected boolean onStateChange(int[] state) {
protected boolean onStateChange(@NonNull int[] state) {
if (mDrawable != null && mDrawable.isStateful()) {
final boolean changed = mDrawable.setState(state);
if (changed) {

View File

@@ -302,7 +302,7 @@ public final class Icon implements Parcelable {
* is available. The {@link android.os.Message#obj obj}
* property is populated with the Drawable.
*/
public void loadDrawableAsync(Context context, Message andThen) {
public void loadDrawableAsync(@NonNull Context context, @NonNull Message andThen) {
if (andThen.getTarget() == null) {
throw new IllegalArgumentException("callback message must have a target handler");
}
@@ -320,7 +320,7 @@ public final class Icon implements Parcelable {
* {@link #loadDrawable(Context)} finished
* @param handler {@link Handler} on which to notify the {@code listener}
*/
public void loadDrawableAsync(Context context, final OnDrawableLoadedListener listener,
public void loadDrawableAsync(@NonNull Context context, final OnDrawableLoadedListener listener,
Handler handler) {
new LoadDrawableTask(context, handler, listener).runAsync();
}
@@ -335,7 +335,7 @@ public final class Icon implements Parcelable {
* to access {@link android.content.res.Resources Resources}, for example.
* @return A fresh instance of a drawable for this image, yours to keep.
*/
public Drawable loadDrawable(Context context) {
public @Nullable Drawable loadDrawable(Context context) {
final Drawable result = loadDrawableInner(context);
if (result != null && hasTint()) {
result.mutate();
@@ -415,7 +415,7 @@ public final class Icon implements Parcelable {
return null;
}
private InputStream getUriInputStream(Context context) {
private @Nullable InputStream getUriInputStream(Context context) {
final Uri uri = getUri();
final String scheme = uri.getScheme();
if (ContentResolver.SCHEME_CONTENT.equals(scheme)
@@ -496,7 +496,7 @@ public final class Icon implements Parcelable {
* @param stream The stream on which to serialize the Icon.
* @hide
*/
public void writeToStream(OutputStream stream) throws IOException {
public void writeToStream(@NonNull OutputStream stream) throws IOException {
DataOutputStream dataStream = new DataOutputStream(stream);
dataStream.writeInt(VERSION_STREAM_SERIALIZER);
@@ -532,7 +532,7 @@ public final class Icon implements Parcelable {
* @param stream The input stream from which to reconstruct the Icon.
* @hide
*/
public static Icon createFromStream(InputStream stream) throws IOException {
public static @Nullable Icon createFromStream(@NonNull InputStream stream) throws IOException {
DataInputStream inputStream = new DataInputStream(stream);
final int version = inputStream.readInt();
@@ -571,7 +571,7 @@ public final class Icon implements Parcelable {
* @return whether this icon is the same as the another one
* @hide
*/
public boolean sameAs(Icon otherIcon) {
public boolean sameAs(@NonNull Icon otherIcon) {
if (otherIcon == this) {
return true;
}
@@ -602,7 +602,7 @@ public final class Icon implements Parcelable {
* given resource ID.
* @param resId ID of the drawable resource
*/
public static Icon createWithResource(Context context, @DrawableRes int resId) {
public static @NonNull Icon createWithResource(Context context, @DrawableRes int resId) {
if (context == null) {
throw new IllegalArgumentException("Context must not be null.");
}
@@ -617,7 +617,7 @@ public final class Icon implements Parcelable {
* @hide
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static Icon createWithResource(Resources res, @DrawableRes int resId) {
public static @NonNull Icon createWithResource(Resources res, @DrawableRes int resId) {
if (res == null) {
throw new IllegalArgumentException("Resource must not be null.");
}
@@ -632,7 +632,7 @@ public final class Icon implements Parcelable {
* @param resPackage Name of the package containing the resource in question
* @param resId ID of the drawable resource
*/
public static Icon createWithResource(String resPackage, @DrawableRes int resId) {
public static @NonNull Icon createWithResource(String resPackage, @DrawableRes int resId) {
if (resPackage == null) {
throw new IllegalArgumentException("Resource package name must not be null.");
}
@@ -646,7 +646,7 @@ public final class Icon implements Parcelable {
* Create an Icon pointing to a bitmap in memory.
* @param bits A valid {@link android.graphics.Bitmap} object
*/
public static Icon createWithBitmap(Bitmap bits) {
public static @NonNull Icon createWithBitmap(Bitmap bits) {
if (bits == null) {
throw new IllegalArgumentException("Bitmap must not be null.");
}
@@ -660,7 +660,7 @@ public final class Icon implements Parcelable {
* by {@link AdaptiveIconDrawable}.
* @param bits A valid {@link android.graphics.Bitmap} object
*/
public static Icon createWithAdaptiveBitmap(Bitmap bits) {
public static @NonNull Icon createWithAdaptiveBitmap(Bitmap bits) {
if (bits == null) {
throw new IllegalArgumentException("Bitmap must not be null.");
}
@@ -677,7 +677,7 @@ public final class Icon implements Parcelable {
* @param offset Offset into <code>data</code> at which the bitmap data starts
* @param length Length of the bitmap data
*/
public static Icon createWithData(byte[] data, int offset, int length) {
public static @NonNull Icon createWithData(byte[] data, int offset, int length) {
if (data == null) {
throw new IllegalArgumentException("Data must not be null.");
}
@@ -693,7 +693,7 @@ public final class Icon implements Parcelable {
*
* @param uri A uri referring to local content:// or file:// image data.
*/
public static Icon createWithContentUri(String uri) {
public static @NonNull Icon createWithContentUri(String uri) {
if (uri == null) {
throw new IllegalArgumentException("Uri must not be null.");
}
@@ -707,7 +707,7 @@ public final class Icon implements Parcelable {
*
* @param uri A uri referring to local content:// or file:// image data.
*/
public static Icon createWithContentUri(Uri uri) {
public static @NonNull Icon createWithContentUri(Uri uri) {
if (uri == null) {
throw new IllegalArgumentException("Uri must not be null.");
}
@@ -720,8 +720,7 @@ public final class Icon implements Parcelable {
*
* @param uri A uri referring to local content:// or file:// image data.
*/
@NonNull
public static Icon createWithAdaptiveBitmapContentUri(@NonNull String uri) {
public static @NonNull Icon createWithAdaptiveBitmapContentUri(@NonNull String uri) {
if (uri == null) {
throw new IllegalArgumentException("Uri must not be null.");
}
@@ -750,7 +749,7 @@ public final class Icon implements Parcelable {
* @param tint a color, as in {@link Drawable#setTint(int)}
* @return this same object, for use in chained construction
*/
public Icon setTint(@ColorInt int tint) {
public @NonNull Icon setTint(@ColorInt int tint) {
return setTintList(ColorStateList.valueOf(tint));
}
@@ -760,7 +759,7 @@ public final class Icon implements Parcelable {
* @param tintList as in {@link Drawable#setTintList(ColorStateList)}, null to remove tint
* @return this same object, for use in chained construction
*/
public Icon setTintList(ColorStateList tintList) {
public @NonNull Icon setTintList(ColorStateList tintList) {
mTintList = tintList;
return this;
}
@@ -809,7 +808,7 @@ public final class Icon implements Parcelable {
* @param path A path to a file that contains compressed bitmap data of
* a type that {@link android.graphics.BitmapFactory} can decode.
*/
public static Icon createWithFilePath(String path) {
public static @NonNull Icon createWithFilePath(String path) {
if (path == null) {
throw new IllegalArgumentException("Path must not be null.");
}