Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
54c92080
authored
Aug 18, 2020
by
ibaker
Committed by
Oliver Woodman
Aug 21, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix nullness warnings in testutil package
PiperOrigin-RevId: 327190676
parent
99d245f7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeAdaptiveMediaPeriod.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSource.java
library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
View file @
54c92080
...
...
@@ -406,6 +406,21 @@ public final class Util {
}
/**
* Copies the contents of {@code list} into {@code array}.
*
* <p>{@code list.size()} must be the same as {@code array.length} to ensure the contents can be
* copied into {@code array} without leaving any nulls at the end.
*
* @param list The list to copy items from.
* @param array The array to copy items to.
*/
@SuppressWarnings
(
"nullness:toArray.nullable.elements.not.newarray"
)
public
static
<
T
>
void
nullSafeListToArray
(
List
<
T
>
list
,
T
[]
array
)
{
Assertions
.
checkState
(
list
.
size
()
==
array
.
length
);
list
.
toArray
(
array
);
}
/**
* Creates a {@link Handler} on the current {@link Looper} thread.
*
* @throws IllegalStateException If the current thread doesn't have a {@link Looper}.
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeAdaptiveMediaPeriod.java
View file @
54c92080
...
...
@@ -31,6 +31,7 @@ import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
import
com.google.android.exoplayer2.upstream.TransferListener
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.Util
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.checkerframework.checker.nullness.compatqual.NullableType
;
...
...
@@ -48,7 +49,7 @@ public class FakeAdaptiveMediaPeriod extends FakeMediaPeriod
@Nullable
private
final
TransferListener
transferListener
;
private
final
long
durationUs
;
@MonotonicNonNull
private
Callback
callback
;
private
@MonotonicNonNull
Callback
callback
;
private
ChunkSampleStream
<
FakeChunkSource
>[]
sampleStreams
;
private
SequenceableLoader
sequenceableLoader
;
...
...
@@ -99,7 +100,7 @@ public class FakeAdaptiveMediaPeriod extends FakeMediaPeriod
}
}
sampleStreams
=
newSampleStreamArray
(
validStreams
.
size
());
validStreams
.
toArray
(
sampleStreams
);
Util
.
nullSafeListToArray
(
validStreams
,
sampleStreams
);
this
.
sequenceableLoader
=
new
CompositeSequenceableLoader
(
sampleStreams
);
return
returnPositionUs
;
}
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSource.java
View file @
54c92080
...
...
@@ -217,8 +217,7 @@ public class FakeDataSource extends BaseDataSource {
* this method.
*/
public
final
DataSpec
[]
getAndClearOpenedDataSpecs
()
{
DataSpec
[]
dataSpecs
=
new
DataSpec
[
openedDataSpecs
.
size
()];
openedDataSpecs
.
toArray
(
dataSpecs
);
DataSpec
[]
dataSpecs
=
openedDataSpecs
.
toArray
(
new
DataSpec
[
0
]);
openedDataSpecs
.
clear
();
return
dataSpecs
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment