korre / android-tv-epg

Classic TV electronic program guide (EPG) with multidirectional scroll
MIT License
160 stars 75 forks source link

Changing input data #27

Open Aecttann opened 4 years ago

Aecttann commented 4 years ago

How should I change MockDataService class for my own data, which are going in a strong order? What steps I need to do? Now there are random values from Lists. I was trying to change some loops, for example:

        for (int i=0 ; i < availableChannelLogos.size(); i++) {
            EPGChannel epgChannel = new EPGChannel(availableChannelLogos.get(i),
                    "Channel " + (i+1), Integer.toString(i));

            result.put(epgChannel, createEvents(epgChannel, nowMillis));
        }

and

//        while (currentTime <= epgEnd) {
            for(int i = 0; currentTime <= epgEnd; i++){
                long eventEnd = getEventEnd(currentTime);
                EPGEvent epgEvent = new EPGEvent(currentTime, eventEnd, availableEventTitles.get(i));
                result.add(epgEvent);
                currentTime = eventEnd;
            }
//            long eventEnd = getEventEnd(currentTime);
//            EPGEvent epgEvent = new EPGEvent(currentTime, eventEnd, availableEventTitles.get(randomBetween(0, 6)));
//            result.add(epgEvent);
//            currentTime = eventEnd;
//        }

but I didn't think that I'm on the right way.

And with this method I even have no ideas how to change it for me:

    private static long getEventEnd(long eventStartMillis) {
        long length = availableEventLength.get(randomBetween(0,5));
        return eventStartMillis + length;
    }
devnullpointer commented 3 years ago

The MockDataService is simply a service that generates a map of channels and epgevents for the channel. All you need to do is call your own service or data gathering mechanism, build the Map<Channel, EPGEvent> and then pass it to the epg object.

final Map<Channel, EPGEvent> epgData = myService.getMyData();
epg.setEPGData(epgData);
epg.recalculateAndRedraw(false);