Added VideoClipEntity and TvShowEntity#4
Conversation
| episodeNumber = entity.episodeNumber, | ||
| ) | ||
| is VideoClipEntity -> entity.name | ||
| else -> throw IllegalStateException("Unsupported video type for Continue Watching: $entity") |
There was a problem hiding this comment.
Let's change the else to is TvShowEntity instead.
|
|
||
| is VideoClipEntity -> null | ||
|
|
||
| else -> throw IllegalStateException("Unsupported video type for Continue Watching: $entity") |
There was a problem hiding this comment.
Let's change the else to is TvShowEntity instead.
| val genre: String, | ||
| val seasonCount: Integer, | ||
| val duration: Duration, | ||
| var nextTvShowEntity: TvShowEntity?, |
There was a problem hiding this comment.
Let's remove this as a TvShowEntity doesn't have a next show.
| val platformSpecificUris: PlatformSpecificUris, | ||
| val releaseYear: Int, | ||
| val genre: String, | ||
| val seasonCount: Integer, |
There was a problem hiding this comment.
Let's remove the season count for now. When we want to make use of seasons, we can create a new entity called TvSeasonEntity and then add a new field to the TvShowEntity called val seasons: List<TvSeasonEntity>. Then, we can create a getter which returns the seasonCount.
data class TvShowEntity(
...
) {
val seasonCount = seasons.size()
}This way, we will avoid having fragmented state and it will help us prevent out-of-sync issues.
| val duration: Duration | ||
| val name: String | ||
| val playbackUris: PlatformSpecificUris | ||
| val images: List<Image> |
There was a problem hiding this comment.
nit: we can keep the images field as well in the VideoEntity interface as all video entities will have images.
| else -> throw IllegalStateException("Unsupported video type for Continue Watching: $entity") | ||
| } | ||
| val duration: Duration | ||
| get() = when (entity) { | ||
| is MovieEntity -> entity.duration | ||
| is TvEpisodeEntity -> entity.duration | ||
| is VideoClipEntity -> entity.duration | ||
| else -> throw IllegalStateException("Unsupported video type for Continue Watching: $entity") | ||
| } | ||
|
|
||
| val genre: String | ||
| get() = when (entity) { | ||
| is MovieEntity -> entity.genre | ||
| is TvEpisodeEntity -> entity.genre | ||
| is VideoClipEntity -> entity.genre | ||
| else -> throw IllegalStateException("Unsupported video type for Continue Watching: $entity") |
There was a problem hiding this comment.
Let's change the else to is TvShowEntity instead.
The benefit is that when we add a new entity type in future, we will be warned by compiler that we need to update this place. If we use the generic else, we might forget to update some place and the app will crash at runtime.
| is MovieEntity -> entity.convertToEngageMovieEntity(this) | ||
| is TvEpisodeEntity -> entity.convertToEngageTvEpisodeEntity(this) | ||
| is VideoClipEntity -> entity.convertToEngageVideoClipEntity(this) | ||
| else -> throw IllegalStateException("Unsupported video type for Continue Watching: $entity") |
There was a problem hiding this comment.
Let's change the else to is TvShowEntity instead.
Key Changes:
New Entity Types:
Continue Watching:
Engage SDK Integration
UI Updates: