Skip to content

Commit cb2ed75

Browse files
committed
refactor: mark required SponsorBlock properties as non-null
These values are guaranteed by the API to be always set, so the should be marked as non-null.
1 parent a69a197 commit cb2ed75

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

  • app/src/main/java/com/github/libretube/api/obj

app/src/main/java/com/github/libretube/api/obj/Segment.kt

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,32 @@ import kotlinx.serialization.Transient
1313
@Serializable
1414
@Parcelize
1515
data class Segment(
16-
@SerialName("UUID") val uuid: String? = null,
17-
val actionType: String? = null,
18-
val category: String? = null,
16+
@SerialName("UUID") val uuid: String,
17+
val actionType: String,
18+
val category: String,
1919
val description: String? = null,
20-
val locked: Int? = null,
20+
val locked: Int,
2121
private val segment: List<Float> = listOf(),
2222
val userID: String? = null,
23-
val videoDuration: Double? = null,
24-
val votes: Int? = null,
23+
val videoDuration: Double,
24+
val votes: Int,
2525
var skipped: Boolean = false
2626
): Parcelable {
2727
@Transient
2828
@IgnoredOnParcel
2929
val segmentStartAndEnd = FloatFloatPair(segment[0], segment[1])
3030

31-
// reminder: all the attributed that are asserted as non-null here are declared non-null by the
32-
// SponsorBlock API, so it's safe to assert they're not null (if we trust the SponsorBlock API docs)
3331
fun toDownloadSegment(videoId: String): DownloadSponsorBlockSegment = DownloadSponsorBlockSegment(
34-
uuid = uuid!!,
32+
uuid = uuid,
3533
videoId = videoId,
3634
startTime = segmentStartAndEnd.first,
3735
endTime = segmentStartAndEnd.second,
38-
actionType = actionType!!,
39-
category = category!!,
36+
actionType = actionType,
37+
category = category,
4038
description = description,
41-
locked = locked!!,
42-
videoDuration = videoDuration!!.toFloat(),
43-
votes = votes!!
39+
locked = locked,
40+
videoDuration = videoDuration.toFloat(),
41+
votes = votes
4442
)
4543

4644
companion object {

0 commit comments

Comments
 (0)