From 8aa600151bfefe7ff1d95d4b16e98d6206f98eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Muller?= Date: Fri, 8 Dec 2023 14:20:01 +0100 Subject: [PATCH] Fix some Lint warnings --- .../src/main/res/values-de/strings.xml | 4 +- .../demo/ui/showcases/story/SimpleStory.kt | 40 ++++++++----------- .../pillarbox/ui/widget/KeepScreenOn.kt | 2 + 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/pillarbox-core-business/src/main/res/values-de/strings.xml b/pillarbox-core-business/src/main/res/values-de/strings.xml index a505d9b32..84393529a 100644 --- a/pillarbox-core-business/src/main/res/values-de/strings.xml +++ b/pillarbox-core-business/src/main/res/values-de/strings.xml @@ -2,8 +2,8 @@ ~ Copyright (c) SRG SSR. All rights reserved. ~ License information is available from the LICENSE file. --> - - Dieser Inhalt ist ausserhalb der Schweiz nicht verfügbar. + + Dieser Inhalt ist ausserhalb der Schweiz nicht verfügbar. Dieser Inhalt ist aus rechtlichen Gründen nicht verfügbar. Dieser Werbe-Inhalt ist nicht verfügbar. Dieser Inhalt ist aus Gründen des Jugendschutzes nur zwischen 22:00 und 5:00 Uhr verfügbar. diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/story/SimpleStory.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/story/SimpleStory.kt index 18cfa8b50..93171bf65 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/story/SimpleStory.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/story/SimpleStory.kt @@ -9,10 +9,8 @@ import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.viewinterop.AndroidView import androidx.media3.common.C import androidx.media3.common.Player @@ -53,33 +51,29 @@ fun SimpleStory() { */ @Composable private fun SimpleStoryPlayer(demoItem: DemoItem, isPlaying: Boolean = false) { - val context = LocalContext.current - val player = remember { - PillarboxPlayer( - context = context, - mediaItemSource = PlayerModule.provideMixedItemSource(context), - loadControl = StoryLoadControl.build() - ).apply { - setMediaItem(demoItem.toMediaItem()) - prepare() - videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING - repeatMode = Player.REPEAT_MODE_ONE - } - } - player.playWhenReady = isPlaying + AndroidView( + factory = { context -> + val player = PillarboxPlayer( + context = context, + mediaItemSource = PlayerModule.provideMixedItemSource(context), + loadControl = StoryLoadControl.build() + ).apply { + setMediaItem(demoItem.toMediaItem()) + prepare() + videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING + repeatMode = Player.REPEAT_MODE_ONE + playWhenReady = isPlaying + } - DisposableEffect( - AndroidView(factory = { PlayerView(context).apply { hideController() useController = false resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM this.player = player } - }) - ) { - onDispose { - player.release() + }, + onRelease = { + it.player?.release() } - } + ) } diff --git a/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/KeepScreenOn.kt b/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/KeepScreenOn.kt index ffa9fd85d..a51120aea 100644 --- a/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/KeepScreenOn.kt +++ b/pillarbox-ui/src/main/java/ch/srgssr/pillarbox/ui/widget/KeepScreenOn.kt @@ -4,6 +4,7 @@ */ package ch.srgssr.pillarbox.ui.widget +import android.annotation.SuppressLint import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.platform.LocalView @@ -14,6 +15,7 @@ import ch.srgssr.pillarbox.ui.extension.isPlayingAsState * Keep screen on when [Player.isPlaying] */ @Composable +@SuppressLint("ComposableNaming") fun Player.keepScreenOn() { val isPlaying by isPlayingAsState() LocalView.current.keepScreenOn = isPlaying