예제 #1
0
    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder;

      if (convertView == null) {
        convertView = inflater.inflate(R.layout.item_group, parent, false);
        holder = new ViewHolder();
        // holder.image_iv = (ImageView) convertView.findViewById(R.id.image_iv);
        holder.name_tv = (TextView) convertView.findViewById(R.id.name_tv);

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

      if (position < groups.size()) {
        Group group = getItem(position);

        holder.name_tv.setText(group.getName());
        holder.name_tv.setTextColor(getResources().getColor(android.R.color.black));
      } else {
        holder.name_tv.setText("Add new group");
        holder.name_tv.setTextColor(getResources().getColor(android.R.color.darker_gray));
      }

      return convertView;
    }
예제 #2
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

      ViewHolder holder;

      if (convertView == null) {
        convertView = inflater.inflate(R.layout.item_youtube_feed, parent, false);
        holder = new ViewHolder();
        holder.image_iv = (ImageView) convertView.findViewById(R.id.thumbnail_iv);
        holder.name_tv = (TextView) convertView.findViewById(R.id.name_tv);
        // holder.visible_sw = (SwitchCompat) convertView.findViewById(R.id.visible_sw);

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

      MediaFeed feed = getItem(position);

      holder.image_iv.setImageResource(R.drawable.ic_youtube_icon);
      if (feed.getThumbnail() != null)
        imageLoader.DisplayImage(feed.getThumbnail(), holder.image_iv);
      holder.name_tv.setText(feed.getName());
      // holder.visible_sw.setChecked(feed.isVisible());

      return convertView;
    }
예제 #3
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder vh = null;
      if (convertView == null) {
        convertView = View.inflate(MainActivity.this, R.layout.adapter_friend, null);
        vh = new ViewHolder();
        vh.first_word_tv = (TextView) convertView.findViewById(R.id.first_word);
        vh.name_tv = (TextView) convertView.findViewById(R.id.name);
        convertView.setTag(vh);
      } else {
        vh = (ViewHolder) convertView.getTag();
      }

      if (position > 0) {
        if (friends
            .get(position)
            .getLetter()
            .equals(friends.get(position - 1).getLetter())) { // 让相邻item的first_word_tv隐藏
          vh.first_word_tv.setVisibility(View.GONE);
        } else {
          vh.first_word_tv.setVisibility(View.VISIBLE);
        }
      } else {
        vh.first_word_tv.setVisibility(View.VISIBLE);
      }

      vh.name_tv.setText(friends.get(position).getName());
      vh.first_word_tv.setText(friends.get(position).getLetter());

      return convertView;
    }
예제 #4
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

      ViewHolder holder;

      if (convertView == null) {
        convertView =
            inflater.inflate(
                (getItemViewType(position) == 0
                    ? R.layout.item_youtube_search
                    : R.layout.item_twitter_search),
                parent,
                false);
        holder = new ViewHolder();
        holder.image_iv = (ImageView) convertView.findViewById(R.id.thumbnail_iv);
        holder.name_tv = (TextView) convertView.findViewById(R.id.name_tv);
        holder.screenName_tv = (TextView) convertView.findViewById(R.id.screen_name_tv);
        convertView.setTag(holder);
      } else {
        holder = (ViewHolder) convertView.getTag();
      }

      if (searchMode == Var.SEARCH_YOUTUBE) {
        YoutubeChannel feed = (YoutubeChannel) getItem(position);
        holder.image_iv.setImageResource(R.drawable.ic_youtube_icon);
        if (feed.getThumbnail() != null)
          imageLoader.DisplayImage(feed.getThumbnail(), holder.image_iv);

        holder.name_tv.setText(feed.getName());
      }

      if (searchMode == Var.SEARCH_TWITTER) {
        TwitterFeed feed = (TwitterFeed) getItem(position);
        holder.image_iv.setImageResource(R.drawable.ic_twitter_icon);
        if (feed.getThumbnail() != null)
          imageLoader.DisplayImage(feed.getThumbnail(), holder.image_iv);

        holder.name_tv.setText(feed.getDisplayName());
        holder.screenName_tv.setText(feed.getName());
      }

      if (searchMode == Var.SEARCH_YT_CHANNEL) {
        YoutubeFeed feed = (YoutubeFeed) getItem(position);
        holder.image_iv.setImageResource(R.drawable.ic_youtube_icon);
        if (feed.getThumbnail() != null)
          imageLoader.DisplayImage(feed.getThumbnail(), holder.image_iv);

        holder.name_tv.setText(feed.getName());
      }

      return convertView;
    }
예제 #5
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    ViewHolder holder;
    if (convertView == null) {
      convertView = minflater.inflate(R.layout.item_fanslist, null);
      holder = new ViewHolder();
      holder.name_tv = (TextView) convertView.findViewById(R.id.name_fans_tv);
      holder.distance_tv = (TextView) convertView.findViewById(R.id.distance_fans_tv);
      holder.time_tv = (TextView) convertView.findViewById(R.id.time_fans_tv);
      holder.age_tv = (TextView) convertView.findViewById(R.id.age_fans_tv);
      holder.height_tv = (TextView) convertView.findViewById(R.id.height_fans_tv);
      holder.weight_tv = (TextView) convertView.findViewById(R.id.weight_fans_tv);
      holder.sign_tv = (TextView) convertView.findViewById(R.id.sign_fans_tv);
      holder.head_img = (ImageView) convertView.findViewById(R.id.head_fans_img);
      holder.sex_img = (ImageView) convertView.findViewById(R.id.sex_fans_img);
      // holder.ll=(LinearLayout)convertView.findViewById(R.id.ll);
      convertView.setTag(holder); // 绑定ViewHolder对象
    } else {
      holder = (ViewHolder) convertView.getTag(); // 取出ViewHolder对象
    }
    final Followers back = followers.get(position);
    try {
      if (back != null) {
        long data = new Date().getTime();
        if (back.getAvatar_middle() != null) {
          fb.display(holder.head_img, back.getAvatar_middle() + "#" + data);
        } else if (back.getAvatar_small() != null) {
          fb.display(holder.head_img, back.getAvatar_small() + "#" + data);
        } else if (back.getAvatar_big() != null) {
          fb.display(holder.head_img, back.getAvatar_big() + "#" + data);
        }

        holder.name_tv.setText(back.getNickname());
        // holder.distance_tv.setText();
        String time = StandardDate.getStandardDate((back.getLast_login_time() * 1000));
        holder.time_tv.setText(time);

        if (back.getProfile().getBirthday() != null
            && !back.getProfile().getBirthday().getValue().equals("")) {
          SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
          String now_year = sdf.format(new java.util.Date()); // 获取当前年份
          String old_year =
              sdf.format(
                  new Date(
                      Integer.parseInt(back.getProfile().getBirthday().getValue())
                          * 1000L)); // 获取出生年份
          String age = String.valueOf(Integer.parseInt(now_year) - Integer.parseInt(old_year));
          holder.age_tv.setText(age + "岁");
        }

        if (back.getProfile().getHeight() != null
            && !back.getProfile().getHeight().getValue().equals("")) {
          holder.height_tv.setText(back.getProfile().getHeight().getValue() + "cm");
        }

        if (back.getProfile().getWeight() != null
            && !back.getProfile().getWeight().getValue().equals("")) {
          holder.weight_tv.setText(back.getProfile().getWeight().getValue() + "kg");
        }
        // holder.age_tv.setText();
        //				holder.height_tv.setText((CharSequence)
        // back.getProfile().getHeight().getValue()+"cm");
        //				holder.weight_tv.setText((CharSequence)
        // back.getProfile().getWeight().getValue()+"kg");
        holder.sign_tv.setText(back.getIntro());
        if (back.getSex().equals("1")) {
          holder.sex_img.setImageResource(R.drawable.man_icon);
        } else {
          holder.sex_img.setImageResource(R.drawable.woman_icon);
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
    }

    convertView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Intent intent = new Intent(context, PersonActivity.class);
            intent.putExtra("uid", back.getUid());
            context.startActivity(intent);
          }
        });

    return convertView;
  }