mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Defensively copy potentially mutable text in Cue constructor
Without this the Cue isn't deeply immutable, which can be a bit surprising. PiperOrigin-RevId: 375477571
This commit is contained in:
parent
b87a4c04e0
commit
55f50e24eb
1 changed files with 9 additions and 1 deletions
|
|
@ -19,6 +19,8 @@ import android.graphics.Bitmap;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.text.Layout;
|
import android.text.Layout;
|
||||||
import android.text.Layout.Alignment;
|
import android.text.Layout.Alignment;
|
||||||
|
import android.text.Spanned;
|
||||||
|
import android.text.SpannedString;
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
@ -458,7 +460,13 @@ public final class Cue {
|
||||||
} else {
|
} else {
|
||||||
Assertions.checkArgument(bitmap == null);
|
Assertions.checkArgument(bitmap == null);
|
||||||
}
|
}
|
||||||
this.text = text;
|
if (text instanceof Spanned) {
|
||||||
|
this.text = SpannedString.valueOf(text);
|
||||||
|
} else if (text != null) {
|
||||||
|
this.text = text.toString();
|
||||||
|
} else {
|
||||||
|
this.text = null;
|
||||||
|
}
|
||||||
this.textAlignment = textAlignment;
|
this.textAlignment = textAlignment;
|
||||||
this.multiRowAlignment = multiRowAlignment;
|
this.multiRowAlignment = multiRowAlignment;
|
||||||
this.bitmap = bitmap;
|
this.bitmap = bitmap;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue