问题
The app I'm writing loads an RSS feed using the HorrorRSS library. The problem I'm facing is that looking at the logs I see oodles of this junk:
10-06 12:58:36.939: I/global(3159): Loaded time zone names for en in 624ms.
10-06 12:58:37.329: I/global(3159): Loaded time zone names for en in 368ms.
10-06 12:58:37.709: I/global(3159): Loaded time zone names for en in 370ms.
10-06 12:58:38.149: I/global(3159): Loaded time zone names for en in 403ms.
10-06 12:58:38.589: I/global(3159): Loaded time zone names for en in 420ms.
10-06 12:58:39.039: I/global(3159): Loaded time zone names for en in 446ms.
10-06 12:58:39.449: I/global(3159): Loaded time zone names for en in 393ms.
10-06 12:58:39.859: I/global(3159): Loaded time zone names for en in 396ms.
10-06 12:58:40.269: I/global(3159): Loaded time zone names for en in 401ms.
10-06 12:58:40.749: I/global(3159): Loaded time zone names for en in 459ms.
10-06 12:58:41.159: I/global(3159): Loaded time zone names for en in 404ms.
10-06 12:58:41.549: I/global(3159): Loaded time zone names for en in 380ms.
10-06 12:58:41.919: I/global(3159): Loaded time zone names for en in 366ms.
10-06 12:58:42.289: I/global(3159): Loaded time zone names for en in 363ms.
10-06 12:58:42.659: I/global(3159): Loaded time zone names for en in 368ms.
10-06 12:58:43.109: I/global(3159): Loaded time zone names for en in 437ms.
10-06 12:58:43.489: I/global(3159): Loaded time zone names for en in 377ms.
10-06 12:58:43.879: I/global(3159): Loaded time zone names for en in 387ms.
10-06 12:58:44.279: I/global(3159): Loaded time zone names for en in 387ms.
10-06 12:58:44.649: I/global(3159): Loaded time zone names for en in 367ms.
10-06 12:58:45.029: I/global(3159): Loaded time zone names for en in 379ms.
10-06 12:58:45.469: I/global(3159): Loaded time zone names for en in 438ms.
I realize that there is an issue with the SimpleDateFormat
class as described in this question, and it looks like the RssParser.getDate() function uses it to extract the date from the RSS feed.
These statements seem to happen right after I load the feed, i.e.:
RssParser rss = new RssParser();
RssFeed feed = rss.load("some feed url");
// This is where the log statements begin appearing.
I can understand why they would be logged once, on the first call to SimpleDateFormat
. But does anyone know why these statements are being logged over and over again, and how I can prevent them? They're making my app impossible to run as half the time the Android system deems it too resource intensive and kills it before the UI is even loaded.
If the time zone names were only loaded once on the first call to SimpleDateFormat
then it would be perfectly acceptable. But every single time I load an RSS feed I get dozens of these logs. Is there a way to turn the cache on or something??
Any help would be greatly appreciated. I'm basically dead in the water till I can figure this out.
Update: I have submitted an issue to the HorrorRSS project to make their RssParser.getDate() method protected or public. Then, I will be able to provide my own implementation that uses something like JodaTime. I think this will work. Any thoughts?
回答1:
I ended up importing the HorroRSS source tree into mine and modifying the RssParser
class so that RssParser.getDate()
is protected. I then added my ownRssParser
subclass which overrides RssParser.getDate()
using my own DateParser
utility class that uses JodaTime:
@Override
protected Date getDate(String dateString, int rssType)
{
return DateParser.getDate(dateString, rssType);
}
The maintainer of HorroRSS is going to modify RssParser
to accept a custom date parser implementation, so in the future no modification of vendor code is necessary. My modifications are merely a stop-gap till then.
来源:https://stackoverflow.com/questions/12762478/android-loaded-time-zone-names-for-en-in-ms