@@ -19,7 +19,6 @@ class ListStreamUiModelImpl(
1919 private val resources : Resources
2020) : ListStreamUimodel {
2121 override fun convertToCardContent (listStream : List <ListStream >): ListStreamsUIState {
22- val item = listStream.random().streams.random()
2322 return ListStreamsUIState (
2423 isLoading = false ,
2524 carousels = listStream.map {
@@ -32,16 +31,27 @@ class ListStreamUiModelImpl(
3231 )
3332 })
3433 },
35- highlightBanner = HighlightBanner (
36- name = item.name,
37- imageUrl = item.posterPathUrl,
38- contentType = ContentType .getContentName(ContentType .FILM ),
39- contentTypeAsPlural = ContentType .getContentNameAsPlural(ContentType .FILM ),
40- extraInfo = IconAndTextInfo (R .drawable.ic_top_10, R .string.highlight_banner_stream_ranking),
41- leftButton = IconAndTextInfo (drawable.ic_add, R .string.highlight_banner_add),
42- centralButton = IconAndTextInfo (drawable.ic_play, R .string.highlight_banner_watch),
43- rightButton = IconAndTextInfo (drawable.ic_info, R .string.highlight_banner_info),
44- )
34+ highlightBanner = getHighlightBanner(listStream)
35+ )
36+ }
37+
38+ private fun getHighlightBanner (listStream : List <ListStream >): HighlightBanner ? {
39+ if (listStream.isEmpty()) return null
40+
41+ val item = listStream.random().streams.random()
42+
43+ return HighlightBanner (
44+ name = item.name,
45+ imageUrl = item.posterPathUrl,
46+ contentType = ContentType .getContentName(ContentType .FILM ),
47+ contentTypeAsPlural = ContentType .getContentNameAsPlural(ContentType .FILM ),
48+ extraInfo = IconAndTextInfo (
49+ R .drawable.ic_top_10,
50+ R .string.highlight_banner_stream_ranking
51+ ),
52+ leftButton = IconAndTextInfo (drawable.ic_add, R .string.highlight_banner_add),
53+ centralButton = IconAndTextInfo (drawable.ic_play, R .string.highlight_banner_watch),
54+ rightButton = IconAndTextInfo (drawable.ic_info, R .string.highlight_banner_info),
4555 )
4656 }
4757}
0 commit comments