コード例 #1
0
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    if (convertView == null || convertView.getTag() == null) {
      convertView = LayoutInflater.from(mContext).inflate(R.layout.listitem_centerpet, null);
      holder = new ViewHolder(convertView);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }
    PetObject pet = getItem(position);
    if (pet != null) {
      if (!CommonTextUtils.isEmpty(pet.getIcoUrl())) {
        FrescoHelper.displayImageview(
            holder.petImg,
            pet.getIcoUrl() + CommonUtils.getAvatarSize(mContext),
            R.drawable.avatar_default_image,
            mContext.getResources(),
            true);
      }
      if (!CommonTextUtils.isEmpty(pet.getGender())) {
        if (pet.getGender().equals("0")) {
          holder.petSex.setBackgroundResource(R.drawable.pet_bitch);
        } else {
          holder.petSex.setBackgroundResource(R.drawable.pet_dog);
        }
      }
      if (!CommonTextUtils.isEmpty(pet.getName())) {
        holder.petName.setText(pet.getName());
      }

      if (!CommonTextUtils.isEmpty(pet.getCategoryName())) {
        holder.petCategory.setText(pet.getCategoryName());
      }
      if (!CommonTextUtils.isEmpty(pet.getBirthday())) {
        holder.petBirthday.setText(CommonUtils.getPetAge(mContext, pet.getBirthday()));
      }
    }
    return convertView;
  }
コード例 #2
0
  public View getView(final int position, View view, ViewGroup arg2) {
    ViewHolder viewHolder = null;
    final PetStyleObject mContent = list.get(position);
    if (view == null) {
      viewHolder = new ViewHolder();
      view = LayoutInflater.from(mContext).inflate(R.layout.listitem_petcategory, null);
      viewHolder.name = (TextView) view.findViewById(R.id.itemcategory_name);
      viewHolder.toptitle = (TextView) view.findViewById(R.id.itemcategory_toptitle);
      viewHolder.img = (SimpleDraweeView) view.findViewById(R.id.itemcategory_image);
      view.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) view.getTag();
    }

    // 根据position获取分类的首字母的char ascii值
    int section = getSectionForPosition(position);

    // 如果当前位置等于该分类首字母的Char的位置 ,则认为是第一次出现
    if (position == getPositionForSection(section)) {
      viewHolder.toptitle.setVisibility(View.VISIBLE);
      viewHolder.toptitle.setText(mContent.getSpell());
    } else {
      viewHolder.toptitle.setVisibility(View.GONE);
    }
    if (!TextUtils.isEmpty(this.list.get(position).getName())) {
      viewHolder.name.setText(this.list.get(position).getName());
    }
    if (!CommonTextUtils.isEmpty(this.list.get(position).getIcoUrl())) {
      FrescoHelper.displayImageview(
          viewHolder.img,
          this.list.get(position).getIcoUrl() + CommonUtils.getAvatarSize(mContext),
          R.drawable.avatar_default_image,
          mContext.getResources(),
          true);
    }
    return view;
  }
コード例 #3
0
  // 实现setContentView方法
  @Override
  public void setContentView(View contentView, int position, HorizontalScrollView parent) {
    SimpleDraweeView userimg =
        (SimpleDraweeView) contentView.findViewById(R.id.petdiartycomment_userimg);
    TextView timeTv = (TextView) contentView.findViewById(R.id.petdiartycomment_time);
    TextView contentTv = (TextView) contentView.findViewById(R.id.petdiartycomment_content);
    TextView voicenameTv = (TextView) contentView.findViewById(R.id.petdiartycomment_voice_name);
    PercentRelativeLayout voiceRL =
        (PercentRelativeLayout) contentView.findViewById(R.id.petdiartycomment_voice);
    ImageView voiceImg = (ImageView) contentView.findViewById(R.id.petdiartycomment_voiceimg);
    TextView voiceText = (TextView) contentView.findViewById(R.id.petdiartycomment_voicetext);
    CommontObject commentObj = (CommontObject) getItem(position);
    if (commentObj != null) {
      AccountObject account = commentObj.getAccount();
      String name = "";
      if (account != null) {
        if (!CommonTextUtils.isEmpty(account.getIcoUrl())) {
          FrescoHelper.displayImageview(
              userimg,
              account.getIcoUrl() + CommonUtils.getAvatarSize(mContext),
              R.drawable.avatar_default_image,
              mContext.getResources(),
              true);
        } else {
          Uri uri = Uri.parse("res://mobi.jzcx.android.chongmi/" + R.drawable.avatar_default_image);
          userimg.setImageURI(uri);
        }
        name = account.getNickName();
      }
      if (!CommonTextUtils.isEmpty(commentObj.getTimeStamp())) {
        timeTv.setText(commentObj.getTimeStamp());
      } else {
        timeTv.setText("");
      }
      if (!CommonTextUtils.isEmpty(commentObj.getText())) {
        contentTv.setText(commentObj.getText());
      } else {
        contentTv.setText("");
      }
      // if (!CommonTextUtils.isEmpty(commentObj.getVoiceUrl())) {
      // voiceRL.setVisibility(View.VISIBLE);
      // contentTv.setVisibility(View.GONE);
      // } else {
      //
      // }
      voiceRL.setVisibility(View.GONE);
      contentTv.setVisibility(View.VISIBLE);
      if (!CommonTextUtils.isEmpty(name)) {
        voicenameTv.setText(name);
      } else {
        voicenameTv.setText("");
      }
      userimg.setOnClickListener(new userImgClick(account));

      // String localPath = FileUtils.VOICE +
      // DemoUtils.md5(commentObj.getVoiceUrl()) + ".amr";
      //
      // if (FileUtils.exists(localPath)) {
      // try {
      // long duration = CommonUtils.getAmrDuration(new File(localPath));
      // NumberFormat nf = NumberFormat.getNumberInstance();
      // nf.setMaximumFractionDigits(2);
      // voiceText.setText(nf.format(Double.valueOf(duration / 1000)));
      // } catch (IOException e) {
      // e.printStackTrace();
      // }
      // voiceRL.setOnClickListener(new VoicePlayClickListener(localPath,
      // voiceImg, this, mContext));
      // } else {
      // voiceText.setText("");
      // }
    }
  }