mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Change nested ternary to switch in SubtitlePainter
The nested ternary is quite hard to read imo, and I believe this is a no-op change that captures the intent more clearly. PiperOrigin-RevId: 277320461
This commit is contained in:
parent
a3d1ab6900
commit
e922f83401
@ -304,9 +304,19 @@ import com.google.android.exoplayer2.util.Util;
|
||||
int textRight;
|
||||
if (cuePosition != Cue.DIMEN_UNSET) {
|
||||
int anchorPosition = Math.round(parentWidth * cuePosition) + parentLeft;
|
||||
textLeft = cuePositionAnchor == Cue.ANCHOR_TYPE_END ? anchorPosition - textWidth
|
||||
: cuePositionAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorPosition * 2 - textWidth) / 2
|
||||
: anchorPosition;
|
||||
switch (cuePositionAnchor) {
|
||||
case Cue.ANCHOR_TYPE_END:
|
||||
textLeft = anchorPosition - textWidth;
|
||||
break;
|
||||
case Cue.ANCHOR_TYPE_MIDDLE:
|
||||
textLeft = (anchorPosition * 2 - textWidth) / 2;
|
||||
break;
|
||||
case Cue.ANCHOR_TYPE_START:
|
||||
case Cue.TYPE_UNSET:
|
||||
default:
|
||||
textLeft = anchorPosition;
|
||||
}
|
||||
|
||||
textLeft = Math.max(textLeft, parentLeft);
|
||||
textRight = Math.min(textLeft + textWidth, parentRight);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user