Remove all references to @NonNull
Our package-info.java files are annotated with @NonNullApi which results in everything being non-null by default, so this annotation is never needed. #minor-release PiperOrigin-RevId: 405864737
This commit is contained in:
parent
651985b0ac
commit
9a49a9ccda
@ -27,7 +27,6 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
@ -199,7 +198,6 @@ public class MainActivity extends AppCompatActivity
|
||||
private class MediaQueueListAdapter extends RecyclerView.Adapter<QueueItemViewHolder> {
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public QueueItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
TextView v =
|
||||
(TextView)
|
||||
@ -240,9 +238,7 @@ public class MainActivity extends AppCompatActivity
|
||||
|
||||
@Override
|
||||
public boolean onMove(
|
||||
@NonNull RecyclerView list,
|
||||
RecyclerView.ViewHolder origin,
|
||||
RecyclerView.ViewHolder target) {
|
||||
RecyclerView list, RecyclerView.ViewHolder origin, RecyclerView.ViewHolder target) {
|
||||
int fromPosition = origin.getAdapterPosition();
|
||||
int toPosition = target.getAdapterPosition();
|
||||
if (draggingFromPosition == C.INDEX_UNSET) {
|
||||
@ -266,7 +262,7 @@ public class MainActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearView(@NonNull RecyclerView recyclerView, @NonNull ViewHolder viewHolder) {
|
||||
public void clearView(RecyclerView recyclerView, ViewHolder viewHolder) {
|
||||
super.clearView(recyclerView, viewHolder);
|
||||
if (draggingFromPosition != C.INDEX_UNSET) {
|
||||
QueueItemViewHolder queueItemHolder = (QueueItemViewHolder) viewHolder;
|
||||
@ -306,8 +302,7 @@ public class MainActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
public View getView(int position, @Nullable View convertView, ViewGroup parent) {
|
||||
View view = super.getView(position, convertView, parent);
|
||||
((TextView) view).setText(Util.castNonNull(getItem(position)).mediaMetadata.title);
|
||||
return view;
|
||||
|
@ -18,7 +18,6 @@ package androidx.media3.demo.cast;
|
||||
import android.content.Context;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.media3.cast.CastPlayer;
|
||||
import androidx.media3.cast.SessionAvailabilityListener;
|
||||
import androidx.media3.common.C;
|
||||
@ -226,7 +225,7 @@ import java.util.ArrayList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimelineChanged(@NonNull Timeline timeline, @TimelineChangeReason int reason) {
|
||||
public void onTimelineChanged(Timeline timeline, @TimelineChangeReason int reason) {
|
||||
updateCurrentItemIndex();
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ import android.opengl.GLES20;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.os.Handler;
|
||||
import android.view.Surface;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.Format;
|
||||
@ -290,7 +289,7 @@ public final class VideoProcessingGLSurfaceView extends GLSurfaceView {
|
||||
public void onVideoFrameAboutToBeRendered(
|
||||
long presentationTimeUs,
|
||||
long releaseTimeNs,
|
||||
@NonNull Format format,
|
||||
Format format,
|
||||
@Nullable MediaFormat mediaFormat) {
|
||||
sampleTimestampQueue.add(releaseTimeNs, presentationTimeUs);
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import static androidx.media3.demo.main.DemoUtil.DOWNLOAD_NOTIFICATION_CHANNEL_I
|
||||
|
||||
import android.app.Notification;
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.util.NotificationUtil;
|
||||
import androidx.media3.common.util.Util;
|
||||
@ -48,7 +47,6 @@ public class DemoDownloadService extends DownloadService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
protected DownloadManager getDownloadManager() {
|
||||
// This will only happen once, because getDownloadManager is guaranteed to be called only once
|
||||
// in the life cycle of the process.
|
||||
@ -67,9 +65,8 @@ public class DemoDownloadService extends DownloadService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
protected Notification getForegroundNotification(
|
||||
@NonNull List<Download> downloads, @Requirements.RequirementFlags int notMetRequirements) {
|
||||
List<Download> downloads, @Requirements.RequirementFlags int notMetRequirements) {
|
||||
return DemoUtil.getDownloadNotificationHelper(/* context= */ this)
|
||||
.buildProgressNotification(
|
||||
/* context= */ this,
|
||||
|
@ -23,7 +23,6 @@ import android.content.DialogInterface;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
@ -142,9 +141,7 @@ public class DownloadTracker {
|
||||
|
||||
@Override
|
||||
public void onDownloadChanged(
|
||||
@NonNull DownloadManager downloadManager,
|
||||
@NonNull Download download,
|
||||
@Nullable Exception finalException) {
|
||||
DownloadManager downloadManager, Download download, @Nullable Exception finalException) {
|
||||
downloads.put(download.request.uri, download);
|
||||
for (Listener listener : listeners) {
|
||||
listener.onDownloadsChanged();
|
||||
@ -152,8 +149,7 @@ public class DownloadTracker {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadRemoved(
|
||||
@NonNull DownloadManager downloadManager, @NonNull Download download) {
|
||||
public void onDownloadRemoved(DownloadManager downloadManager, Download download) {
|
||||
downloads.remove(download.request.uri);
|
||||
for (Listener listener : listeners) {
|
||||
listener.onDownloadsChanged();
|
||||
@ -196,7 +192,7 @@ public class DownloadTracker {
|
||||
// DownloadHelper.Callback implementation.
|
||||
|
||||
@Override
|
||||
public void onPrepared(@NonNull DownloadHelper helper) {
|
||||
public void onPrepared(DownloadHelper helper) {
|
||||
@Nullable Format format = getFirstFormatWithDrmInitData(helper);
|
||||
if (format == null) {
|
||||
onDownloadPrepared(helper);
|
||||
@ -231,7 +227,7 @@ public class DownloadTracker {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareError(@NonNull DownloadHelper helper, @NonNull IOException e) {
|
||||
public void onPrepareError(DownloadHelper helper, IOException e) {
|
||||
boolean isLiveContent = e instanceof LiveContentUnsupportedException;
|
||||
int toastStringId =
|
||||
isLiveContent ? R.string.download_live_unsupported : R.string.download_start_error;
|
||||
|
@ -28,7 +28,6 @@ import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.media3.common.AudioAttributes;
|
||||
@ -185,7 +184,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(
|
||||
int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
int requestCode, String[] permissions, int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (grantResults.length == 0) {
|
||||
// Empty results are triggered if a permission is requested while another request was already
|
||||
@ -201,7 +200,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
updateTrackSelectorParameters();
|
||||
updateStartPosition();
|
||||
@ -424,7 +423,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerError(@NonNull PlaybackException error) {
|
||||
public void onPlayerError(PlaybackException error) {
|
||||
if (error.errorCode == PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW) {
|
||||
player.seekToDefaultPosition();
|
||||
player.prepare();
|
||||
@ -454,8 +453,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||
private class PlayerErrorMessageProvider implements ErrorMessageProvider<PlaybackException> {
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public Pair<Integer, String> getErrorMessage(@NonNull PlaybackException e) {
|
||||
public Pair<Integer, String> getErrorMessage(PlaybackException e) {
|
||||
String errorString = getString(R.string.error_generic);
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof DecoderInitializationException) {
|
||||
|
@ -40,7 +40,6 @@ import android.widget.ExpandableListView.OnChildClickListener;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.media3.common.MediaItem;
|
||||
@ -163,7 +162,7 @@ public class SampleChooserActivity extends AppCompatActivity
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(
|
||||
int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
int requestCode, String[] permissions, int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (grantResults.length == 0) {
|
||||
// Empty results are triggered if a permission is requested while another request was already
|
||||
|
@ -24,7 +24,6 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatDialog;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
@ -213,7 +212,6 @@ public final class TrackSelectionDialog extends DialogFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
// We need to own the view to let tab layout work correctly on all API levels. We can't use
|
||||
// AlertDialog because it owns the view itself, so we use AppCompatDialog instead, themed using
|
||||
@ -225,7 +223,7 @@ public final class TrackSelectionDialog extends DialogFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
super.onDismiss(dialog);
|
||||
onDismissListener.onDismiss(dialog);
|
||||
}
|
||||
@ -290,7 +288,6 @@ public final class TrackSelectionDialog extends DialogFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public Fragment getItem(int position) {
|
||||
return tabFragments.valueAt(position);
|
||||
}
|
||||
@ -364,8 +361,7 @@ public final class TrackSelectionDialog extends DialogFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrackSelectionChanged(
|
||||
boolean isDisabled, @NonNull List<SelectionOverride> overrides) {
|
||||
public void onTrackSelectionChanged(boolean isDisabled, List<SelectionOverride> overrides) {
|
||||
this.isDisabled = isDisabled;
|
||||
this.overrides = overrides;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import androidx.media3.common.C;
|
||||
import androidx.media3.common.FlagSet;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import javax.annotation.Nonnull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* A set of listeners.
|
||||
@ -37,7 +37,7 @@ import javax.annotation.Nonnull;
|
||||
* @param <T> The listener type.
|
||||
*/
|
||||
@UnstableApi
|
||||
public final class ListenerSet<T> {
|
||||
public final class ListenerSet<T extends @NonNull Object> {
|
||||
|
||||
/**
|
||||
* An event sent to a listener.
|
||||
@ -234,15 +234,15 @@ public final class ListenerSet<T> {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static final class ListenerHolder<T> {
|
||||
private static final class ListenerHolder<T extends @NonNull Object> {
|
||||
|
||||
@Nonnull public final T listener;
|
||||
public final T listener;
|
||||
|
||||
private FlagSet.Builder flagsBuilder;
|
||||
private boolean needsIterationFinishedEvent;
|
||||
private boolean released;
|
||||
|
||||
public ListenerHolder(@Nonnull T listener) {
|
||||
public ListenerHolder(T listener) {
|
||||
this.listener = listener;
|
||||
this.flagsBuilder = new FlagSet.Builder();
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Pair;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.media3.common.AudioAttributes;
|
||||
@ -1838,7 +1837,7 @@ public final class DefaultAudioSink implements AudioSink {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTearDown(@NonNull AudioTrack track) {
|
||||
public void onTearDown(AudioTrack track) {
|
||||
Assertions.checkState(track == audioTrack);
|
||||
if (listener != null && playing) {
|
||||
// The audio track was destroyed while in use. Thus a new AudioTrack needs to be
|
||||
|
@ -24,7 +24,6 @@ import android.media.MediaFormat;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import androidx.annotation.GuardedBy;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.media3.common.util.Util;
|
||||
@ -207,15 +206,14 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
// Called from the callback thread.
|
||||
|
||||
@Override
|
||||
public void onInputBufferAvailable(@NonNull MediaCodec codec, int index) {
|
||||
public void onInputBufferAvailable(MediaCodec codec, int index) {
|
||||
synchronized (lock) {
|
||||
availableInputBuffers.add(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOutputBufferAvailable(
|
||||
@NonNull MediaCodec codec, int index, @NonNull MediaCodec.BufferInfo info) {
|
||||
public void onOutputBufferAvailable(MediaCodec codec, int index, MediaCodec.BufferInfo info) {
|
||||
synchronized (lock) {
|
||||
if (pendingOutputFormat != null) {
|
||||
addOutputFormat(pendingOutputFormat);
|
||||
@ -227,14 +225,14 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull MediaCodec codec, @NonNull MediaCodec.CodecException e) {
|
||||
public void onError(MediaCodec codec, MediaCodec.CodecException e) {
|
||||
synchronized (lock) {
|
||||
mediaCodecException = e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOutputFormatChanged(@NonNull MediaCodec codec, @NonNull MediaFormat format) {
|
||||
public void onOutputFormatChanged(MediaCodec codec, MediaFormat format) {
|
||||
synchronized (lock) {
|
||||
addOutputFormat(format);
|
||||
pendingOutputFormat = null;
|
||||
|
@ -31,7 +31,6 @@ import android.media.MediaParser;
|
||||
import android.media.MediaParser.OutputConsumer;
|
||||
import android.media.MediaParser.SeekPoint;
|
||||
import android.text.TextUtils;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.media3.common.FileTypes;
|
||||
@ -264,7 +263,7 @@ public final class MediaParserHlsMediaChunkExtractor implements HlsMediaChunkExt
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(@NonNull byte[] buffer, int offset, int readLength) throws IOException {
|
||||
public int read(byte[] buffer, int offset, int readLength) throws IOException {
|
||||
int peekedBytes = extractorInput.peek(buffer, offset, readLength);
|
||||
totalPeekedBytes += peekedBytes;
|
||||
return peekedBytes;
|
||||
|
@ -19,7 +19,6 @@ import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
||||
import static androidx.media3.common.util.Util.postOrRun;
|
||||
|
||||
import androidx.annotation.GuardedBy;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.collection.ArrayMap;
|
||||
import androidx.media3.common.Player;
|
||||
@ -27,6 +26,7 @@ import androidx.media3.session.MediaSession.ControllerInfo;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Manager that holds {@link ControllerInfo} of connected {@link MediaController controllers}.
|
||||
@ -37,7 +37,7 @@ import java.util.Deque;
|
||||
*
|
||||
* <p>This class is thread-safe.
|
||||
*/
|
||||
/* package */ final class ConnectedControllersManager<T> {
|
||||
/* package */ final class ConnectedControllersManager<T extends @NonNull Object> {
|
||||
|
||||
private final Object lock;
|
||||
|
||||
@ -59,7 +59,7 @@ import java.util.Deque;
|
||||
}
|
||||
|
||||
public void addController(
|
||||
@NonNull T controllerKey,
|
||||
T controllerKey,
|
||||
ControllerInfo controllerInfo,
|
||||
SessionCommands sessionCommands,
|
||||
Player.Commands playerCommands) {
|
||||
@ -104,7 +104,7 @@ import java.util.Deque;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void removeController(@NonNull T controllerKey) {
|
||||
public void removeController(T controllerKey) {
|
||||
@Nullable ControllerInfo controllerInfo = getController(controllerKey);
|
||||
if (controllerInfo != null) {
|
||||
removeController(controllerInfo);
|
||||
@ -112,7 +112,7 @@ import java.util.Deque;
|
||||
}
|
||||
|
||||
public void removeController(ControllerInfo controllerInfo) {
|
||||
@Nullable ConnectedControllerRecord<T> record;
|
||||
@Nullable /*Type*/ ConnectedControllerRecord<T> record;
|
||||
synchronized (lock) {
|
||||
record = controllerRecords.remove(controllerInfo);
|
||||
if (record == null) {
|
||||
@ -168,7 +168,7 @@ import java.util.Deque;
|
||||
* disconnected.
|
||||
*/
|
||||
@Nullable
|
||||
public SequencedFutureManager getSequencedFutureManager(@NonNull T controllerKey) {
|
||||
public SequencedFutureManager getSequencedFutureManager(T controllerKey) {
|
||||
@Nullable ConnectedControllerRecord<T> info;
|
||||
synchronized (lock) {
|
||||
@Nullable ControllerInfo controllerInfo = getController(controllerKey);
|
||||
@ -206,7 +206,7 @@ import java.util.Deque;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ControllerInfo getController(@NonNull T controllerKey) {
|
||||
public ControllerInfo getController(T controllerKey) {
|
||||
synchronized (lock) {
|
||||
return controllerInfoMap.get(controllerKey);
|
||||
}
|
||||
@ -236,14 +236,14 @@ import java.util.Deque;
|
||||
|
||||
private static final class ConnectedControllerRecord<T> {
|
||||
|
||||
@NonNull public final T controllerKey;
|
||||
public final T controllerKey;
|
||||
public final SequencedFutureManager sequencedFutureManager;
|
||||
public SessionCommands sessionCommands;
|
||||
public Player.Commands playerCommands;
|
||||
public Deque<Runnable> commandQueue;
|
||||
|
||||
public ConnectedControllerRecord(
|
||||
@NonNull T controllerKey,
|
||||
T controllerKey,
|
||||
SequencedFutureManager sequencedFutureManager,
|
||||
SessionCommands sessionCommands,
|
||||
Player.Commands playerCommands) {
|
||||
|
@ -22,7 +22,6 @@ import android.os.ConditionVariable;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Message;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.util.HandlerWrapper;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
@ -398,7 +397,7 @@ public final class FakeClockTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(@NonNull Message msg) {
|
||||
public boolean handleMessage(Message msg) {
|
||||
messages.add(new MessageData(msg.what, msg.arg1, msg.arg2, msg.obj));
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user