// Split the subsribed channels by data service
Channel[] subscribedChannels = ChannelList.getSubscribedChannels();
UpdateJob[] jobArr = toUpdateJobArr(subscribedChannels, services);
// Create the ProgressMonitorGroup
ProgressMonitorGroup monitorGroup
= new ProgressMonitorGroup(progressBar, label, subscribedChannels.length + 1);
// Work on the job list
Throwable downloadException = null;
for (int i = 0; (i < jobArr.length) && (!mStopDownloading); i++) {
TvDataServiceProxy dataService = jobArr[i].getDataService();
Channel[] channelArr = jobArr[i].getChannelList();
ProgressMonitor monitor = monitorGroup.getNextProgressMonitor(channelArr.length);
try {
dataService.updateTvData(updateManager, channelArr, startDate,
daysToDownload, monitor);
}
catch (Throwable thr) {
mLog.log(Level.WARNING, "Updating the TV data for TV data service "
+ dataService.getInfo().getName() + " failed", thr);
downloadException = thr;
}
}
// Show the exception if there was one
if (downloadException != null) {
String msg = mLocalizer.msg("error.1", "Couldn't download the whole program!");
ErrorHandler.handle(msg, downloadException);
}
// Reset the download flag
mIsDownloading = false;
checkLocalDateUsingNTP();
ProgressMonitor monitor = monitorGroup.getNextProgressMonitor(subscribedChannels.length+1);
monitor.setMessage(mLocalizer.msg("calculateEntries","Calculating new entries in the database"));
TvDataBase.getInstance().reCalculateTvData(daysToDownload, monitor);
TvDataBase.getInstance().updateTvDataBase();
MarkedProgramsList.getInstance().revalidatePrograms();