public PluginTreeNode getRootNode() {
return rootNode;
}
private void updatePluginTree() {
PluginTreeNode root = getRootNode();
Channel[] channels = devplugin.Plugin.getPluginManager().getSubscribedChannels();
if (null == channels) {
return;
}
// iterate over all programs to find programs with ratings
Date day = getPluginManager().getCurrentDate();
HashMap<Program, ArrayList<Movie>> programs = new HashMap<Program, ArrayList<Movie>>();
final int startOfDay = getPluginManager().getTvBrowserSettings().getProgramTableStartOfDay();
final int endOfDay = getPluginManager().getTvBrowserSettings().getProgramTableEndOfDay();
for (Channel channel : channels) {
if (isChannelHidden(channel)) {
continue;
}
// show only today and tomorrow
for (int dayOffset = 0; dayOffset < 2; dayOffset++) {
Iterator<Program> iter = devplugin.Plugin.getPluginManager().getChannelDayProgram(day.addDays(dayOffset),
channel);
if (iter != null) {
try {
while (iter.hasNext()) {
Program prog = iter.next();
if (dayOffset == 0 && prog.getTimeField(ProgramFieldType.START_TIME_TYPE) < startOfDay) {
continue;
}
if (dayOffset == 1 && prog.getTimeField(ProgramFieldType.START_TIME_TYPE) > endOfDay) {
continue;
}
Set<Movie>[] movies = findMovies(prog);
if (null != movies) {
ArrayList<Movie> list = new ArrayList<Movie>();
if (movies[0] != null) {
list.addAll(movies[0]);
}
if (movies[1] != null) {
list.addAll(movies[1]);
}
if (list.size() > 0) {
programs.put(prog, list);
}
}
}
} catch (NullPointerException e) {
}
}
}
}
// show programs under sub nodes with rating from 1+ to 9+
for (Program program : programs.keySet()) {
ArrayList<Movie> movies = programs.get(program);
for (Movie movie : movies) {
int index = movie.getRank() / 10 - 1;
if (index == rankNode.length) {
index = rankNode.length - 1;
}
addPluginTreeNode(rankNode[index], movie, program);
}
}
root.update();
}