示例#1
0
  @Override
  public View getView(int position, View convertView, ViewGroup viewGroup) {
    Holder holder = null;
    View rowView = convertView;

    FileObj fileObj = filePathList.get(position);

    if (rowView == null) {

      Bitmap bitmap = BitmapFactory.decodeFile(fileObj.getFilePath());

      holder = new Holder();
      rowView = mInflater.inflate(R.layout.image_file_item, viewGroup, false);
      holder.picture = (ImageView) rowView.findViewById(R.id.picture);
      holder.text = (TextView) rowView.findViewById(R.id.text);
      holder.picture.setScaleType(ImageView.ScaleType.CENTER_CROP);

      holder.picture.setImageBitmap(bitmap);
      holder.picture.setScaleType(ImageView.ScaleType.CENTER_CROP);
      holder.text.setText(fileObj.getCreateTime());
      rowView.setTag(holder);

    } else {
      Bitmap bitmap = BitmapFactory.decodeFile(fileObj.getFilePath());
      holder = (Holder) rowView.getTag();
      holder.picture.setImageBitmap(bitmap);
      holder.picture.setScaleType(ImageView.ScaleType.CENTER_CROP);
      holder.text.setText(fileObj.getCreateTime());
    }
    return rowView;
  }
  public View getChildView(
      int groupPosition,
      int childPosition,
      boolean isLastChild,
      View convertView,
      ViewGroup parent) {
    // Log.d(LOG_TAG,"getChildView "+childPosition);
    groupDatastore.moveToPosition(groupPosition);

    String post_id = groupDatastore.getString(mGroupIdCursorColumnIndex);

    updateChildDataStore(post_id);

    childDatastore.moveToPosition(childPosition);

    Holder tag;
    if (convertView == null) {
      convertView = mLayoutInflater.inflate(R.layout.t_streamcomment, parent, false);
      tag = new Holder();
      tag.name = (TextView) convertView.findViewById(R.id.name);
      tag.text = (TextView) convertView.findViewById(R.id.text);
    } else {
      tag = (Holder) convertView.getTag();
    }

    String name = childDatastore.getString(Comment.TOTAL_PROPERTY_COLUMNS + User.col_name);
    String message = childDatastore.getString(Comment.col_comment);
    if (message != null) {
      tag.text.setText(message.trim());
    }

    tag.name.setText(name);
    tag.groupPosition = groupPosition;

    convertView.setTag(tag);

    return convertView;
  }
示例#3
0
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    final Holder holder;

    if (convertView == null) {
      holder = new Holder();
      convertView = View.inflate(act, R.layout.item_image_grid, null);
      holder.iv = (ImageView) convertView.findViewById(R.id.image);
      holder.selected = (ImageView) convertView.findViewById(R.id.isselected);
      holder.text = (TextView) convertView.findViewById(R.id.item_image_grid_text);
      convertView.setTag(holder);
    } else {
      holder = (Holder) convertView.getTag();
    }
    final ImageItem item = dataList.get(position);

    holder.iv.setTag(item.imagePath);
    cache.displayBmp(holder.iv, item.thumbnailPath, item.imagePath, callback);
    if (item.isSelected) {
      holder.selected.setImageResource(R.drawable.icon_data_select);
      holder.text.setBackgroundResource(R.drawable.bgd_relatly_line);
    } else {
      holder.selected.setImageResource(-1);
      holder.text.setBackgroundColor(0x00000000);
    }
    holder.iv.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            String path = dataList.get(position).imagePath;

            if ((Bimp.drr.size() + selectTotal) < 9) {
              item.isSelected = !item.isSelected;
              if (item.isSelected) {
                holder.selected.setImageResource(R.drawable.icon_data_select);
                holder.text.setBackgroundResource(R.drawable.bgd_relatly_line);
                selectTotal++;
                if (textcallback != null) textcallback.onListen(selectTotal);
                map.put(path, path);

              } else if (!item.isSelected) {
                holder.selected.setImageResource(-1);
                holder.text.setBackgroundColor(0x00000000);
                selectTotal--;
                if (textcallback != null) textcallback.onListen(selectTotal);
                map.remove(path);
              }
            } else if ((Bimp.drr.size() + selectTotal) >= 9) {
              if (item.isSelected == true) {
                item.isSelected = !item.isSelected;
                holder.selected.setImageResource(-1);
                selectTotal--;
                map.remove(path);

              } else {
                Message message = Message.obtain(mHandler, 0);
                message.sendToTarget();
              }
            }
          }
        });

    return convertView;
  }