Пример #1
0
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    ViewHolder vh;
    if (convertView == null) {
      vh = new ViewHolder();
      convertView = LayoutInflater.from(context).inflate(R.layout.track_fragment_item_item, null);
      vh.tv_user_sex = (TextView) convertView.findViewById(R.id.tv_user_sex);
      vh.tv_user_rank = (TextView) convertView.findViewById(R.id.tv_user_rank);
      vh.name = (TextView) convertView.findViewById(R.id.travel_fragment_item_name);
      vh.comment = (TextView) convertView.findViewById(R.id.travel_fragment_item_commend);
      vh.content = (TextView) convertView.findViewById(R.id.travel_fragment_item_content);
      vh.good = (TextView) convertView.findViewById(R.id.travel_fragment_item_good);
      vh.share = (TextView) convertView.findViewById(R.id.travel_fragment_item_share);
      vh.time = (TextView) convertView.findViewById(R.id.travel_fragment_item_time);
      vh.imageView = (CircleImageView) convertView.findViewById(R.id.travel_fragment_item_image);
      vh.largeimage = (ImageView) convertView.findViewById(R.id.travel_fragment_item_largeimage);
      vh.collect = (TextView) convertView.findViewById(R.id.travel_fragment_item_collection);
      vh.relayout = (RelativeLayout) convertView.findViewById(R.id.track_fragment_item_Relayout);
      vh.relayout2 = (RelativeLayout) convertView.findViewById(R.id.travel_fragment_item_Relayout);
      convertView.setTag(vh);
    } else {
      vh = (ViewHolder) convertView.getTag();
    }
    vh.relayout.setVisibility(View.GONE);
    vh.relayout2.setVisibility(View.VISIBLE);
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    ViewGroup.LayoutParams para;
    para = vh.largeimage.getLayoutParams();
    para.height = wm.getDefaultDisplay().getWidth() * 3 / 4;
    para.width = wm.getDefaultDisplay().getWidth();
    vh.largeimage.setLayoutParams(para);

    if ("1".equals(list.get(position).getSex())) {
      vh.tv_user_sex.setText("男");
      vh.tv_user_sex.setBackgroundResource(R.drawable.corner_view_left);
      vh.tv_user_rank.setBackgroundResource(R.drawable.corner_view_right);
    } else if ("2".equals(list.get(position).getSex())) {
      vh.tv_user_sex.setText("女");
      vh.tv_user_sex.setBackgroundResource(R.drawable.corner_view_left_sex);
      vh.tv_user_rank.setBackgroundResource(R.drawable.corner_view_right_sex);
    }
    vh.tv_user_rank.setText(list.get(position).getLevel().getLvName());
    vh.name.setText(list.get(position).getNickname());
    vh.share.setText(list.get(position).getShare());
    vh.good.setText(list.get(position).getPraise());
    vh.share.setText(list.get(position).getShare());

    vh.content.setText(SmileUtils.getSmiledText(context, list.get(position).getTitle()));
    vh.comment.setText(list.get(position).getComment());
    vh.time.setText(getStringTime(list.get(position).getModtime()));

    vh.collect.setText(list.get(position).getCollect());
    vh.imageView.setImageUrl(
        UrlPools.getFriendAvatarUrl(context, list.get(position).getUserid()), imageLoader);

    String url =
        UrlPools.QINIU + list.get(position).getImage().getSingle().getFileurl() + "-Thumb640";
    DisplayImageOptions options =
        new DisplayImageOptions.Builder()
            .showStubImage(R.drawable.imgurl) // 加载开始默认的图片
            .showImageForEmptyUri(R.drawable.imgurl) // url爲空會显示该图片,自己放在drawable里面的
            .showImageOnFail(R.drawable.imgurl) // 加载图片出现问题,会显示该图片
            .cacheInMemory() // 缓存用
            .cacheOnDisc() // 缓存用
            .build();
    imageLoader2.displayImage(url, vh.largeimage, options);
    vh.imageView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent intent = new Intent(context, UserDetailsActivity.class);
            intent.putExtra("friendid", list.get(position).getUserid());
            context.startActivity(intent);
          }
        });
    return convertView;
  }
Пример #2
0
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    ViewHolder vh;
    if (convertView == null) {
      vh = new ViewHolder();
      convertView = LayoutInflater.from(context).inflate(R.layout.hometrack_listview_item, null);
      vh.hometrack_title = (TextView) convertView.findViewById(R.id.hometrack_title);
      vh.hometrack_more = (TextView) convertView.findViewById(R.id.hometrack_more);
      vh.hometrack_realname = (TextView) convertView.findViewById(R.id.hometrack_realname);
      vh.hometrack_realname2 = (TextView) convertView.findViewById(R.id.hometrack_realname2);
      vh.hometrack_top = (TextView) convertView.findViewById(R.id.hometrack_top);
      vh.hometrack_top2 = (TextView) convertView.findViewById(R.id.hometrack_top2);
      vh.hometrack_ImageView = (ImageView) convertView.findViewById(R.id.hometrack_ImageView);
      vh.hometrack_ImageView2 = (ImageView) convertView.findViewById(R.id.hometrack_ImageView2);
      vh.headpic = (CircleImageView) convertView.findViewById(R.id.hometrack_headpic);
      vh.headpic2 = (CircleImageView) convertView.findViewById(R.id.hometrack_headpic2);
      vh.hometrack_layout1 = (RelativeLayout) convertView.findViewById(R.id.hometrack_layout1);
      vh.hometrack_layout2 = (RelativeLayout) convertView.findViewById(R.id.hometrack_layout2);

      convertView.setTag(vh);
    } else {
      vh = (ViewHolder) convertView.getTag();
    }
    DisplayImageOptions options =
        new DisplayImageOptions.Builder()
            .showStubImage(R.drawable.imgurl) // 加载开始默认的图片
            .showImageForEmptyUri(R.drawable.imgurl) // url爲空會显示该图片,自己放在drawable里面的
            .showImageOnFail(R.drawable.imgurl) // 加载图片出现问题,会显示该图片
            .cacheInMemory() // 缓存用
            .cacheOnDisc() // 缓存用
            .displayer(new RoundedBitmapDisplayer(2)) // 图片圆角显示,值为整数
            .build();
    vh.hometrack_title.setText(list.get(position).getTitle());
    if (list.get(position).getList().size() >= 1) {
      vh.hometrack_realname.setText(list.get(position).getList().get(0).getNickname());
      vh.hometrack_top.setText(list.get(position).getList().get(0).getTop());
      String url =
          UrlPools.QINIU
              + list.get(position).getList().get(0).getAtlas().getData().get(0).getFileurl()
              + "-Thumb640";
      imageLoader.displayImage(url, vh.hometrack_ImageView, options);
      vh.headpic.setImageUrl(
          UrlPools.getFriendAvatarUrl(context, list.get(position).getList().get(0).getUserid()),
          imageLoader2);
      vh.headpic.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              Intent intent = new Intent(context, UserDetailsActivity.class);
              intent.putExtra("friendid", list.get(position).getList().get(0).getUserid());
              context.startActivity(intent);
            }
          });
      vh.hometrack_ImageView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              Intent intent8 = new Intent(context, TrackDetailsActivity.class);
              intent8.putExtra("id", list.get(position).getList().get(0).getId());
              intent8.putExtra("userid", list.get(position).getList().get(0).getUserid());
              context.startActivity(intent8);
            }
          });
      if (list.get(position).getList().size() >= 2) {
        vh.hometrack_realname2.setText(list.get(position).getList().get(1).getNickname());
        vh.hometrack_top2.setText(list.get(position).getList().get(1).getTop());
        String url1 =
            UrlPools.QINIU
                + list.get(position).getList().get(1).getAtlas().getData().get(0).getFileurl()
                + "-Thumb640";
        imageLoader.displayImage(url1, vh.hometrack_ImageView2, options);
        vh.headpic2.setImageUrl(
            UrlPools.getFriendAvatarUrl(context, list.get(position).getList().get(1).getUserid()),
            imageLoader2);
        vh.headpic2.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                Intent intent = new Intent(context, UserDetailsActivity.class);
                intent.putExtra("friendid", list.get(position).getList().get(1).getUserid());
                context.startActivity(intent);
              }
            });
        vh.hometrack_ImageView2.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                Intent intent8 = new Intent(context, TrackDetailsActivity.class);
                intent8.putExtra("id", list.get(position).getList().get(1).getId());
                intent8.putExtra("userid", list.get(position).getList().get(1).getUserid());
                context.startActivity(intent8);
              }
            });
      } else if (list.get(position).getList().size() == 1) {
        vh.hometrack_layout2.setVisibility(View.GONE);
      }
    } else if (list.get(position).getList().size() <= 0) {
      vh.hometrack_layout1.setVisibility(View.GONE);
      vh.hometrack_layout2.setVisibility(View.GONE);
    }
    vh.hometrack_more.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent intent = new Intent(context, MyTrackActivity.class);
            intent.putExtra("Homeid", list.get(position).getId());
            context.startActivity(intent);
          }
        });

    return convertView;
  }