Skip to content

Commit

Permalink
fix: Add Null or empty validation for videoId, and accessToken (#195)
Browse files Browse the repository at this point in the history
- In this commit, we have added Null or empty validation to `videoId`, and `accessToken` in `TpInitParams`
  • Loading branch information
PruthiviRaj27 committed Jul 12, 2024
1 parent 4ba7378 commit bcee6aa
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions player/src/main/java/com/tpstream/player/TpInitParams.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import kotlinx.parcelize.Parcelize

@Parcelize
data class TpInitParams (
var autoPlay: Boolean? = null,
var autoPlay: Boolean = false,
var accessToken: String? = null,
var videoId: String? = null,
var isDownloadEnabled: Boolean = false,
var startAt: Long = 0L
): Parcelable {

class Builder {
private var autoPlay: Boolean? = null
private var autoPlay: Boolean = false
private var accessToken: String? = null
private var videoId: String? = null
private var isDownloadEnabled: Boolean = false
Expand All @@ -26,12 +26,15 @@ data class TpInitParams (
fun enableDownloadSupport(isDownloadEnabled: Boolean) = apply { this.isDownloadEnabled = isDownloadEnabled }

fun build(): TpInitParams {
require(!accessToken.isNullOrBlank()) { "accessToken must not be null or empty" }
require(!videoId.isNullOrBlank()) { "videoId must not be null or empty" }

return TpInitParams(
autoPlay,
accessToken,
videoId,
isDownloadEnabled,
startAt
autoPlay = autoPlay,
accessToken = accessToken!!,
videoId = videoId!!,
isDownloadEnabled = isDownloadEnabled,
startAt = startAt
)
}
}
Expand All @@ -54,7 +57,8 @@ data class TpInitParams (
return TpInitParams(
videoId = videoId,
isDownloadEnabled = true,
autoPlay = true
autoPlay = true,
accessToken = "offlineVideo"
)
}
}
Expand Down

0 comments on commit bcee6aa

Please sign in to comment.