Exemple #1
0
  @Override
  public View getView(final int position, View convertView, ViewGroup viewGroup) {
    ViewHolder holder = null;
    ViewHolder1 holder1 = null;
    int type = getItemViewType(position);
    if (type == type0) {
      convertView = null;
      if (convertView == null || !convertView.getTag().getClass().equals(ViewHolder.class)) {
        convertView = View.inflate(context, R.layout.groupdetail_head, null);
        holder = new ViewHolder();
        holder.icon = (CircleImageView) convertView.findViewById(R.id.groupdetail_icon);
        holder.name = (TextView) convertView.findViewById(R.id.groupdetail_name);
        holder.address = (TextView) convertView.findViewById(R.id.groupdetail_address);
        holder.num = (TextView) convertView.findViewById(R.id.groupdetail_num);
        holder.time = (TextView) convertView.findViewById(R.id.groupdetail_time);
        holder.content = (TextView) convertView.findViewById(R.id.groupdetail_content);
        holder.tip = (TextView) convertView.findViewById(R.id.groupdetail_tip);
        holder.join = (TextView) convertView.findViewById(R.id.groupdetail_join);
        holder.menu_lin = (LinearLayout) convertView.findViewById(R.id.groupdetail_menu_lin);
        holder.replay = (ImageView) convertView.findViewById(R.id.groupdetail_replay);
        holder.parimage = (ImageView) convertView.findViewById(R.id.groupdetail_parimage);
        holder.gridView = (MyGridView) convertView.findViewById(R.id.groupdetail_grid);
        convertView.setTag(holder);
      } else {
        holder = (ViewHolder) convertView.getTag();
      }
    } else if (type == type1) {
      if (convertView == null || !convertView.getTag().getClass().equals(ViewHolder1.class)) {
        convertView = View.inflate(context, R.layout.groupdetail_item, null);
        holder1 = new ViewHolder1();
        holder1.icon = (CircleImageView) convertView.findViewById(R.id.groupdetail_item_icon);
        holder1.name = (TextView) convertView.findViewById(R.id.groupdetail_item_name);
        holder1.content = (TextView) convertView.findViewById(R.id.groupdetail_item_content);
        holder1.time = (TextView) convertView.findViewById(R.id.groupdetail_item_time);
        holder1.reply = (TextView) convertView.findViewById(R.id.groupdetail_item_reply);
        holder1.del = (TextView) convertView.findViewById(R.id.groupdetail_item_del);
        convertView.setTag(holder1);
      } else {
        holder1 = (ViewHolder1) convertView.getTag();
      }
    }
    if (type == type0) {
      if (!entity.publishUserIcon.equals(holder.icon.getTag())) {
        holder.icon.setTag(entity.publishUserIcon);
        bitmapUtils.display(holder.icon, entity.publishUserIcon);
      }
      //            bitmapUtils.display(holder.icon, entity.publishUserIcon);
      holder.name.setText(entity.publishUserNickname);
      holder.address.setText(entity.locationName);
      holder.tip.setText(entity.topic);
      holder.num.setText("参团人数:" + entity.groupNum + "/" + entity.planPeopleNum);
      holder.time.setText("截止日期:" + entity.endDate);
      holder.content.setText(entity.detail);
      holder.join.setEnabled(true);
      holder.join.setClickable(true);
      if ("0".equals(entity.isInGroup)) {
        holder.join.setText("已参加进群聊");
      } else {
        holder.join.setText("参加");
        try {
          if ("0".equals(entity.applyState)
              && Integer.valueOf(entity.planPeopleNum) <= Integer.valueOf(entity.groupNum)) {
            holder.join.setText("活动关闭");
            holder.join.setEnabled(false);
            holder.join.setClickable(false);
          }
          if (!"0".equals(entity.state)) {
            holder.join.setText("活动关闭");
            holder.join.setEnabled(false);
            holder.join.setClickable(false);
          }
        } catch (Exception e) {

        }
      }

      holder.join.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (ToosUtils.CheckComInfo(context)) {
                handler.sendEmptyMessage(1112);
              }
            }
          });
      holder.icon.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Intent intent = new Intent(context, ConstactActivity.class);
              intent.putExtra("id", entity.publishUserId);
              intent.putExtra("name", entity.publishUserNickname);
              context.startActivity(intent);
            }
          });
      List<User> userList = entity.praiseUser;
      if (userList == null) {
        userList = new ArrayList<>();
      }
      GroupDetailGridViewAdapter gridAdapter = new GroupDetailGridViewAdapter(context, userList);
      holder.gridView.setAdapter(gridAdapter);

      if (userList.size() == 0) {
        holder.parimage.setVisibility(View.INVISIBLE);
      } else {
        holder.parimage.setVisibility(View.VISIBLE);
      }

      holder.replay.setTag("pppp" + position);
      rep = holder.replay;

      holder.replay.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (ToosUtils.CheckComInfo(context)) {
                if (menuWindow == null || menuWindow.isShowing() == false) {
                  menu_press();
                } else {
                  menuWindow.dismiss();
                }
              }
            }
          });

    } else if (type == type1) {
      if (!entities.get(position - 1).publishUserIcon.equals(holder1.icon.getTag())) {
        holder1.icon.setTag(entities.get(position - 1).publishUserIcon);
        bitmapUtils.display(holder1.icon, entities.get(position - 1).publishUserIcon);
      }

      if (ShareDataTool.getUserId(context).equals(entities.get(position - 1).publishUserId)) {
        entities.get(position - 1).publishUserNickname = "我";
      }

      if (ShareDataTool.getUserId(context).equals(entities.get(position - 1).targetUserId)) {
        entities.get(position - 1).targetUserNickname = "我";
      }

      if (ToosUtils.isStringEmpty(entities.get(position - 1).parentId)
          || entities.get(position - 1).parentId.equals(entity.id)) {
        holder1.name.setText(entities.get(position - 1).publishUserNickname);
      } else {
        holder1.name.setText(
            Html.fromHtml(
                entities.get(position - 1).publishUserNickname
                    + "\u2000<font color=\"#0076FF\">回复</font>\u2000"
                    + entities.get(position - 1).targetUserNickname));
      }
      //            if (ToosUtils.isStringEmpty(entities.get(position-1).targetUserId)){
      //                holder1.name.setText(entities.get(position - 1).publishUserNickname);
      //            }else{
      //                holder1.name.setText(entities.get(position -
      // 1).publishUserNickname+"\u2000回复\u2000"+entities.get(position-1).targetUserNickname);
      //            }
      if (ShareDataTool.getUserId(context).equals(entities.get(position - 1).publishUserId)) {
        holder1.del.setVisibility(View.VISIBLE);
        holder1.del.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                if (ToosUtils.CheckComInfo(context)) {
                  String temp = "是否删除该评论?";
                  if (ToosUtils.isStringEmpty(entities.get(position - 1).targetUserId)) {
                    temp = "是否删除该评论?";
                  } else {
                    temp = "是否删除该回复?";
                  }

                  CustomeDialog dialog =
                      new CustomeDialog(context, handler, temp, position - 1, -2, null);
                  //                        Message message=new Message();
                  //                        message.what=1009;
                  //                        message.arg1=(position-1);
                  //                        handler.sendMessage(message);
                }
              }
            });
      } else {
        holder1.del.setVisibility(View.GONE);
      }

      holder1.icon.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Intent intent = new Intent(context, ConstactActivity.class);
              intent.putExtra("id", entities.get(position - 1).publishUserId);
              intent.putExtra("name", entities.get(position - 1).publishUserNickname);
              context.startActivity(intent);
            }
          });

      holder1.content.setText(entities.get(position - 1).content);
      holder1.time.setText(entities.get(position - 1).createDate);
      holder1.reply.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (ToosUtils.CheckComInfo(context)) {
                Message message = new Message();
                message.what = 1005;
                message.arg1 = (position - 1);
                handler.sendMessage(message);
              }
            }
          });
    }
    return convertView;
  }
Exemple #2
0
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  @Override
  public View getView(final int position, View convertView, ViewGroup viewGroup) {
    ViewHolder holder = null;
    ViewHolder1 holder1 = null;
    int type = getItemViewType(position);
    if (type == type0) {
      convertView = null;
      if (convertView == null || !convertView.getTag().getClass().equals(ViewHolder1.class)) {
        convertView = View.inflate(context, R.layout.fwithfloor_head, null);
        holder1 = new ViewHolder1();
        holder1.serch = convertView.findViewById(R.id.fwithfloor_serch);
        holder1.group = (TextView) convertView.findViewById(R.id.fwithfloor_group);
        holder1.used = (TextView) convertView.findViewById(R.id.fwithfloor_used);
        holder1.pp = (TextView) convertView.findViewById(R.id.fwithfloor_pp);
        holder1.help = (TextView) convertView.findViewById(R.id.fwithfloor_help);
        convertView.setTag(holder1);
      } else {
        holder1 = (ViewHolder1) convertView.getTag();
      }
    } else if (type == type1) {
      if (convertView == null || !convertView.getTag().getClass().equals(ViewHolder.class)) {
        holder = new ViewHolder();
        convertView = View.inflate(context, R.layout.fwithfloor_item, null);
        holder.icon = (CircleImageView) convertView.findViewById(R.id.fwithfloor_item_icon);
        holder.name = (TextView) convertView.findViewById(R.id.fwithfloor_item_name);
        holder.tip = (TextView) convertView.findViewById(R.id.fwithfloor_item_tip);
        holder.content = (TextView) convertView.findViewById(R.id.fwithfloor_item_content);
        holder.bluebtn = convertView.findViewById(R.id.fwithfloor_item_bluebtn);
        holder.graybtn = convertView.findViewById(R.id.fwithfloor_item_graybtn);
        holder.bluetext = (TextView) convertView.findViewById(R.id.fwithfloor_item_bluetext);
        holder.blueimage = (ImageView) convertView.findViewById(R.id.fwithfloor_item_blueimage);
        holder.graytext = (TextView) convertView.findViewById(R.id.fwithfloor_item_graytext);
        holder.praise = (TextView) convertView.findViewById(R.id.fwithfloor_item_atten);
        holder.time = (TextView) convertView.findViewById(R.id.fwithfloor_item_time);
        convertView.setTag(holder);
      } else {
        holder = (ViewHolder) convertView.getTag();
      }
    }
    if (type == type0) {
      holder1.serch.setOnClickListener(this);
      holder1.group.setOnClickListener(this);
      holder1.used.setOnClickListener(this);
      holder1.pp.setOnClickListener(this);
      holder1.help.setOnClickListener(this);
    } else if (type == type1) {
      bitmapUtils.display(holder.icon, entities.get(position - 1).publishUserIcon);

      holder.name.setText(entities.get(position - 1).publishUserNickname);
      if ("0".equals(entities.get(position - 1).modelType)) {
        holder.content.setText("活动:" + entities.get(position - 1).detail);
      } else if ("1".equals(entities.get(position - 1).modelType)) {
        if ("0".equals(entities.get(position - 1).supplyType)) {
          holder.content.setText("转让:" + entities.get(position - 1).detail);
        } else {
          holder.content.setText("求购:" + entities.get(position - 1).detail);
        }

      } else if ("2".equals(entities.get(position - 1).modelType)) {
        if ("0".equals(entities.get(position - 1).supplyType)) {
          holder.content.setText("车主:" + entities.get(position - 1).detail);
        } else {
          holder.content.setText("乘客:" + entities.get(position - 1).detail);
        }
      } else if ("3".equals(entities.get(position - 1).modelType)) {
        if ("0".equals(entities.get(position - 1).supplyType)) {
          holder.content.setText("求帮:" + entities.get(position - 1).detail);
        } else {
          holder.content.setText("自荐:" + entities.get(position - 1).detail);
        }
      }
      holder.tip.setText(entities.get(position - 1).topic);
      holder.time.setText(entities.get(position - 1).createDate);
      //            if ("0".equals(entities.get(position-1).modelType) ||
      // !entities.get(position-1).publishUserId.equals(ShareDataTool.getUserId(context))) {
      holder.bluebtn.setBackgroundResource(R.drawable.blue_chat);
      holder.bluebtn.setClickable(true);
      holder.bluebtn.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              if (ToosUtils.CheckComInfo(context)) {
                if ("0".equals(entities.get(position - 1).modelType)) {
                  if ("0".equals(entities.get(position - 1).isInGroup)) {
                    Intent intent = new Intent(context, ChatActivity.class);
                    MessageInfo messageInfo = new MessageInfo();
                    messageInfo.receiverHeadUrl = entities.get(position - 1).id;
                    messageInfo.groupDynamicID = entities.get(position - 1).id;
                    messageInfo.receiverImUserName = entities.get(position - 1).imGroupId;
                    messageInfo.receiverNickName = entities.get(position - 1).groupName;
                    messageInfo.receiverUserId = entities.get(position - 1).imGroupId;
                    intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP);
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("info", messageInfo);
                    intent.putExtras(bundle);
                    context.startActivity(intent);
                  } else {
                    Message message = new Message();
                    message.what = HiGroupActivity.ADDGROUP;
                    message.arg1 = position - 1;
                    handler.sendMessage(message);
                  }
                } else {
                  Intent intent = new Intent(context, ChatActivity.class);
                  MessageInfo messageInfo = new MessageInfo();
                  messageInfo.receiverHeadUrl = entities.get(position - 1).publishUserIcon;
                  messageInfo.receiverImUserName = entities.get(position - 1).publishUserImUsername;
                  messageInfo.receiverNickName = entities.get(position - 1).publishUserNickname;
                  messageInfo.receiverUserId = entities.get(position - 1).publishUserId;
                  messageInfo.senderHeadUrl = ShareDataTool.getIcon(context);
                  messageInfo.senderImUserName = ShareDataTool.getImUsername(context);
                  messageInfo.senderUserId = ShareDataTool.getUserId(context);
                  messageInfo.senderNickName = ShareDataTool.getNickname(context);
                  Bundle bundle = new Bundle();
                  bundle.putSerializable("info", messageInfo);
                  intent.putExtras(bundle);
                  context.startActivity(intent);
                }
              }
            }
          });

      if ("1".equals(entities.get(position - 1).isInGroup)
          && "0".equals(entities.get(position - 1).modelType)) {
        if (ToosUtils.isStringEmpty(entities.get(position - 1).planPeopleNum)) {
          entities.get(position - 1).planPeopleNum = "0";
        }
        if (ToosUtils.isStringEmpty(entities.get(position - 1).groupNum)) {
          entities.get(position - 1).groupNum = "0";
        }
        if ("0".equals(entities.get(position - 1).applyState)
            && Integer.valueOf(entities.get(position - 1).planPeopleNum)
                <= Integer.valueOf(entities.get(position - 1).groupNum)) {
          holder.bluetext.setText("已关闭");
          holder.blueimage.setImageResource(R.mipmap.end);
          holder.bluebtn.setBackgroundResource(R.drawable.gray_atten);
          holder.bluebtn.setClickable(false);
          holder.bluebtn.setEnabled(false);
        } else {
          holder.bluetext.setText("加入");
          holder.blueimage.setImageResource(R.mipmap.add_chat);
        }

      } else {
        holder.bluetext.setText("聊聊");
        holder.blueimage.setImageResource(R.mipmap.myfloor_speak);
      }

      if (!"0".equals(entities.get(position - 1).state)) {
        holder.bluetext.setText("已关闭");
        holder.blueimage.setImageResource(R.mipmap.end);
        holder.bluebtn.setBackgroundResource(R.drawable.gray_atten);
        holder.bluebtn.setClickable(false);
        holder.bluebtn.setEnabled(false);
      }

      //            } else {
      //                holder.bluetext.setText("聊聊");
      //                holder.blueimage.setImageResource(R.mipmap.myfloor_speak);
      //                holder.bluebtn.setBackgroundResource(R.drawable.gray_atten);
      //                holder.bluebtn.setClickable(false);
      //            }

      //        holder.graybtn.setTag("graybtn"+position);
      //        holder.graytext.setTag("graytext"+position);
      if (Constant.ATTEN_OK.equals(entities.get(position - 1).isAttention)) {
        holder.graybtn.setBackgroundResource(R.drawable.gray_attened);
        holder.graytext.setText("已关注");
      } else {
        holder.graybtn.setBackgroundResource(R.drawable.gray_atten);
        holder.graytext.setText("关注");
      }
      holder.graybtn.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              //                    if (ToosUtils.CheckComInfo(context)) {
              //                        if
              // (!ShareDataTool.getUserId(context).equals(entities.get(position -
              // 1).publishUserId)) {
              Message message = new Message();
              message.what = WithFloorFragment.ATTEN;
              message.obj = position - 1;
              handler.sendMessage(message);
              //                        } else {
              //                            ToastUtils.displayShortToast(context, "不可以关注自己的发布!");
              //                        }
              //                    }
            }
          });

      holder.icon.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Intent intent = new Intent(context, ConstactActivity.class);
              intent.putExtra("id", entities.get(position - 1).publishUserId);
              intent.putExtra("name", entities.get(position - 1).publishUserNickname);
              context.startActivity(intent);
            }
          });
      holder.praise.setTag("praise" + (position - 1));
      holder.praise.setText(entities.get(position - 1).praiseNum);
      if (Constant.PRAISE_OK.equals(entities.get(position - 1).isPraise)) {
        holder.praise.setTextColor(Color.parseColor("#499EB8"));
        Drawable drawable = ContextCompat.getDrawable(context, R.mipmap.consult_atten_checked);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        holder.praise.setCompoundDrawables(drawable, null, null, null);

      } else {
        holder.praise.setTextColor(Color.parseColor("#B3B3B3"));
        Drawable drawable = ContextCompat.getDrawable(context, R.mipmap.consult_atten);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        holder.praise.setCompoundDrawables(drawable, null, null, null);
      }

      holder.praise.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              if (ToosUtils.CheckComInfo(context)) {
                Message message = new Message();
                message.what = WithFloorFragment.PRAISE;
                message.obj = position - 1;
                handler.sendMessage(message);
              }
            }
          });
    }
    return convertView;
  }
  @Override
  public View getView(final int position, View convertView, ViewGroup viewGroup) {
    ViewHolder holder = null;
    if (convertView == null) {
      convertView = View.inflate(context, R.layout.myfloorspeech_item, null);
      holder = new ViewHolder();
      holder.icon = (CircleImageView) convertView.findViewById(R.id.myfloorspeech_item_icon);
      holder.name = (TextView) convertView.findViewById(R.id.myfloorspeech_item_name);
      holder.tip = (TextView) convertView.findViewById(R.id.myfloorspeech_item_tip);
      holder.content = (TextView) convertView.findViewById(R.id.myfloorspeech_item_content);
      holder.bluebtn = convertView.findViewById(R.id.myfloorspeech_item_bluebtn);
      holder.blueimage = (ImageView) convertView.findViewById(R.id.myfloorspeech_item_blueimage);
      holder.bluetext = (TextView) convertView.findViewById(R.id.myfloorspeech_item_bluetext);
      holder.time = (TextView) convertView.findViewById(R.id.myfloorspeech_item_time);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    bitmapUtils.display(holder.icon, entities.get(position).publishUserIcon);
    holder.name.setText(entities.get(position).publishUserNickname);
    holder.tip.setText(entities.get(position).topic);
    holder.time.setText(entities.get(position).createDate);
    holder.content.setText(entities.get(position).detail);
    holder.bluebtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Message message = new Message();
            message.what = 1112;
            message.arg1 = position;
            handler.sendMessage(message);
          }
        });
    holder.bluebtn.setBackgroundResource(R.drawable.blue_chat);
    holder.bluebtn.setClickable(true);
    if ("1".equals(entities.get(position).isInGroup)
        && "0".equals(entities.get(position).modelType)) {
      if (ToosUtils.isStringEmpty(entities.get(position).planPeopleNum)) {
        entities.get(position).planPeopleNum = "0";
      }
      if (ToosUtils.isStringEmpty(entities.get(position).groupNum)) {
        entities.get(position).groupNum = "0";
      }
      if ("0".equals(entities.get(position).applyState)
          && Integer.valueOf(entities.get(position).planPeopleNum)
              <= Integer.valueOf(entities.get(position).groupNum)) {
        holder.bluetext.setText("已关闭");
        holder.blueimage.setImageResource(R.mipmap.end);
        holder.bluebtn.setBackgroundResource(R.drawable.gray_atten);
        holder.bluebtn.setClickable(false);
        holder.bluebtn.setEnabled(false);
      } else {
        holder.bluetext.setText("加入");
        holder.blueimage.setImageResource(R.mipmap.add_chat);
        holder.bluebtn.setClickable(true);
        holder.bluebtn.setEnabled(true);
      }

    } else {
      holder.bluetext.setText("聊聊");
      holder.blueimage.setImageResource(R.mipmap.myfloor_speak);
      holder.bluebtn.setClickable(true);
      holder.bluebtn.setEnabled(true);
    }

    if (!"0".equals(entities.get(position).state)) {
      holder.bluetext.setText("已关闭");
      holder.blueimage.setImageResource(R.mipmap.end);
      holder.bluebtn.setBackgroundResource(R.drawable.gray_atten);
      holder.bluebtn.setClickable(false);
      holder.bluebtn.setEnabled(false);
    }

    //        if ("0".equals(entities.get(position).modelType)&&
    // "1".equals(entities.get(position).isInGroup)){
    //            holder.bluetext.setText("进群聊");
    //            holder.blueimage.setImageResource(R.mipmap.add_chat);
    //        }else{
    //            holder.bluetext.setText("聊聊");
    //            holder.blueimage.setImageResource(R.mipmap.myfloor_speak);
    //        }

    holder.icon.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(context, ConstactActivity.class);
            intent.putExtra("id", entities.get(position).publishUserId);
            intent.putExtra("name", entities.get(position).publishUserNickname);
            context.startActivity(intent);
          }
        });
    LogManager.LogShow("----", flag + "----------", LogManager.ERROR);

    if (flag == 0) {
      holder.name.setVisibility(View.VISIBLE);
      holder.bluebtn.setVisibility(View.VISIBLE);
    } else {
      holder.name.setVisibility(View.GONE);
      holder.bluebtn.setVisibility(View.GONE);
    }

    return convertView;
  }