Android EPG вид в Android Mobile. Я работаю над приложением OTT, и мне нужно показать EPG в моем приложении. Я получаю данные EPG с сервера.
Я получил пример проекта от github [https://github.com/korre/android-tv-epg]. Я попытался реализовать этот проект и застрял в загрузке данных EPG с сервера. Я использую модификацию для получения данных с сервера.
fun GetChnlEPG( map: HashMap<String, String>){
val Call = apiInterface.GetChnlEPG(map)
Call.enqueue(object : Callback<EPGResponseList>{
override fun onResponse(
call: Call<EPGResponseList>,
response: Response<EPGResponseList>
) {
if (response.isSuccessful()){
ChnlDetails = response.body()!!.channelDetails as ArrayList<ChannelDetail>
for (i in 0 until ChnlDetails.size){
var EPGResponse: ArrayList<EpgReponse>
EPGResponse = ChnlDetails.get(i).epg as ArrayList<EpgReponse>
for (j in 0 until EPGResponse.size){
if (EPGResponse.get(j).epgAvailable.toString().equals("YES")){
ChnlEpgDetails = EPGResponse.get(j).epgDetails as ArrayList<EpgDetailResponse>
for (k in 0 until ChnlEpgDetails.size){
val ProgDuration = ChnlEpgDetails.get(k).programName
Log.d("epgDetails", ProgDuration.toString())
}
}
}
}
}
}
override fun onFailure(call: Call<EPGResponseList>, t: Throwable) {
Log.d("EPGResponseList", t.message)
}
})
}
//The sample project loads the EPG data as follows
public class MockDataService {
private static Random rand = new Random();
private static ArrayList<Integer> availableEventLength = new ArrayList<>(Arrays.asList(
1000*60*15, // 15 minutes
1000*60*30, // 30 minutes
1000*60*45, // 45 minutes
1000*60*60, // 60 minutes
1000*60*120 // 120 minutes
));
private static List<String> availableEventTitles = new ArrayList<>(Arrays.asList(
"Avengers",
"How I Met Your Mother",
"Silicon Valley",
"Late Night with Jimmy Fallon",
"The Big Bang Theory",
"Leon",
"Die Hard"
));
private static List<String> availableChannelLogos = new ArrayList<>(Arrays.asList(
"http://tineye.com/images/widgets/mona.jpg",
"https://homepages.cae.wisc.edu/~ece533/images/airplane.png",
"https://homepages.cae.wisc.edu/~ece533/images/baboon.png",
"https://homepages.cae.wisc.edu/~ece533/images/fruits.png",
"https://homepages.cae.wisc.edu/~ece533/images/pool.png"
));
public static Map<EPGChannel, List<EPGEvent>> getMockData() {
HashMap<EPGChannel, List<EPGEvent>> result = new HashMap<>();
long nowMillis = System.currentTimeMillis();
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));
}
return result;
}
private static List<EPGEvent> createEvents(EPGChannel epgChannel, long nowMillis) {
ArrayList<EPGEvent> result = new ArrayList<>();
long epgStart = nowMillis - EPG.DAYS_BACK_MILLIS;
long epgEnd = nowMillis + EPG.DAYS_FORWARD_MILLIS;
long currentTime = epgStart;
while (currentTime <= epgEnd) {
long eventEnd = getEventEnd(currentTime);
EPGEvent epgEvent = new EPGEvent(currentTime, eventEnd, availableEventTitles.get(randomBetween(0, 6)));
result.add(epgEvent);
currentTime = eventEnd;
}
return result;
}
private static long getEventEnd(long eventStartMillis) {
long length = availableEventLength.get(randomBetween(0,4));
return eventStartMillis + length;
}
private static int randomBetween(int start, int end) {
return start + rand.nextInt((end - start) + 1);
}