コード例 #1
0
  @SuppressLint("SetJavaScriptEnabled")
  @Override
  public View getView(int position, View contentView, ViewGroup parent) {
    info = this.getItem(position);
    View rowView = this.viewMap.get(position);
    if (rowView == null) {
      try {

        LayoutInflater inflater = ((Activity) this.getContext()).getLayoutInflater();
        rowView = inflater.inflate(R.layout.list_items, null);

        // 屏蔽转发
        rowView.findViewById(R.id.forwardCount).setVisibility(View.INVISIBLE);
        rowView.findViewById(R.id.forwardCount2).setVisibility(View.INVISIBLE);
        rowView.findViewById(R.id.forwardCount_img).setVisibility(View.INVISIBLE);
        rowView.findViewById(R.id.forwardCount2_img).setVisibility(View.INVISIBLE);

        TextView username = (TextView) rowView.findViewById(R.id.username);
        username.setText(info.getUser().getUserName());
        username.getPaint().setFakeBoldText(true);

        TextView blogText = (TextView) rowView.findViewById(R.id.comment);
        blogText.setText(
            new ShareActivity(context)
                .imgReplaceText(
                    blogText, info.getLiveBlog().getBlogContent(), context, false)); // 转换表情

        if (info.getLiveBlog().getBlogPic() != null
            && !"".equals(info.getLiveBlog().getBlogPic())) {
          WebView imgThumb = (WebView) rowView.findViewById(R.id.imgThumb);
          imgThumb.setVisibility(View.VISIBLE);
          imgThumb.setHorizontalScrollBarEnabled(false);
          imgThumb.setVerticalScrollBarEnabled(false);
          imgThumb.setFocusable(false);
          imgThumb.setBackgroundColor(0);
          imgThumb.getSettings().setJavaScriptEnabled(true);
          imgThumb.addJavascriptInterface(this, "miblogscript");

          // 在引解析缩略图地址
          String[] tempImgPath = info.getLiveBlog().getBlogPic().split(",");
          String thumbPic =
              info.getLiveBlog().getLargePic().replace(tempImgPath[0], tempImgPath[1]);
          info.getLiveBlog().setThumbPic(thumbPic);

          imgThumb.loadDataWithBaseURL(
              null,
              MyMethods.getHtmlWithA(
                  info.getLiveBlog().getLargePic(), info.getLiveBlog().getThumbPic()),
              "text/html",
              "UTF-8",
              null);

          ImageView pic = (ImageView) rowView.findViewById(R.id.pic);
          pic.setVisibility(View.VISIBLE);
        }

        if (info.getLiveBlog().getOrigBlog() != null) {
          TextView quote = (TextView) rowView.findViewById(R.id.quote);
          TextView quotename = (TextView) rowView.findViewById(R.id.quotename);

          rowView.findViewById(R.id.quotelayou).setVisibility(View.VISIBLE);
          rowView.findViewById(R.id.quote_bg1).setVisibility(View.VISIBLE);
          rowView.findViewById(R.id.quote_bg2).setVisibility(View.VISIBLE);
          quote.setText(
              new ShareActivity(context).imgReplaceText(quote, "被转发的内容", context, false)); // 转换表情

          quotename.setVisibility(View.VISIBLE);
          quotename.setText("名字需要重新定义");
          ShareActivity.otherUserInfo(quotename, 100, this.getContext());

          WebView iii = (WebView) rowView.findViewById(R.id.forwordimgThumb);
          iii.setHorizontalScrollBarEnabled(false);
          iii.setVerticalScrollBarEnabled(false);
          iii.setFocusable(false);
          iii.setBackgroundColor(Color.parseColor("#EEEEEE"));
          iii.getSettings().setJavaScriptEnabled(true);
          iii.addJavascriptInterface(this, "miblogscript");
          iii.loadDataWithBaseURL(
              null,
              MyMethods.getHtmlWithA(
                  info.getLiveBlog().getOrigBlog().getBlogPic(),
                  info.getLiveBlog().getOrigBlog().getLargePic()),
              "text/html",
              "UTF-8",
              null);

          //	TextView resendcount2 = (TextView) rowView.findViewById(R.id.forwardCount2);
          TextView replaycount2 = (TextView) rowView.findViewById(R.id.replyCount2);
          //	resendcount2.setText("11");
          replaycount2.setText("21");
        } else {
          rowView.findViewById(R.id.quotelayou).setVisibility(View.GONE);
          rowView.findViewById(R.id.quote_bg1).setVisibility(View.GONE);
          rowView.findViewById(R.id.quote_bg2).setVisibility(View.GONE);
        }

        TextView comefrom = (TextView) rowView.findViewById(R.id.comefrom);
        comefrom.setText(info.getLiveBlog().getSourceFrom());

        TextView time = (TextView) rowView.findViewById(R.id.time);
        time.setText(info.getLiveBlog().getCreateTime());

        rowView.findViewById(R.id.statCount).setVisibility(View.VISIBLE);
        // TextView resendcount = (TextView) rowView.findViewById(R.id.forwardCount);
        TextView replaycount = (TextView) rowView.findViewById(R.id.replyCount);
        // resendcount.setText(info.getLiveBlog().getForwardNum() + "");
        replaycount.setText(info.getLiveBlog().getCommentNum() + "");
        // 头像

        WebView imageView = (WebView) rowView.findViewById(R.id.ItemWebImage);
        imageView.getSettings().setJavaScriptEnabled(true);
        imageView.setBackgroundColor(Color.parseColor("#EEEEEE"));
        imageView.setHorizontalScrollBarEnabled(false);
        imageView.setVerticalScrollBarEnabled(false);
        imageView.setFocusable(false);
        imageView.loadDataWithBaseURL(
            null, MyMethods.getHtml(info.getUser().getUserPic()), "text/html", "UTF-8", null);
      } catch (Exception e) {
        e.printStackTrace();
      }
      viewMap.put(position, rowView);
    }
    return viewMap.get(position);
  }
コード例 #2
0
 public CharSequence getContent() {
   return MyMethods.charConversion(content);
 }