Esempio n. 1
0
 private void loadFeed(ParserType type, String feedUrl) {
   try {
     FeedParser parser = FeedParserFactory.getParser(type, feedUrl);
     long start = System.currentTimeMillis();
     messages = parser.parse();
     long duration = System.currentTimeMillis() - start;
     Log.i("AndroidNews", "Parser duration=" + duration);
     String xml = writeXml();
     Log.i("AndroidNews", xml);
     List<String> titles = new ArrayList<String>(messages.size());
     String html =
         "<html><head><meta charset=\"utf-8\" />"
             + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /></head>"
             + "<body style=\"text-align:justify;color:#222;margin:0;padding:10px;line-height:normal\">"
             + "<style type=\"text/css\">"
             + "a {color: #333;text-decoration:underline;} h2 a {color: #005074;text-decoration:none;} h2 {margin: 15px 0 0 0;font-size: 1.4em;font-weight:normal} "
             + "ul, li {list-style:none;margin: 5px 0;padding:0;clear:both} "
             + "em {color: #666;font-style:normal;font-size:0.9em;} img {float:left; margin: 0 5px 0 0;}"
             + "</style>"
             + "<ul>";
     for (Message msg : messages) {
       titles.add(msg.getTitle());
       html +=
           "<li>"
               + "<h2><a href=\""
               + msg.getLink()
               + "\">"
               + msg.getTitle()
               + "</a></h2>"
               + "<div style=\"padding:3px 0;\"><em>"
               + msg.getDate()
               + "</em></div>"
               + msg.getDescription()
               + "</li>";
     }
     html += "</ul></body></html>";
     wvContent.loadData(html, "text/html;charset=utf-8", "utf-8");
   } catch (Throwable t) {
     Log.e("AndroidNews", t.getMessage(), t);
   }
 }