示例#1
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    RobotEntity entity = entities.get(position);
    int type = entity.getType();
    ViewHolder holder = new ViewHolder();
    // if(convertView==null){
    if (type == RobotEntity.RECEIVER)
      convertView = mInflater.inflate(R.layout.list_item_robot_left, null);
    else if (type == RobotEntity.SEND)
      convertView = mInflater.inflate(R.layout.list_item_robot_right, null);
    holder.tv_content = (TextView) convertView.findViewById(R.id.tv_chatcontent);
    holder.tv_name = (TextView) convertView.findViewById(R.id.tv_username);
    holder.tv_time = (TextView) convertView.findViewById(R.id.tv_sendtime);
    holder.head_photo = (CircularImage) convertView.findViewById(R.id.head_photo);
    convertView.setTag(holder);
    //	}else {
    holder = (ViewHolder) convertView.getTag();
    //	}
    if (entities.get(position).getType() == RobotEntity.RECEIVER) {
      holder.head_photo.setImageResource(R.drawable.logo);
      holder.tv_name.setText("СÁµ");
    } else {
      bais = editPhoto();
      holder.head_photo.setImageDrawable(
          Drawable.createFromStream(bais, entities.get(position).getPhoto()));
      String name = sp.getString("username", "");
      if (name != null) {
        holder.tv_name.setText(name);
      } else holder.tv_name.setText("ÁµÁµ");
    }
    holder.tv_content.setText(entities.get(position).getContent());

    holder.tv_time.setText(entities.get(position).getTime());
    return convertView;
  }
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    if (convertView == null) {
      holder = new ViewHolder();
      convertView = LayoutInflater.from(context).inflate(R.layout.item_history_list, null);
      holder.ll = (LinearLayout) convertView.findViewById(R.id.ll);
      holder.iv_icon = (ImageView) convertView.findViewById(R.id.iv_icon);
      holder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
      holder.tv_content = (TextView) convertView.findViewById(R.id.tv_content);
      holder.btn_share = (Button) convertView.findViewById(R.id.btn_share);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }
    if (historyList.get(getCount() - position - 1).getType() == 1) {
      holder.iv_icon.setImageResource(R.drawable.browser_icon);
      // holder.tv_title.setText( context.getString( R.string.string_interlinkage ) );
    } else {
      holder.iv_icon.setImageResource(R.drawable.text_icon);
      // holder.tv_title.setText( context.getString( R.string.string_text ) );
    }
    holder.tv_title.setText(historyList.get(getCount() - position - 1).getCurrtime());
    holder.tv_content.setText(historyList.get(getCount() - position - 1).getText());
    holder.ll.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (historyList.get(getCount() - position - 1).getType() == 1) {
              Uri uri = Uri.parse(historyList.get(getCount() - position - 1).getText());
              Intent intent = new Intent(Intent.ACTION_VIEW, uri);
              context.startActivity(intent);
            } else {
              AlertDialog.Builder builder = new Builder(context);
              builder.setMessage(historyList.get(getCount() - position - 1).getText());
              builder.setTitle(context.getResources().getString(R.string.string_text));
              builder.setNegativeButton(android.R.string.ok, null);
              AlertDialog dialog = builder.create();
              dialog.show();
            }
          }
        });
    holder.btn_share.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Log.v("QrCode", "share click");
            Intent shareIntent = new Intent(Intent.ACTION_SEND);
            shareIntent.setType("text/plain");
            shareIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.share_title));
            shareIntent.putExtra(
                Intent.EXTRA_TEXT, historyList.get(getCount() - position - 1).getText());
            shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(shareIntent);
          }
        });
    return convertView;
  }
示例#3
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder h = null;
      if (convertView == null) {
        convertView =
            LayoutInflater.from(getActivity()).inflate(R.layout.item_lv_acty_messagecenter, null);
        h = new ViewHolder();
        h.iv_avatar = (ImageView) convertView.findViewById(R.id.iv_avatar);
        h.tv_username = (TextView) convertView.findViewById(R.id.tv_username);
        h.tv_content = (TextView) convertView.findViewById(R.id.tv_content);
        h.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
        h.tv_unreadCount = (TextView) convertView.findViewById(R.id.tv_unreadcount);
        convertView.setTag(h);
      } else {
        h = (ViewHolder) convertView.getTag();
      }
      MMessage mm = data_message.get(position);

      if (mm.getSenderavatar() != null) {
        ImageLoader.getInstance()
            .displayImage(RestClient.BASE_URL + mm.getSenderavatar(), h.iv_avatar);
      } else {
        ImageLoader.getInstance()
            .displayImage("drawalbe://" + R.drawable.ic_image_load_normal, h.iv_avatar);
      }
      h.tv_content.setText(mm.getBody());
      h.tv_username.setText(mm.getSendername());
      h.tv_time.setText(
          CalendarUtils.getTimeFromat(
              data_message.get(position).getSendtime(), CalendarUtils.TYPE_timeline));
      h.tv_unreadCount.setVisibility(View.GONE);

      if (mm.getSenderid() == 8) { // 系统消息
        h.tv_username.setTextColor(getResources().getColor(R.color.blue_lv_two));
      } else {
        h.tv_username.setTextColor(getResources().getColor(R.color.black));
      }
      if (mm.getUnreadcount() > 0) {
        h.tv_unreadCount.setText(mm.getUnreadcount() + "");
        h.tv_unreadCount.setVisibility(View.VISIBLE);
      }
      return convertView;
    }
示例#4
0
  @Override
  public View getView(int position, View layout, ViewGroup parent) {
    ViewHolder holder = null;
    if (layout == null) {
      holder = new ViewHolder();
      layout = activity.getLayoutInflater().inflate(R.layout.item_craft_value, null);
      holder.tv_content = (TextView) layout.findViewById(R.id.tv_content);
      holder.tv_name = (TextView) layout.findViewById(R.id.tv_name);
      holder.tv_time = (TextView) layout.findViewById(R.id.tv_time);
      layout.setTag(holder);
    } else {
      holder = (ViewHolder) layout.getTag();
    }
    Comment comment = commentList.get(position);
    holder.tv_content.setText(comment.getAdvise());
    holder.tv_time.setText(comment.getTime());

    holder.tv_name.setText(comment.getComment_craftsman_name());
    return layout;
  }
示例#5
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
      holder = new ViewHolder();
      convertView = LayoutInflater.from(context).inflate(R.layout.list_item_layout, null);
      convertView.setTag(holder);

      holder.iv_poster = (ImageView) convertView.findViewById(R.id.iv_poster);
      holder.tv_content = (TextView) convertView.findViewById(R.id.tv_content);

    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    //    Picasso.with(context).load(items.get(position).url).into(holder.iv_poster);
    //    ImageLoader.getInstance().displayImage(items.get(position).url,holder.iv_poster);
    PicassoUtils.displayImage(context, items.get(position).url, holder.iv_poster);

    holder.tv_content.setText(items.get(position).who);

    return convertView;
  }
示例#6
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    final ViewHolder holder;
    View view = convertView;
    if (view == null) {
      view = inflater.inflate(R.layout.item_snippet_fragment2, null);
      holder = new ViewHolder();
      holder.iv_head_pic = (ImageView) view.findViewById(R.id.iv_head_pic);
      holder.iv_pic = (ImageView) view.findViewById(R.id.iv_pic);
      holder.tv_nickname = (TextView) view.findViewById(R.id.tv_nickname);
      holder.tv_publish_time = (TextView) view.findViewById(R.id.tv_publish_time);
      holder.tv_content = (TextView) view.findViewById(R.id.tv_content);
      holder.tv_ding = (TextView) view.findViewById(R.id.tv_ding);
      holder.tv_cai = (TextView) view.findViewById(R.id.tv_cai);
      holder.tv_comments_num = (TextView) view.findViewById(R.id.tv_comments_num);
      holder.iv_ding = (ImageView) view.findViewById(R.id.iv_ding);
      holder.iv_cai = (ImageView) view.findViewById(R.id.iv_cai);
      holder.iv_pinglun = (ImageView) view.findViewById(R.id.iv_pinglun);
      holder.iv_fenxiang = (ImageView) view.findViewById(R.id.iv_fenxiang);
      holder.rl_ding = (LinearLayout) view.findViewById(R.id.rl_ding);
      holder.rl_cai = (LinearLayout) view.findViewById(R.id.rl_cai);
      holder.rl_comments_num = (LinearLayout) view.findViewById(R.id.rl_comments_num);
      holder.rl_fenxiang = (LinearLayout) view.findViewById(R.id.rl_fenxiang);
      holder.iv_null = (ImageView) view.findViewById(R.id.iv_null);
      view.setTag(holder);
    } else {
      holder = (ViewHolder) view.getTag();
    }

    holder.iv_cai.setImageResource(R.drawable.img_cai);
    holder.iv_ding.setImageResource(R.drawable.img_ding);

    final Snippet snippet = getItem(position);
    holder.tv_publish_time.setText(snippet.getCreate_time());
    holder.tv_nickname.setText(snippet.getUsername());
    holder.tv_content.setText(snippet.getText());
    // 为啥�?
    //		title = getItem(position+1).getTitle();
    holder.tv_ding.setText(snippet.getDing());
    /** */
    final String dingStr = snippet.getDing();
    final String caiStr = snippet.getCai();
    holder.tv_cai.setText(snippet.getCai());
    holder.tv_comments_num.setText(snippet.getComments_count());
    String headPicPath = snippet.getUser_pic();
    final String picPath = snippet.getPic_url();

    if (!TextUtils.isEmpty(headPicPath)) {
      imageLoader.displayImage(headPicPath, holder.iv_head_pic, optionsCircle);
    } else {
      holder.iv_head_pic.setImageResource(R.drawable.img_square_logo);
    }
    if (!snippet.getUserid().isEmpty()) {
      holder.iv_head_pic.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              if (TextUtils.isEmpty(snippet.getUserid())) {
                Log.i("message", "userId is null");
              } else {
                Intent intent = new Intent(context, HeadClientInfoActivity.class);
                intent.putExtra("ttkeid", snippet.getUserid());
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(intent);
              }
            }
          });
    }

    // 71dp
    // 21dp
    if (!TextUtils.isEmpty(picPath)) {
      holder.iv_pic.setVisibility(View.VISIBLE);
      String widthStr = snippet.getWidth();
      String heightStr = snippet.getHeight();
      float width = Float.parseFloat(widthStr);
      float height = Float.parseFloat(heightStr);
      // 卧槽,得计算
      float pxWidth = ScreenSizeUtil.getScreenWidth(context);
      int actualDpWidth = ScreenSizeUtil.Px2Dp(context, pxWidth) - 92;
      float actualDpHeight = (float) actualDpWidth * height / width;
      int actualWidth = ScreenSizeUtil.Dp2Px(context, actualDpWidth);
      int actualHeight = ScreenSizeUtil.Dp2Px(context, actualDpHeight);
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(actualWidth, (int) actualHeight);
      int leftMargin = ScreenSizeUtil.Dp2Px(context, 65);
      int rightMargin = ScreenSizeUtil.Dp2Px(context, 15);
      params.setMargins(leftMargin, 0, rightMargin, 0);
      holder.iv_pic.setLayoutParams(params);
      System.out.println("-----------段子图片" + picPath);
      imageLoader.displayImage(picPath, holder.iv_pic, options2);

      holder.iv_pic.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              Intent intent = new Intent(context, PicActivity.class);
              intent.putExtra("picurl", picPath);
              intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              context.startActivity(intent);
            }
          });

    } else {
      holder.iv_pic.setVisibility(View.GONE);
    }
    final String infoid = snippet.getInfoid();
    /** 点击事件 */
    holder.rl_ding.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {

            new Thread(
                    new Runnable() {
                      @Override
                      public void run() {
                        String result = HttpData.snippetDingOrCai(infoid, "1");
                        if (!TextUtils.isEmpty(result)) {
                          String resultCode = JSONUtil.resolveJson(result, "statuses_code");
                          if (resultCode.equals("10001")) {
                            flagDing = false;
                            int dingCount = Integer.parseInt(dingStr);
                            int dingCountAfter = dingCount + 1;
                            final String dingStr = String.valueOf(dingCountAfter);
                            holder.tv_ding.post(
                                new Runnable() {
                                  @Override
                                  public void run() {
                                    holder.tv_ding.setText(dingStr);
                                    holder.iv_ding.setImageResource(R.drawable.img_ding_color);
                                    holder.rl_ding.setClickable(false);
                                  }
                                });
                          }
                        } else {
                        }
                      }
                    })
                .start();
          }
        });

    /** */
    holder.rl_cai.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {

            new Thread(
                    new Runnable() {
                      @Override
                      public void run() {
                        String result = HttpData.snippetDingOrCai(infoid, "2");
                        if (!TextUtils.isEmpty(result)) {
                          String resultCode = JSONUtil.resolveJson(result, "statuses_code");
                          if (resultCode.equals("10001")) {
                            flagCai = false;
                            int caiCount = Integer.parseInt(caiStr);
                            int caiCountAfter = caiCount + 1;
                            final String caiStr = String.valueOf(caiCountAfter);
                            holder.tv_cai.post(
                                new Runnable() {
                                  @Override
                                  public void run() {
                                    holder.tv_cai.setText(caiStr);
                                    holder.iv_cai.setImageResource(R.drawable.img_cai_color);
                                    holder.rl_cai.setClickable(false);
                                  }
                                });
                          }
                        } else {
                        }
                      }
                    })
                .start();
          }
        });

    holder.rl_comments_num.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Intent intent = new Intent(context, PicturesCommentsActivity.class);
            intent.putExtra("id", snippet.getInfoid());
            intent.putExtra("title", snippet.getText());
            context.startActivity(intent);
          }
        });

    holder.rl_fenxiang.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            title = snippet.getText();
            picContent = snippet.getPic_url();
            webUrl = snippet.getWeb_url();
            showShare(false, null, false);
          }
        });

    return view;
  }