egeniq / android-tv-program-guide

Android TV Program Guide
Apache License 2.0
157 stars 62 forks source link

Endless EPG #68

Open IvanAbakumov opened 1 week ago

IvanAbakumov commented 1 week ago

Is it possible to make endless EPG when if you scroll to the end of the day it will seamlessly go in the next day and so on ?

dzolnai commented 1 week ago

It should be possible, since the cells are created dynamically, only the ones you see on the screen are stored in memory. You could try extending the ranges to like 1 month, and see what happens :)

IvanAbakumov commented 3 days ago

Could you point the place in the code where I can do it ?

dzolnai commented 3 days ago

Hello Ivan,

Here's a diff where I change the timeline to extend to 90 days, and I also fill the demo program with random data for those days. Only thing that needs to be fixed is that the day selector should also update based on the current day (as the time-of-day-selector does), but that shouldn't be too hard :)

90days_timeline.txt

IvanAbakumov commented 2 days ago

You are savior. Thank you so much) I haven't even thought this way.

AaravPatel1999 commented 2 days ago

Hi, I have a similar problem with implementing scrolling for multiple days in the past and future. Specifically, I want to implement scrolling for 7 days into the past and 7 days into the future. These days are set from the current day. I tried your code and it works for days in the "future".

Your code:

EpgFragment.kt

val MIN_CHANNEL_END_TIME =
localDate.atStartOfDay().plusDays(89).withHour(21).truncatedTo(ChronoUnit.HOURS)
.atZone(DISPLAY_TIMEZONE)

val MAX_CHANNEL_END_TIME =
localDate.plusDays(90).atStartOfDay().withHour(4).truncatedTo(ChronoUnit.HOURS)
.atZone(DISPLAY_TIMEZONE)

ProgramGuideManager.kt

val timelineEndsAt =
timelineStartsAt.plusDays(90).withHour(DAY_ENDS_NEXT_DAY_AT_HOUR)

By analogy, I changed the code for days in the "past" and it works strangely.

My code: ProgramGuideManager.kt

val timelineStartsAt =
selectedDate.minusDays(7).atStartOfDay(timeZone).withHour(DAY_STARTS_AT_HOUR)

EpgFragment.kt

  val MIN_CHANNEL_START_TIME =
            localDate.atStartOfDay().minusDays(7).withHour(2).truncatedTo(ChronoUnit.HOURS)
                .atZone(DISPLAY_TIMEZONE)
        val MAX_CHANNEL_START_TIME =
            localDate.atStartOfDay().minusDays(7).withHour(8).truncatedTo(ChronoUnit.HOURS)
                .atZone(DISPLAY_TIMEZONE)

It broked the "live" day, shows only 3 days, and the scroll works only for 3 days. I'm a beginner and don't quite understand what needs to be changed.

dzolnai commented 2 days ago

Hi @AaravPatel1999 could you upload a diff perhaps?

AaravPatel1999 commented 1 day ago

sure file.txt

dzolnai commented 1 day ago

I think your issue is this - your code looks something like:

                    val timelineStartsAt =
                        selectedDate.atStartOfDay(timeZone).minusDays(7).withHour(DAY_STARTS_AT_HOUR)
                    val timelineEndsAt =
                        timelineStartsAt.plusDays(7).withHour(DAY_ENDS_NEXT_DAY_AT_HOUR)

Which means that first, the timeline will start at 7 days before - but then you add 7 days to the timeline start, ending at today. You need to either add 14 days to the start date, or 7 days to the selectedDate, then it should work.

Btw, your diff did not apply, so probably mine won't work on your branch, but I think it is short enough that you get the gist of it. This version works if you apply it on the main branch in this repo: 7days_before_after.txt