Beispiel #1
0
  protected void loadByPicasso(final View v, ImageView targetImageView) {
    final BaseSliderView me = this;
    ImageUtils.getInstance().loadWebImage(mContext, targetImageView, mUrl);
    /*Picasso p = Picasso.with(mContext);
    RequestCreator rq = null;
    if (mUrl != null) {
        rq = p.load(mUrl);
    } else if (mFile != null) {
        rq = p.load(mFile);
    } else if (mRes != 0) {
        rq = p.load(mRes);
    } else {
        return;
    }

    if (rq == null) {
        return;
    }

    if (getImageResForEmpty() != 0) {
        rq.placeholder(getImageResForEmpty());
    }

    if (getImageResForError() != 0) {
        rq.error(getImageResForError());
    }

    switch (mScaleType) {
        case Fit:
            rq.fit();
            break;
        case CenterCrop:
            rq.fit().centerCrop();
            break;
        case CenterInside:
            rq.fit().centerInside();
            break;
    }

    rq.into(targetImageView, new Callback() {
        @Override
        public void onSuccess() {
            if (v.findViewById(R.id.loading_bar) != null) {
                v.findViewById(R.id.loading_bar).setVisibility(View.INVISIBLE);
            }
            if (mBitmapLoadListener != null) {
                mBitmapLoadListener.onLoadComplete(me);
            }
        }

        @Override
        public void onError() {
            if (mBitmapLoadListener != null) {
                mBitmapLoadListener.onLoadFail(me);
            }
        }
    });*/

  }
  @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;
  }