Reading Time: 3 minutes
Several months ago, we were tasked to implement a built-in program guide a built-in program guide (also called an EPG) in one of our Android TV apps. It should list all the channels from top to bottom, with the programs on the channels laid out from left to right on a timeline.
There are some apps on Google Play, which have a similar program guide built-in, so I was hoping that there is a library, or a Leanback component which we could build upon.
Our search led to some outdated repositories, and EPG’s built for the mobile Android, but none of those were good enough to be used as a baseline. However we did find the source code for the Android TV app built by Google for displaying the channels on your TV you receive from your television subscription. The layout part did fit our needs, but we had to adapt the data layer, to use our own channels and programs.
While we were doing that, we removed everything which seemed unnecessary for us, to keep the code minimal, and also converted it over to Kotlin, as our app was already a 100% Kotlin. Although it did take some time to understand the complex RecyclerView-in-a-RecyclerView workings, with the custom focus handling, after a point it all started to fit together.
We customized the program guide so that it only displays one day at a time, and going to other days is possible by using a filter. Also we added quick jumps to different parts of the day, or to the current live position.
After the usual testing and bug fixing, we have released this feature in our production app, and we are pretty happy about it. Now we feel it is the time to give back to the community, and are releasing the code as an open-source library. We have refactored it to be more extensible and configurable, and added a demo module to demonstrate the usage of the library, while also making it easy to test it out on your device, if you want to.
Our assumption is, that probably you will have to fork the project to adjust it to the specifications and designs you have, so right now we are not offering a packaged (aar) version of this library. We have made it a bit configurable, so you can change default locale and time zone, or a number of selectable dates easily, if we would have to make every feature customizable, the project would explode in terms of lines of code. So feel free to fork and edit, if you have found a bug (or just have questions), create an issue, and we will do our best to help you.