mirror of
https://github.com/androidx/media.git
synced 2025-05-03 21:57:46 +08:00
Fix SubtitleView.ViewType IntDef
PiperOrigin-RevId: 300067502
This commit is contained in:
parent
a5f0eb1e10
commit
b83041a6f5
@ -80,9 +80,9 @@ public final class SubtitleView extends ViewGroup implements TextOutput {
|
|||||||
* <li>{@link #VIEW_TYPE_WEB}
|
* <li>{@link #VIEW_TYPE_WEB}
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
@IntDef
|
|
||||||
@Documented
|
@Documented
|
||||||
@Retention(SOURCE)
|
@Retention(SOURCE)
|
||||||
|
@IntDef({VIEW_TYPE_TEXT, VIEW_TYPE_WEB})
|
||||||
public @interface ViewType {}
|
public @interface ViewType {}
|
||||||
|
|
||||||
private @ViewType int viewType;
|
private @ViewType int viewType;
|
||||||
@ -128,19 +128,24 @@ public final class SubtitleView extends ViewGroup implements TextOutput {
|
|||||||
*
|
*
|
||||||
* <p>NOTE: {@link #VIEW_TYPE_WEB} is currently very experimental, and doesn't support most
|
* <p>NOTE: {@link #VIEW_TYPE_WEB} is currently very experimental, and doesn't support most
|
||||||
* styling and layout properties of {@link Cue}.
|
* styling and layout properties of {@link Cue}.
|
||||||
|
*
|
||||||
|
* @param viewType The {@link ViewType} to use.
|
||||||
*/
|
*/
|
||||||
public void setViewType(@ViewType int newViewType) {
|
public void setViewType(@ViewType int viewType) {
|
||||||
if (viewType == newViewType) {
|
if (this.viewType == viewType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (newViewType == VIEW_TYPE_TEXT) {
|
switch (viewType) {
|
||||||
|
case VIEW_TYPE_TEXT:
|
||||||
setView(new SubtitleTextView(getContext()));
|
setView(new SubtitleTextView(getContext()));
|
||||||
} else if (newViewType == VIEW_TYPE_WEB) {
|
break;
|
||||||
|
case VIEW_TYPE_WEB:
|
||||||
setView(new SubtitleWebView(getContext()));
|
setView(new SubtitleWebView(getContext()));
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
viewType = newViewType;
|
this.viewType = viewType;
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T extends View & Output> void setView(T view) {
|
private <T extends View & Output> void setView(T view) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user