From 5108b250f637172f7fa340653e6c1759b45ceab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Muller?= Date: Mon, 22 Jan 2024 11:01:03 +0100 Subject: [PATCH] Add protected examples on TV --- .../demo/shared}/ui/examples/ExamplesViewModel.kt | 4 +++- .../srgssr/pillarbox/demo/tv/ui/examples/ExamplesHome.kt | 7 +++++-- .../ch/srgssr/pillarbox/demo/ui/examples/ExamplesHome.kt | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) rename {pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo => pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared}/ui/examples/ExamplesViewModel.kt (94%) diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/examples/ExamplesViewModel.kt b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/examples/ExamplesViewModel.kt similarity index 94% rename from pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/examples/ExamplesViewModel.kt rename to pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/examples/ExamplesViewModel.kt index fd684d9a7..1fe061e30 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/examples/ExamplesViewModel.kt +++ b/pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/examples/ExamplesViewModel.kt @@ -2,7 +2,7 @@ * Copyright (c) SRG SSR. All rights reserved. * License information is available from the LICENSE file. */ -package ch.srgssr.pillarbox.demo.ui.examples +package ch.srgssr.pillarbox.demo.shared.ui.examples import android.app.Application import androidx.lifecycle.AndroidViewModel @@ -40,6 +40,7 @@ class ExamplesViewModel(application: Application) : AndroidViewModel(application item.title }, description = "DRM-protected video", + imageUrl = item.imageUrl.rawUrl, uri = item.urn ) } @@ -48,6 +49,7 @@ class ExamplesViewModel(application: Application) : AndroidViewModel(application DemoItem( title = item.title, description = "Token-protected video", + imageUrl = item.imageUrl.rawUrl, uri = item.urn ) } diff --git a/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/examples/ExamplesHome.kt b/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/examples/ExamplesHome.kt index 854d203c7..35fbfc68b 100644 --- a/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/examples/ExamplesHome.kt +++ b/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/examples/ExamplesHome.kt @@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf @@ -37,6 +38,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview +import androidx.lifecycle.viewmodel.compose.viewModel import androidx.navigation.NavHostController import androidx.navigation.NavType import androidx.navigation.compose.NavHost @@ -52,8 +54,8 @@ import androidx.tv.material3.ExperimentalTvMaterial3Api import androidx.tv.material3.MaterialTheme import androidx.tv.material3.Text import ch.srgssr.pillarbox.demo.shared.data.DemoItem -import ch.srgssr.pillarbox.demo.shared.data.Playlist import ch.srgssr.pillarbox.demo.shared.ui.NavigationRoutes +import ch.srgssr.pillarbox.demo.shared.ui.examples.ExamplesViewModel import ch.srgssr.pillarbox.demo.tv.extension.onDpadEvent import ch.srgssr.pillarbox.demo.tv.ui.theme.PillarboxTheme import ch.srgssr.pillarbox.demo.tv.ui.theme.paddings @@ -73,8 +75,9 @@ fun ExamplesHome( modifier: Modifier = Modifier, onItemSelected: (DemoItem) -> Unit = {}, ) { + val examplesViewModel: ExamplesViewModel = viewModel() val navController = rememberNavController() - val playlists = Playlist.examplesPlaylists + val playlists by examplesViewModel.contents.collectAsState() NavHost( navController = navController, diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/examples/ExamplesHome.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/examples/ExamplesHome.kt index d95e30e5c..a68686953 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/examples/ExamplesHome.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/examples/ExamplesHome.kt @@ -25,6 +25,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel import ch.srgssr.pillarbox.demo.BuildConfig import ch.srgssr.pillarbox.demo.shared.data.DemoItem import ch.srgssr.pillarbox.demo.shared.data.Playlist +import ch.srgssr.pillarbox.demo.shared.ui.examples.ExamplesViewModel import ch.srgssr.pillarbox.demo.ui.components.DemoListHeaderView import ch.srgssr.pillarbox.demo.ui.components.DemoListItemView import ch.srgssr.pillarbox.demo.ui.components.DemoListSectionView