Skip to content

Instantly share code, notes, and snippets.

@ademirqueiroga
Created February 22, 2023 22:12
Show Gist options
  • Save ademirqueiroga/92e0d20df9caafdabe80b6f02c5588ed to your computer and use it in GitHub Desktop.
Save ademirqueiroga/92e0d20df9caafdabe80b6f02c5588ed to your computer and use it in GitHub Desktop.
Get channel programs function
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