Fix UI module API nullability annotations and make non-null-by-default.

PiperOrigin-RevId: 261872025
This commit is contained in:
tonihei 2019-08-06 10:34:15 +01:00 committed by Toni
parent 346f8e670a
commit 591bd6e46a
4 changed files with 59 additions and 12 deletions

View file

@ -285,7 +285,7 @@ public class PlayerControlView extends FrameLayout {
}
public PlayerControlView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
this(context, attrs, /* defStyleAttr= */ 0);
}
public PlayerControlView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
@ -494,9 +494,10 @@ public class PlayerControlView extends FrameLayout {
/**
* Sets the {@link VisibilityListener}.
*
* @param listener The listener to be notified about visibility changes.
* @param listener The listener to be notified about visibility changes, or null to remove the
* current listener.
*/
public void setVisibilityListener(VisibilityListener listener) {
public void setVisibilityListener(@Nullable VisibilityListener listener) {
this.visibilityListener = listener;
}
@ -512,7 +513,8 @@ public class PlayerControlView extends FrameLayout {
/**
* Sets the {@link PlaybackPreparer}.
*
* @param playbackPreparer The {@link PlaybackPreparer}.
* @param playbackPreparer The {@link PlaybackPreparer}, or null to remove the current playback
* preparer.
*/
public void setPlaybackPreparer(@Nullable PlaybackPreparer playbackPreparer) {
this.playbackPreparer = playbackPreparer;

View file

@ -308,14 +308,14 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
private static final int PICTURE_TYPE_NOT_SET = -1;
public PlayerView(Context context) {
this(context, null);
this(context, /* attrs= */ null);
}
public PlayerView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
public PlayerView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, /* defStyleAttr= */ 0);
}
public PlayerView(Context context, AttributeSet attrs, int defStyleAttr) {
public PlayerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
if (isInEditMode()) {
@ -505,6 +505,7 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
}
/** Returns the player currently set on this view, or null if no player is set. */
@Nullable
public Player getPlayer() {
return player;
}
@ -904,9 +905,11 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
/**
* Set the {@link PlayerControlView.VisibilityListener}.
*
* @param listener The listener to be notified about visibility changes.
* @param listener The listener to be notified about visibility changes, or null to remove the
* current listener.
*/
public void setControllerVisibilityListener(PlayerControlView.VisibilityListener listener) {
public void setControllerVisibilityListener(
@Nullable PlayerControlView.VisibilityListener listener) {
Assertions.checkState(controller != null);
controller.setVisibilityListener(listener);
}
@ -914,7 +917,8 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
/**
* Sets the {@link PlaybackPreparer}.
*
* @param playbackPreparer The {@link PlaybackPreparer}.
* @param playbackPreparer The {@link PlaybackPreparer}, or null to remove the current playback
* preparer.
*/
public void setPlaybackPreparer(@Nullable PlaybackPreparer playbackPreparer) {
Assertions.checkState(controller != null);
@ -1006,7 +1010,8 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
* @param listener The listener to be notified about aspect ratios changes of the video content or
* the content frame.
*/
public void setAspectRatioListener(AspectRatioFrameLayout.AspectRatioListener listener) {
public void setAspectRatioListener(
@Nullable AspectRatioFrameLayout.AspectRatioListener listener) {
Assertions.checkState(contentFrame != null);
contentFrame.setAspectRatioListener(listener);
}
@ -1025,6 +1030,7 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
* @return The {@link SurfaceView}, {@link TextureView}, {@link SphericalSurfaceView} or {@code
* null}.
*/
@Nullable
public View getVideoSurfaceView() {
return surfaceView;
}
@ -1047,6 +1053,7 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
* @return The {@link SubtitleView}, or {@code null} if the layout has been customized and the
* subtitle view is not present.
*/
@Nullable
public SubtitleView getSubtitleView() {
return subtitleView;
}

View file

@ -0,0 +1,19 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2.ui;
import com.google.android.exoplayer2.util.NonNullApi;

View file

@ -0,0 +1,19 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2.ui.spherical;
import com.google.android.exoplayer2.util.NonNullApi;