}
if( m_openPage ) {
String parm = m_bookmarkList.getString(
m_curBookmark);
feed = (RssItunesFeed)m_rssFeeds.get(parm);
m_curRssParser = new RssFeedParser( feed );
m_openPage = ( feed.getItems().size() > 0 );
m_getPage = !m_openPage;
m_prevDisp = m_bookmarkList;
} else {
feed = m_curRssParser.getRssFeed();
}
if( m_openPage ) {
/* Loading feed... */
initializeLoadingFormRsc("text.l.feed",
m_bookmarkList);
} else {
/* Updating feed... */
initializeLoadingFormRsc(
m_getModPage ? "text.u.mfeed" :
"text.u.feed", m_prevDisp);
}
if(feed.getUrl().length() == 0) {
recordExcFormFin("Unable to open feed. No URL.",
new Exception(
"Feed has no URL cannot load."));
continue;
}
if (!m_openPage) {
/** Get RSS feed */
final int maxItemCount =
m_appSettings.getMaximumItemCountInFeed();
final boolean convHtml =
!m_appSettings.getHtmlEnabled();
//#ifdef DTEST
//@ System.gc();
//@ long beginMem = Runtime.getRuntime().freeMemory();
//#endif
m_curRssParser.parseRssFeed( m_getModPage, convHtml,
maxItemCount );
//#ifdef DTEST
//@ System.gc();
//@ System.out.println("RssItunesFeed size=" + (beginMem - Runtime.getRuntime().freeMemory()));
//#endif
feed = m_curRssParser.getRssFeed();
//#ifdef DTEST
//@ System.gc();
//@ beginMem = Runtime.getRuntime().freeMemory();
//#endif
m_rssFeeds.put(feed.getName(), feed);
//#ifdef DTEST
//@ System.gc();
//@ System.out.println("RssItunesFeed store size=" + (beginMem - Runtime.getRuntime().freeMemory()));
//#endif
}
//#ifdef DTEST
//@ System.gc();
//@ long beginMem = Runtime.getRuntime().freeMemory();
//#endif
final HeaderList hdrList = new HeaderList(this, feed);
//#ifdef DTEST
//@ System.gc();
//@ System.out.println("headerList size=" + (beginMem - Runtime.getRuntime().freeMemory()));
//#endif
hdrList.fillHeadersList();
setCurrent( hdrList );
//#ifdef DTEST
//@ hdrList.testFeed(true);
//@ hdrList.testFeed(false);
//@ hdrList.testFeed2(true);
//@ hdrList.testFeed2(false);
//#endif
}catch(CauseMemoryException e) {
System.gc();
if ((m_curRssParser != null) &&
(m_curRssParser.getRssFeed() != null)) {
m_curRssParser.getRssFeed().setItems(new Vector());
}
recordExcFormFinRsc(
/* \nOut of memory loading/parsing feed on:\n */
(m_openPage ? "exc.om.ld" : "exc.om.pse"),
m_curRssParser.getRssFeed().getUrl(), e);
}catch(Exception e) {
/* Error loading/parsing feed on:\n \1 */
recordExcFormFinRsc(
(m_openPage ? "exc.er.ld" : "exc.er.pse"),
m_curRssParser.getRssFeed().getUrl(), e);
}catch(OutOfMemoryError e) {
System.gc();
if ((m_curRssParser != null) &&
(m_curRssParser.getRssFeed() != null)) {
m_curRssParser.getRssFeed().setItems(new Vector());
}
recordExcFormFinRsc(
/* Out of memory loading/parsing feed on:\n */
(m_openPage ? "exc.om.ld" : "exc.om.pse"),
m_curRssParser.getRssFeed().getUrl(), e);
}catch(Throwable t) {
recordExcFormFinRsc(
/* Internal error loading/parsing feed on:\n */
(m_openPage ? "exc.int.ld" : "exc.int.pse"),
m_curRssParser.getRssFeed().getUrl(), t);
} finally {
m_getPage = false;
m_openPage = false;
m_getModPage = false;
}
}
/* Handle going to settings form. */
if( m_getSettingsForm ) {
m_getSettingsForm = false;
/* Loading settings... */
initializeLoadingFormRsc("text.l.s", m_bookmarkList);
try{
//#ifdef DTEST
//@ System.gc();
//@ long beginMem = Runtime.getRuntime().freeMemory();
//#endif
final SettingsForm settingsForm = new SettingsForm(this);
//#ifdef DTEST
//@ System.gc();
//@ System.out.println("SettingsForm size=" +
//@ (beginMem - Runtime.getRuntime().freeMemory()));
//#endif
if (m_loadForm.hasExc()) {
m_loadForm.addStartCmd( settingsForm );
} else {
setCurrent( settingsForm );
}
} catch(OutOfMemoryError t) {
System.gc();
/* \nOut Of Memory Error loading settings form */
recordExcFormFinRsc("exc.om.set", t);
} catch(Throwable t) {
/* \nInternal error loading settings form */
recordExcFormFinRsc("exc.int.lset", t);
}
}
//#ifndef DSMALLMEM
/* Handle going to help form. */
if( m_getHelpForm ) {
m_getHelpForm = false;
/* Loading help... */
initializeLoadingFormRsc("text.l.h", m_bookmarkList);
try{
final HelpForm helpForm = initializeHelp();
setCurrent( helpForm );
} catch(OutOfMemoryError t) {
System.gc();
/* \nOut Of Memory Error loading help form */
recordExcFormFinRsc("exc.om.bhlp", t);
} catch(Throwable t) {
/* \nInternal error loading help form */
recordExcFormFinRsc("exc.int.bhlp", t);
}
}
//#endif
/* Handle going to bookmark form. */
if( m_getAddBMForm || m_getEditBMForm ) {
try {
if( m_getEditBMForm ) {
m_curBookmark = UiUtil.getSelectedIndex(m_bookmarkList);
if( m_curBookmark<0 ){
continue;
}
}
if( m_getAddBMForm ) {
/* Loading add bookmark... */
initializeLoadingFormRsc("text.l.bmrk",
m_bookmarkList);
} else {
/* Loading edit bookmark... */
initializeLoadingFormRsc("text.edit",
m_bookmarkList);
}
//#ifdef DTEST
//@ System.gc();
//@ long beginMem = Runtime.getRuntime().freeMemory();
//#endif
BMForm bmForm = new BMForm(m_getAddBMForm);
//#ifdef DTEST
//@ System.gc();
//@ System.out.println("BMForm size=" +
//@ (beginMem - Runtime.getRuntime().freeMemory()));
//#endif
if (m_getEditBMForm) {
final RssItunesFeed bm = (RssItunesFeed)m_rssFeeds.get(
m_bookmarkList.getString(m_curBookmark));
bmForm.updateBM(bm);
}
setCurrent( bmForm );
} catch(OutOfMemoryError t) {
System.gc();
/* \nOut Of Memory Error loading bookmark form */
recordExcFormFinRsc("exc.om.bmk", t);
} catch(Throwable t) {
/* \nInternal error loading bookmark form */
recordExcFormFinRsc("exc.int.bmk", t);
} finally {
m_getAddBMForm = false;
m_getEditBMForm = false;
}
}
if( m_refreshAllFeeds || m_refreshUpdFeeds ) {
/* Updating all or modified feeds... */
initializeLoadingFormRsc((m_refreshUpdFeeds ?
"text.um.feed" : "text.ua.feed"),
m_bookmarkList);
/* Updating all (modified) feeds...*/
Gauge gauge = new Gauge(ResourceProviderME.get(
m_refreshAllFeeds ? "text.ua.feed" :
"text.um.feed"),
false, m_rssFeeds.size(), 0);
int pl = m_loadForm.append(gauge);
try{
boolean errFound = false;
final int maxItemCount =
m_appSettings.getMaximumItemCountInFeed();
final boolean convHtml =
!m_appSettings.getHtmlEnabled();
Enumeration keyEnum = m_rssFeeds.keys();
int ic = 1;
while(keyEnum.hasMoreElements()) {
final String fname =
(String)keyEnum.nextElement();
RssItunesFeed feed =
(RssItunesFeed)m_rssFeeds.get(fname);
try{
m_loadForm.appendMsg(fname + "...");
RssFeedParser parser = new RssFeedParser( feed );
parser.parseRssFeed( m_refreshUpdFeeds,
convHtml, maxItemCount);
m_rssFeeds.put( fname, feed );
m_loadForm.appendMsg("ok\n");
} catch(CauseMemoryException ex) {
throw ex;