【问题标题】:Android "Loaded time zone names for en in __ms."Android“在 __ms 内加载 en 的时区名称。”
【发布时间】:2012-10-06 18:14:16
【问题描述】:

我正在编写的应用程序使用 HorrorRSS library 加载 RSS 提要。我面临的问题是,查看日志时我看到了大量的垃圾:

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.

我意识到SimpleDateFormat 类存在问题,如this question 中所述,它看起来像RssParser.getDate() function uses it to extract the date from the RSS feed

这些语句似乎在我加载提要后立即发生,即:

RssParser rss = new RssParser();
RssFeed feed = rss.load("some feed url");
// This is where the log statements begin appearing.

我可以理解为什么他们会在第一次调用SimpleDateFormat 时被记录一次。但是有谁知道为什么这些语句被一遍又一遍地记录下来,以及如何防止它们?他们让我的应用程序无法运行,因为 Android 系统认为它过于占用资源并在加载 UI 之前将其终止。

如果时区名称在第一次调用SimpleDateFormat 时只加载一次,那么这是完全可以接受的。但是每次我加载一个 RSS 提要都会得到几十个这样的日志。有没有办法打开缓存之类的??

任何帮助将不胜感激。在我弄清楚这一点之前,我基本上已经死在水中了。

更新:我已向 HorrorRSS 项目提交了一个问题,以使他们的 RssParser.getDate() 方法受保护或公开。然后,我将能够提供我自己的使用 JodaTime 之类的实现。我认为这会奏效。有什么想法吗?

【问题讨论】:

    标签: java android rss simpledateformat


    【解决方案1】:

    我最终将 HorroRSS 源代码树导入我的并修改 RssParser 类以保护 RssParser.getDate()。然后我添加了我自己的RssParser 子类,它使用我自己的使用 JodaTime 的DateParser 实用程序类覆盖RssParser.getDate()

    @Override    
    protected Date getDate(String dateString, int rssType)
    {
         return DateParser.getDate(dateString, rssType);
    }
    

    HorroRSS 的维护者将修改RssParser 以接受自定义日期解析器实现,因此将来无需修改供应商代码。在此之前,我的修改只是权宜之计。

    【讨论】:

      猜你喜欢
      • 2011-04-23
      • 1970-01-01
      • 2019-09-21
      • 2013-12-05
      • 1970-01-01
      • 2011-11-03
      • 1970-01-01
      • 1970-01-01
      • 2013-08-17
      相关资源
      最近更新 更多