Example #1
0
  void showInfo(final RSSItem item) {
    img = (ImageView) findViewById(R.id.imgnews);
    img.setImageBitmap(null);
    TextView tit = (TextView) findViewById(R.id.txtinfotitle);
    parentLayout = (LinearLayout) findViewById(R.id.wvcontainer);
    txtcon = (WebView) findViewById(R.id.txtcontent);
    head =
        ""
            + "<html xmlns:fb=\"http://ogp.me/ns/fb#\">\n"
            + "<head>\n"
            + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"
            + "</head>\n"
            + "<body>"
            + "<p><div id=\"fb-root\"></div></p>"
            + "<script>"
            + "window.fbAsyncInit = function() {"
            + "FB.init({"
            + "appId      : '111569915535689', // App ID"
            + "status     : true, // check login status"
            + "cookie     : true, // enable cookies to allow the server to access the session"
            + "oauth      : true, // enable OAuth 2.0"
            + "xfbml      : true  // parse XFBML"
            + "});"
            + "};"
            + "</script>\n"
            + "<script src=\"http://connect.facebook.net/en_US/all.js#xfbml=1\"></script>";
    String loading = "";
    tail =
        "<p style=\"clear:both;\"><div id=\"facebook-comments-4159769\" class=\"facebook-comments inited\">"
            + "<fb:comments href=\""
            + item.getLink()
            + "\" num_posts=\"5\" width=\""
            + (txtcon.getWidth() * 80 / 100)
            + "\" colorscheme=\"dark\"></fb:comments>"
            + "</div></p>\n"
            + "</body></html>";

    txtcon.setWebViewClient(new FaceBookClient());
    txtcon.setWebChromeClient(new MyChromeClient());
    txtcon.getSettings().setJavaScriptEnabled(true);
    //    	txtcon.getSettings().setAppCacheEnabled(true);
    txtcon.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    txtcon.getSettings().setSupportMultipleWindows(true);
    txtcon.getSettings().setSupportZoom(true);
    txtcon.getSettings().setBuiltInZoomControls(true);
    txtcon.getSettings().setJavaScriptEnabled(true);
    txtcon.getSettings().setPluginsEnabled(true);
    txtcon.getSettings().setAllowFileAccess(true);

    tit.setText(item.getTitle());
    Uri u = Uri.parse(item.getLink());
    txtcon.loadDataWithBaseURL(
        u.getHost(),
        head + " " + item.getDescription() + loading + tail,
        "text/html",
        "UTF-8",
        null);
    new Thread(
            new Runnable() {
              String url = item.getEnclosure();
              RSSItem ite = item;

              public void run() {
                b = ImageDownloader.readImageByUrl(url);
                if (b == null)
                  handler.post(
                      new Runnable() {
                        public void run() {
                          img.setVisibility(View.GONE);
                        }
                      });
                else
                  handler.post(
                      new Runnable() {
                        public void run() {
                          img.setImageBitmap(b);
                        }
                      });
                final String s = getAdditionInfo(ite.getLink());
                handler.post(
                    new Runnable() {
                      public void run() {
                        Uri u = Uri.parse(item.getLink());
                        if (site != 4)
                          txtcon.loadDataWithBaseURL(
                              u.getHost(),
                              head + " " + ite.getDescription() + s + tail,
                              "text/html",
                              "UTF-8",
                              null);
                        else
                          txtcon.loadDataWithBaseURL(
                              u.getHost(), head + " " + s + tail, "text/html", "UTF-8", null);
                      }
                    });
              }
            })
        .start();
  }