Merge "Add some null checks to slices" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0689312acb
@@ -28,6 +28,7 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.internal.util.Preconditions;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -427,6 +428,7 @@ public final class Slice implements Parcelable {
|
||||
* @see {@link SliceItem#getSubType()}
|
||||
*/
|
||||
public Builder addSubSlice(@NonNull Slice slice, @Nullable @SliceSubtype String subType) {
|
||||
Preconditions.checkNotNull(slice);
|
||||
mItems.add(new SliceItem(slice, SliceItem.FORMAT_SLICE, subType,
|
||||
slice.getHints().toArray(new String[slice.getHints().size()])));
|
||||
return this;
|
||||
@@ -439,6 +441,8 @@ public final class Slice implements Parcelable {
|
||||
*/
|
||||
public Slice.Builder addAction(@NonNull PendingIntent action, @NonNull Slice s,
|
||||
@Nullable @SliceSubtype String subType) {
|
||||
Preconditions.checkNotNull(action);
|
||||
Preconditions.checkNotNull(s);
|
||||
List<String> hints = s.getHints();
|
||||
s.mSpec = null;
|
||||
mItems.add(new SliceItem(action, s, SliceItem.FORMAT_ACTION, subType, hints.toArray(
|
||||
@@ -464,6 +468,7 @@ public final class Slice implements Parcelable {
|
||||
*/
|
||||
public Builder addIcon(Icon icon, @Nullable @SliceSubtype String subType,
|
||||
@SliceHint List<String> hints) {
|
||||
Preconditions.checkNotNull(icon);
|
||||
mItems.add(new SliceItem(icon, SliceItem.FORMAT_IMAGE, subType, hints));
|
||||
return this;
|
||||
}
|
||||
@@ -476,6 +481,7 @@ public final class Slice implements Parcelable {
|
||||
public Slice.Builder addRemoteInput(RemoteInput remoteInput,
|
||||
@Nullable @SliceSubtype String subType,
|
||||
@SliceHint List<String> hints) {
|
||||
Preconditions.checkNotNull(remoteInput);
|
||||
mItems.add(new SliceItem(remoteInput, SliceItem.FORMAT_REMOTE_INPUT,
|
||||
subType, hints));
|
||||
return this;
|
||||
@@ -523,6 +529,7 @@ public final class Slice implements Parcelable {
|
||||
*/
|
||||
public Slice.Builder addBundle(Bundle bundle, @Nullable @SliceSubtype String subType,
|
||||
@SliceHint List<String> hints) {
|
||||
Preconditions.checkNotNull(bundle);
|
||||
mItems.add(new SliceItem(bundle, SliceItem.FORMAT_BUNDLE, subType,
|
||||
hints));
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user