From 29f7c6ce879c8d288a80c1e2d0e2ebbacb0c122b Mon Sep 17 00:00:00 2001 From: Xilin Jia <6257601+XilinJia@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:44:45 +0100 Subject: [PATCH] 6.11.6 commit --- app/build.gradle | 4 ++-- .../ac/mdiq/podcini/storage/model/Episode.kt | 7 +++--- .../ac/mdiq/podcini/ui/compose/EpisodesVM.kt | 22 ++++++++++++------- changelog.md | 4 ++++ .../android/en-US/changelogs/3020276.txt | 3 +++ 5 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/3020276.txt diff --git a/app/build.gradle b/app/build.gradle index 85d09db4..609e435b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,8 +31,8 @@ android { testApplicationId "ac.mdiq.podcini.tests" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - versionCode 3020275 - versionName "6.11.5" + versionCode 3020276 + versionName "6.11.6" applicationId "ac.mdiq.podcini.R" def commit = "" diff --git a/app/src/main/kotlin/ac/mdiq/podcini/storage/model/Episode.kt b/app/src/main/kotlin/ac/mdiq/podcini/storage/model/Episode.kt index 58610ad2..f289ae98 100644 --- a/app/src/main/kotlin/ac/mdiq/podcini/storage/model/Episode.kt +++ b/app/src/main/kotlin/ac/mdiq/podcini/storage/model/Episode.kt @@ -122,10 +122,9 @@ class Episode : RealmObject { val imageLocation: String? get() = when { imageUrl != null -> imageUrl - media != null && media?.hasEmbeddedPicture() == true -> EpisodeMedia.FILENAME_PREFIX_EMBEDDED_COVER + media!!.getLocalMediaUrl() - feed != null -> { - feed!!.imageUrl - } +// TODO: this can be very expensive for list +// media != null && media?.hasEmbeddedPicture() == true -> EpisodeMedia.FILENAME_PREFIX_EMBEDDED_COVER + media!!.getLocalMediaUrl() + feed != null -> feed!!.imageUrl else -> null } diff --git a/app/src/main/kotlin/ac/mdiq/podcini/ui/compose/EpisodesVM.kt b/app/src/main/kotlin/ac/mdiq/podcini/ui/compose/EpisodesVM.kt index 535af167..f9d34da5 100644 --- a/app/src/main/kotlin/ac/mdiq/podcini/ui/compose/EpisodesVM.kt +++ b/app/src/main/kotlin/ac/mdiq/podcini/ui/compose/EpisodesVM.kt @@ -80,6 +80,8 @@ import androidx.compose.ui.window.Dialog import androidx.constraintlayout.compose.ConstraintLayout import androidx.documentfile.provider.DocumentFile import coil.compose.rememberAsyncImagePainter +import coil.request.CachePolicy +import coil.request.ImageRequest import io.realm.kotlin.notifications.SingleQueryChange import io.realm.kotlin.notifications.UpdatedObject import kotlinx.coroutines.* @@ -326,6 +328,7 @@ fun EpisodeLazyColumn(activity: MainActivity, vms: SnapshotStateList, val lazyListState = rememberLazyListState() var longPressIndex by remember { mutableIntStateOf(-1) } val dls = remember { DownloadServiceInterface.get() } + val context = LocalContext.current val showConfirmYoutubeDialog = remember { mutableStateOf(false) } val youtubeUrls = remember { mutableListOf() } @@ -588,8 +591,8 @@ fun EpisodeLazyColumn(activity: MainActivity, vms: SnapshotStateList, } val textColor = MaterialTheme.colorScheme.onSurface Column { - val dur = vm.episode.media?.getDuration() ?: 0 - val durText = DurationConverter.getDurationStringLong(dur) + val dur = remember { vm.episode.media?.getDuration() ?: 0 } + val durText = remember { DurationConverter.getDurationStringLong(dur) } Row(Modifier.background(if (vm.isSelected) MaterialTheme.colorScheme.secondaryContainer else MaterialTheme.colorScheme.surface)) { if (false) { val typedValue = TypedValue() @@ -597,10 +600,15 @@ fun EpisodeLazyColumn(activity: MainActivity, vms: SnapshotStateList, Icon(painter = painterResource(typedValue.resourceId), tint = textColor, contentDescription = "drag handle", modifier = Modifier.width(16.dp).align(Alignment.CenterVertically)) } + Logd(TAG, "episode.imageUrl: ${vm.episode.imageUrl}") ConstraintLayout(modifier = Modifier.width(56.dp).height(56.dp)) { val (imgvCover, checkMark) = createRefs() - val imgLoc = ImageResourceUtils.getEpisodeListImageLocation(vm.episode) - val painter = rememberAsyncImagePainter(model = imgLoc) + val imgLoc = remember { ImageResourceUtils.getEpisodeListImageLocation(vm.episode) } + Logd(TAG, "imgLoc: $imgLoc") + val painter = rememberAsyncImagePainter(model = ImageRequest.Builder(context).data(imgLoc) + .memoryCachePolicy(CachePolicy.ENABLED) + .placeholder(R.mipmap.ic_launcher) + .error(R.mipmap.ic_launcher).build()) Image(painter = painter, contentDescription = "imgvCover", modifier = Modifier.width(56.dp).height(56.dp) .constrainAs(imgvCover) { @@ -614,9 +622,7 @@ fun EpisodeLazyColumn(activity: MainActivity, vms: SnapshotStateList, }) ) val alpha = if (vm.playedState) 1.0f else 0f - if (vm.playedState) Icon(painter = painterResource(R.drawable.ic_check), - tint = textColor, - contentDescription = "played_mark", + if (vm.playedState) Icon(painter = painterResource(R.drawable.ic_check), tint = textColor, contentDescription = "played_mark", modifier = Modifier.background(Color.Green).alpha(alpha).constrainAs(checkMark) { bottom.linkTo(parent.bottom) end.linkTo(parent.end) @@ -700,7 +706,7 @@ fun EpisodeLazyColumn(activity: MainActivity, vms: SnapshotStateList, if (vm.showAltActionsDialog) vm.actionButton?.AltActionsDialog(activity, vm.showAltActionsDialog, onDismiss = { vm.showAltActionsDialog = false }) } - if (InTheatre.isCurMedia(vm.episode.media) || vm.inProgressState) { + if (vm.inProgressState || InTheatre.isCurMedia(vm.episode.media)) { val pos = vm.positionState vm.prog = if (dur > 0 && pos >= 0 && dur >= pos) 1.0f * pos / dur else 0f Logd(TAG, "$index vm.prog: ${vm.prog}") diff --git a/changelog.md b/changelog.md index fc2c50e1..352e686a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +# 6.11.6 + +* fixed a serious performance issue when scrolling list of episode having no defined image url + # 6.11.5 * back to be built to target Android 15 diff --git a/fastlane/metadata/android/en-US/changelogs/3020276.txt b/fastlane/metadata/android/en-US/changelogs/3020276.txt new file mode 100644 index 00000000..0a10fe9f --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/3020276.txt @@ -0,0 +1,3 @@ + Version 6.11.5 + +* fixed a serious performance issue when scrolling list of episode having no defined image url