Skip to content

Commit 9c471b4

Browse files
Check cursor size in channel resolver before building list to avoid "Unable to move cursor" warning
1 parent 8d28ae1 commit 9c471b4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/src/main/kotlin/nl/ndat/tvlauncher/data/resolver/ChannelResolver.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ChannelResolver {
5656
val cursor = context.contentResolver.tryQuery(
5757
TvContractCompat.Channels.CONTENT_URI,
5858
PreviewChannel.Columns.PROJECTION,
59-
) ?: return@withContext emptyList()
59+
)?.takeIf { it.count > 0 } ?: return@withContext emptyList()
6060

6161
buildList {
6262
if (!cursor.moveToFirst()) {
@@ -94,7 +94,7 @@ class ChannelResolver {
9494
val cursor = context.contentResolver.tryQuery(
9595
TvContractCompat.buildPreviewProgramsUriForChannel(channelId),
9696
PreviewProgram.PROJECTION,
97-
) ?: return@withContext emptyList()
97+
)?.takeIf { it.count > 0 } ?: return@withContext emptyList()
9898

9999
buildList {
100100
if (!cursor.moveToFirst()) {
@@ -120,7 +120,7 @@ class ChannelResolver {
120120
val cursor = context.contentResolver.tryQuery(
121121
TvContractCompat.WatchNextPrograms.CONTENT_URI,
122122
WatchNextProgram.PROJECTION,
123-
) ?: return@withContext emptyList()
123+
)?.takeIf { it.count > 0 } ?: return@withContext emptyList()
124124

125125
buildList {
126126
if (!cursor.moveToFirst()) {

0 commit comments

Comments
 (0)