Created
February 22, 2023 22:12
-
-
Save ademirqueiroga/92e0d20df9caafdabe80b6f02c5588ed to your computer and use it in GitHub Desktop.
Get channel programs function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun getChannelPrograms(channelId: Long): List<PreviewProgram> { | |
val programs = ArrayList<PreviewProgram>() | |
context.contentResolver.query( | |
/* uri = */ TvContractCompat.PreviewPrograms.CONTENT_URI, | |
/* projection = */ PreviewProgram.PROJECTION, | |
/* selection = */ null, | |
/* selectionArgs = */ null, | |
/* sortOrder = */ null | |
).use { cursor -> | |
if (cursor != null) { | |
while (cursor.moveToNext()) { | |
val program = PreviewProgram.fromCursor(cursor) | |
if (program.channelId == channelId) { | |
programs.add(program) | |
} | |
} | |
} | |
} | |
return programs | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment