@Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder1 viewHolder1 = null;
    ViewHolder2 viewHolder2 = null;
    ViewHolder3 viewHolder3 = null;
    int type = getItemViewType(position);
    if (convertView == null) {
      switch (type) {
        case TYPE_ONE:
          viewHolder1 = new ViewHolder1();
          convertView = inflater.inflate(R.layout.item_topic1, null);
          viewHolder1.tv_tipic_flag = (TextView) convertView.findViewById(R.id.tv_tipic_flag);
          viewHolder1.iv_topic = (ImageView) convertView.findViewById(R.id.iv_topic);
          viewHolder1.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
          viewHolder1.tv_people = (TextView) convertView.findViewById(R.id.tv_people);
          viewHolder1.btn_join = (Button) convertView.findViewById(R.id.btn_join);
          convertView.setTag(viewHolder1);
          break;
        case TYPE_TWO:
          viewHolder2 = new ViewHolder2();
          convertView = inflater.inflate(R.layout.item_topic2, null);
          viewHolder2.tv_history = (TextView) convertView.findViewById(R.id.tv_history);
          viewHolder2.tv1 = (TextView) convertView.findViewById(R.id.tv1);
          viewHolder2.tv2 = (TextView) convertView.findViewById(R.id.tv2);
          viewHolder2.tv3 = (TextView) convertView.findViewById(R.id.tv3);
          viewHolder2.iv1 = (ImageView) convertView.findViewById(R.id.iv1);
          viewHolder2.iv2 = (ImageView) convertView.findViewById(R.id.iv2);
          viewHolder2.iv3 = (ImageView) convertView.findViewById(R.id.iv3);
          convertView.setTag(viewHolder2);
          break;
        case TYPE_THREE:
          viewHolder3 = new ViewHolder3();
          convertView = inflater.inflate(R.layout.item_topic3, null);
          viewHolder3.iv_cover = (ImageView) convertView.findViewById(R.id.iv_cover);
          viewHolder3.iv_user = (CircleImageView) convertView.findViewById(R.id.iv_user);
          viewHolder3.tv_user_name = (TextView) convertView.findViewById(R.id.tv_user_name);
          viewHolder3.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
          convertView.setTag(viewHolder3);
          break;
      }
    } else {
      switch (type) {
        case TYPE_ONE:
          viewHolder1 = (ViewHolder1) convertView.getTag();
          break;
        case TYPE_TWO:
          viewHolder2 = (ViewHolder2) convertView.getTag();
          break;
        case TYPE_THREE:
          viewHolder3 = (ViewHolder3) convertView.getTag();
          break;
      }
    }
    // data
    switch (type) {
      case TYPE_ONE:
        viewHolder1.tv_tipic_flag.setText(activityEntities.get(position).getTitle());
        viewHolder1.tv_time.setText("时间01.08-02.06");
        viewHolder1.tv_people.setText(
            "参与人数" + activityEntities.get(position).getActivityStats().getParticipator() + "人");
        ImageUtils.getInstance()
            .loadWebImage(
                mContext, viewHolder1.iv_topic, activityEntities.get(position).getImage());
        viewHolder1.btn_join.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {}
            });
        break;
      case TYPE_TWO:
        /*ImageUtils.getInstance().loadWebImage(mContext,viewHolder2.iv1,activityEntities.get(position).getImage());
        ImageUtils.getInstance().loadWebImage(mContext,viewHolder2.iv2,activityEntities.get(position+1).getImage());
        ImageUtils.getInstance().loadWebImage(mContext,viewHolder2.iv3,activityEntities.get(position+2).getImage());*/
        break;
      case TYPE_THREE:
        viewHolder3.tv_user_name.setText(
            userEntities.get(position - bundle.getInt("TYPE1_COUNT")).getLoginNickname());
        viewHolder3.tv_title.setText("#" + activityEntities.get(position).getTitle());
        ImageUtils.getInstance()
            .loadWebImage(
                mContext,
                viewHolder3.iv_user,
                userEntities.get(position - bundle.getInt("TYPE1_COUNT")).getLoginAvatar());
        if (postEntities.get(position - bundle.getInt("TYPE1_COUNT")).getMedia().size() > 1) {
          ImageUtils.getInstance()
              .loadWebImage(
                  mContext,
                  viewHolder3.iv_cover,
                  postEntities
                      .get(position - bundle.getInt("TYPE1_COUNT"))
                      .getMedia()
                      .get(1)
                      .getOriginalUrl());
        } else {
          ImageUtils.getInstance()
              .loadWebImage(
                  mContext,
                  viewHolder3.iv_cover,
                  activityEntities.get(position).getBackgroundImage());
        }
        break;
    }

    return convertView;
  }
Example #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;
  }
Example #3
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;
  }