private boolean calculateMissingLengths(ChannelDayProgram channelProg) {
boolean somethingChanged = false;
// Go through all programs and correct them
// (This is fast, if no correction is needed)
for (int progIdx = 0; progIdx < channelProg.getProgramCount(); progIdx++) {
Program program = channelProg.getProgramAt(progIdx);
if (!(program instanceof MutableProgram)) {
continue;
}
MutableProgram prog = (MutableProgram) program;
if (prog.getLength() <= 0) {
// Try to get the next program
Program nextProgram = null;
if ((progIdx + 1) < channelProg.getProgramCount()) {
// Try to get it from this ChannelDayProgram
nextProgram = channelProg.getProgramAt(progIdx + 1);
} else {
// This is the last program -> Try to get the first program of the