Пример #1
1
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    int showPosition = bean.size() - 1 - position;

    DMViewHolder holder = null;
    if (convertView == null
        || convertView.getTag(R.drawable.ic_launcher + getItemViewType(showPosition)) == null) {
      switch (getItemViewType(showPosition)) {
        case TYPE_NORMAL:
          convertView = initNormalSimpleLayout(parent);
          break;
        case TYPE_MYSELF:
          convertView = initMySimpleLayout(parent);
          break;
        default:
          throw new IllegalArgumentException("dm user type is wrong");
      }
      holder = buildHolder(convertView);
      convertView.setTag(R.drawable.ic_launcher + getItemViewType(showPosition), holder);
      convertView.setTag(
          R.string.listview_index_tag, R.drawable.ic_launcher + getItemViewType(showPosition));

    } else {
      holder =
          (DMViewHolder) convertView.getTag(R.drawable.ic_launcher + getItemViewType(showPosition));
    }

    configViewFont(holder);
    configLayerType(holder);
    bindViewData(holder, showPosition);
    return convertView;
  }
Пример #2
1
  /** Put a nice border on the bitmap. */
  private static View applyFrame(
      final PhotoTable table, final BitmapFactory.Options options, Bitmap decodedPhoto) {
    LayoutInflater inflater =
        (LayoutInflater) table.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View photo = inflater.inflate(R.layout.photo, null);
    ImageView image = (ImageView) photo;
    Drawable[] layers = new Drawable[2];
    int photoWidth = options.outWidth;
    int photoHeight = options.outHeight;
    if (decodedPhoto == null || options.outWidth <= 0 || options.outHeight <= 0) {
      photo = null;
    } else {
      decodedPhoto.setHasMipMap(true);
      layers[0] = new BitmapDrawable(table.mResources, decodedPhoto);
      layers[1] = table.mResources.getDrawable(R.drawable.frame);
      LayerDrawable layerList = new LayerDrawable(layers);
      layerList.setLayerInset(0, table.mInset, table.mInset, table.mInset, table.mInset);
      image.setImageDrawable(layerList);

      photo.setTag(R.id.photo_width, Integer.valueOf(photoWidth));
      photo.setTag(R.id.photo_height, Integer.valueOf(photoHeight));

      photo.setOnTouchListener(new PhotoTouchListener(table.getContext(), table));
    }
    return photo;
  }
Пример #3
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    Cursor cursor = this.getCursor();
    cursor.moveToPosition(position);
    long dateMilliseconds = cursor.getLong(cursor.getColumnIndex(ChatProvider.ChatConstants.DATE));
    String date = TimeUtil.getChatTime(dateMilliseconds);
    String message = cursor.getString(cursor.getColumnIndex(ChatProvider.ChatConstants.MESSAGE));
    String jid = cursor.getString(cursor.getColumnIndex(ChatProvider.ChatConstants.JID));

    String selection =
        ChatConstants.JID
            + " = '"
            + jid
            + "' AND "
            + ChatConstants.DIRECTION
            + " = "
            + ChatConstants.INCOMING
            + " AND "
            + ChatConstants.DELIVERY_STATUS
            + " = "
            + ChatConstants.DS_NEW; // 新消息数量字段
    Cursor msgcursor =
        mContentResolver.query(
            ChatProvider.CONTENT_URI,
            new String[] {
              "count(" + ChatConstants.PACKET_ID + ")", ChatConstants.DATE, ChatConstants.MESSAGE
            },
            selection,
            null,
            SORT_ORDER);
    msgcursor.moveToFirst();
    int count = msgcursor.getInt(0);
    ViewHolder viewHolder;
    if (convertView == null
        || convertView.getTag(R.drawable.ic_launcher + (int) dateMilliseconds) == null) {
      convertView = mLayoutInflater.inflate(R.layout.recent_listview_item, parent, false);
      viewHolder = buildHolder(convertView, jid);
      convertView.setTag(R.drawable.ic_launcher + (int) dateMilliseconds, viewHolder);
      convertView.setTag(R.string.app_name, R.drawable.ic_launcher + (int) dateMilliseconds);
    } else {
      viewHolder = (ViewHolder) convertView.getTag(R.drawable.ic_launcher + (int) dateMilliseconds);
    }
    viewHolder.jidView.setText(XMPPHelper.splitJidAndServer(jid));
    viewHolder.msgView.setText(
        XMPPHelper.convertNormalStringToSpannableString(mContext, message, true));
    viewHolder.dataView.setText(date);

    if (msgcursor.getInt(0) > 0) {
      viewHolder.msgView.setText(
          msgcursor.getString(msgcursor.getColumnIndex(ChatConstants.MESSAGE)));
      viewHolder.dataView.setText(
          TimeUtil.getChatTime(msgcursor.getLong(msgcursor.getColumnIndex(ChatConstants.DATE))));
      viewHolder.unReadView.setText(msgcursor.getString(0));
    }
    viewHolder.unReadView.setVisibility(count > 0 ? View.VISIBLE : View.GONE);
    viewHolder.unReadView.bringToFront();
    msgcursor.close();

    return convertView;
  }
Пример #4
0
 private View createViewFromType(int type) {
   IBdViewHolder viewHolder;
   View v = null;
   switch (type) {
     case BdSample.TYPE_DEFAULT_ITEM:
       {
         v = layoutInflater.inflate(R.layout.bd_default_item, null);
         viewHolder = new BdItemViewHolder(v);
         v.setTag(viewHolder);
         break;
       }
     case BdSample.TYPE_HEADER_DIVIDOR:
       {
         v = layoutInflater.inflate(R.layout.bd_listemptyheader, null);
         viewHolder = new BdHeaderHolder(v);
         v.setTag(viewHolder);
         break;
       }
     case BdSample.TYPE_MULTI_GRID_FRAME_ITEM1:
       {
         v = layoutInflater.inflate(R.layout.multigridframe1, null);
         viewHolder = new BdMultiFrame1Holder(v);
         v.setTag(viewHolder);
         break;
       }
   }
   return v;
 }
  public View getView(int position, View convertView, ViewGroup parent) {
    View row = convertView;

    if (row == null) {
      LayoutInflater inflater = context.getLayoutInflater();
      row = inflater.inflate(R.layout.list_row, null);
    } else row.setTag(""); // when reused, don't pretend to be something else

    TextView name = (TextView) row.findViewById(R.id.row_label);
    name.setText(mItems.get(position).mLabel);

    if (mLoadingBar == position
        || mItems.get(position).icon() == R.drawable.now_playing
        || mItems.get(position).icon() == R.drawable.now_paused) {
      ViewSwitcher switcher = (ViewSwitcher) row.findViewById(R.id.row_view_switcher);
      row.findViewById(R.id.row_view_switcher).setVisibility(View.VISIBLE);
      switcher.setDisplayedChild(mLoadingBar == position ? 1 : 0);
      ((ImageView) row.findViewById(R.id.row_disclosure_icon))
          .setImageResource(mItems.get(position).icon());
    } else {
      row.findViewById(R.id.row_view_switcher).setVisibility(View.GONE);
    }

    row.findViewById(R.id.row_icon).setVisibility(View.VISIBLE);
    ((ImageView) row.findViewById(R.id.row_icon)).setScaleType(ImageView.ScaleType.CENTER);
    ((ImageView) row.findViewById(R.id.row_icon)).setImageResource(R.drawable.list_icon_station);

    if (position == mItems.size() - 1) {
      row.setBackgroundResource(R.drawable.list_entry_rounded_bottom);
      row.setTag("bottom");
    } else row.setBackgroundResource(R.drawable.list_entry);

    return row;
  }
Пример #6
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    long time = System.currentTimeMillis();
    if (null == convertView) {
      convertView = mInflater.inflate(R.layout.lesson_boss, parent, false);
      holder = new ViewHolder();
      holder.llImgsContainer = (LinearLayout) convertView.findViewById(R.id.llImgsContainer);
      convertView.setTag(holder);

      int w = imgBigWidth, h = imgBigWidth;
      Bitmap bitmap = null;
      OptionImg img = null;
      img = new OptionImg(holder.llImgsContainer.getContext(), R.drawable.bg_head, bitmap, w, h);
      ViewUtils.setLinearMargins(img, imgWidth, imgWidth, marginBig, 0, marginBig, 0);
      holder.llImgsContainer.addView(img);
      holder.img = img;
      convertView.setTag(holder);
      imgs.add(img);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }
    //        DebugPrinter.i("耗时1:" + (System.currentTimeMillis() - time) + "ms");
    refreshCurrentView(getItem(position), holder, position);
    //        DebugPrinter.i("耗时all:" + (System.currentTimeMillis() - time) + "ms");
    return convertView;
  }
Пример #7
0
  public void setContent(Object param) {
    if (param instanceof BaseComment) {
      BaseComment comment = (BaseComment) param;

      String nameString = comment.owner.name;
      long timeParam = comment.created_at;
      String iconUri = comment.owner.avatar;

      imageLoadTool.loadImage(icon, iconUri);
      icon.setTag(comment.owner.global_key);
      name.setText(nameString);
      time.setText(Global.dayToNow(timeParam));
      layout.setTag(comment);

    } else if (param instanceof Commit) {
      Commit commit = (Commit) param;
      String nameString = commit.getName();
      long timeParam = commit.getCommitTime();
      String iconUri = commit.getIcon();

      imageLoadTool.loadImage(icon, iconUri);
      icon.setTag(commit.getGlobalKey());
      name.setText(nameString);
      time.setText(Global.dayToNow(timeParam));
      layout.setTag(commit);
    }
  }
Пример #8
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder = null;
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    if (convertView == null) {
      convertView = inflater.inflate(R.layout.layout_userlist_element, null);
      viewHolder = new ViewHolder();
      viewHolder.iv_dp = (ImageView) convertView.findViewById(R.id.id_userhome_iv_listUser_dp);
      viewHolder.iv_dp.setOnClickListener(this);
      viewHolder.tv_nname = (TextView) convertView.findViewById(R.id.id_userhome_tv_listUser_text);
      viewHolder.iv_isOnline =
          (ImageView) convertView.findViewById(R.id.id_userhome_iv_listUser_isOnline);
      viewHolder.iv_MsgType =
          (ImageView) convertView.findViewById(R.id.id_userhome_iv_listUser_lastMessageType);
      viewHolder.tv_lastMsg =
          (TextView) convertView.findViewById(R.id.id_userhome_tv_listUser_lastMessage);
      viewHolder.tv_lastMsgTime =
          (TextView) convertView.findViewById(R.id.id_userhome_tv_listUser_lastMessageTime);
      viewHolder.iv_isSend =
          (ImageView) convertView.findViewById(R.id.id_userhome_iv_listUser_lastMessageIsSend);

      viewHolder = setViewHolder(viewHolder, position);

      convertView.setTag(viewHolder);

    } else {
      viewHolder = setViewHolder((ViewHolder) convertView.getTag(), position);
      convertView.setTag(viewHolder);
    }
    return convertView;
  }
Пример #9
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   if (!favoritos) {
     Holder holder;
     if (convertView == null) {
       convertView = layoutInflater.inflate(R.layout.onibus_listview, null);
       holder = new Holder();
       holder.linhaNome = (TextView) convertView.findViewById(R.id.linha_nome);
       convertView.setTag(holder);
     } else {
       holder = (Holder) convertView.getTag();
     }
     Onibus onibus = lista.get(position);
     holder.linhaNome.setText(onibus.getLinha() + " - " + onibus.getNome());
   } else {
     Holder holder;
     if (convertView == null) {
       convertView = layoutInflater.inflate(R.layout.favoritos_listview, null);
       holder = new Holder();
       holder.linhaNome = (TextView) convertView.findViewById(R.id.linha_nome_favorito);
       convertView.setTag(holder);
     } else {
       holder = (Holder) convertView.getTag();
     }
     Onibus onibus = lista.get(position);
     holder.linhaNome.setText(onibus.getLinha() + " - " + onibus.getNome());
   }
   return convertView;
 }
  /**
   * @param index 小于0则顺序插入(插入至最末尾);大于等于0则按指定索引值(index)插入
   * @param childView
   * @return
   */
  public boolean addChildView(int index, View childView) {
    if (childViews.contains(childView)) {
      return false;
    }

    if (null == childView.getTag()) {
      // 结构层操作
      // tag为null说明此view在添加至文件夹内之前是处于桌面上的,所以需要将其从根文件夹对象中删除
      GlobalDataCacheForMemorySingleton.getInstance
          .getRootDirectory()
          .getListFiles()
          .remove(((DragView) childView).getBookFile());
    } else {
      ((BookFolderLayout) childView.getTag()).removeChildView(childView, true);
    }

    if (null != childView.getParent()) {
      ((ViewGroup) childView.getParent()).removeView(childView);
    }

    if (index < 0) {
      childViews.add(childView);
    } else {
      childViews.add(index, childView);
    }

    // 生成缩略图控件
    BookThumbnailLayout bookThumbnailLayout = new BookThumbnailLayout(getContext());
    bookThumbnailLayout.bind((BookShelfBookCell) childView);
    childView.setTag(R.id.bookThumbnailView, bookThumbnailLayout);

    MyGridLayout.LayoutParams layoutParams = new MyGridLayout.LayoutParams();
    layoutParams.width = (int) getResources().getDimension(R.dimen.book_cell_width) / 3;
    layoutParams.height = (int) getResources().getDimension(R.dimen.book_image_height) / 3;
    layoutParams.topMargin = 4;
    layoutParams.leftMargin = 4;
    layoutParams.rightMargin = 4;
    layoutParams.bottomMargin = 4;

    // 顺序插入时,封面只显示前4本书
    if (index < 0) {
      if (gridLayout.getChildCount() < 4) {
        gridLayout.addView(bookThumbnailLayout, layoutParams);
      }
    }

    // 指定插入时,若索引值小于4则需将封面上多余的一张缩略图(即原第4张)删除
    else if (index < 4) {
      if (gridLayout.getChildCount() == 4) {
        gridLayout.removeViewAt(3);
      }
      gridLayout.addView(bookThumbnailLayout, index, layoutParams);
    }

    childView.setTag(this);

    updateFrontCover(); // 刷新封面

    return true;
  }
Пример #11
0
  // 把viewpager里面要显示的view实例化出来,并且把相关的view添加到一个list当中
  private void createView() {
    view =
        this.getLocalActivityManager()
            .startActivity("doctor", new Intent(MainFrame.this, DoctorList.class))
            .getDecorView();
    // 用来更改下面button的样式的标志
    view.setTag(0);
    list.add(view);

    Intent intent_pharma = new Intent(MainFrame.this, PharmacistList.class);
    view1 =
        MainFrame.this
            .getLocalActivityManager()
            .startActivity("pharmacist", intent_pharma)
            .getDecorView();
    view1.setTag(1);
    list.add(view1);

    Intent intent_file = new Intent(MainFrame.this, State.class);
    view2 =
        MainFrame.this.getLocalActivityManager().startActivity("files", intent_file).getDecorView();
    view2.setTag(2);
    list.add(view2);

    view3 =
        MainFrame.this
            .getLocalActivityManager()
            .startActivity("Set", new Intent(MainFrame.this, Set.class))
            .getDecorView();
    view3.setTag(3);
    list.add(view3);
  }
Пример #12
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    // Changed to ViewHolder and Picasso error load as per feedback received
    ViewHolder holder = new ViewHolder();

    // Inflate view if it is null
    if (convertView == null) {
      convertView = inflater.inflate(R.layout.grid_item, null);
      holder.imageView = (ImageView) convertView.findViewById(R.id.movie_poster);
      MovieDetailDO movie = movieList.get(position);
      convertView.setTag(holder);

      Picasso.with(context)
          .load(movie.getPoster_path())
          // .placeholder(R.drawable.def_pos)
          .error(R.drawable.def_pos)
          .into(holder.imageView);

    } else {
      holder.imageView = (ImageView) convertView.findViewById(R.id.movie_poster);
      MovieDetailDO movie = movieList.get(position);
      convertView.setTag(holder);

      Picasso.with(context)
          .load(movie.getPoster_path())
          // .placeholder(R.drawable.def_pos)
          .error(R.drawable.def_pos)
          .into(holder.imageView);
    }

    return convertView;
  }
Пример #13
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      LayoutInflater mInflater =
          (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
      convertView = mInflater.inflate(R.layout.card, null);
      holder.mText = (TextView) convertView.findViewById(R.id.stop);
      holder.imgIcon = (ImageView) convertView.findViewById(R.id.card_image);
      convertView.setTag(R.id.id_one, holder.mText);
      convertView.setTag(R.id.id_two, holder.imgIcon);
    } else {
      holder.mText = (TextView) convertView.getTag(R.id.id_one);
      holder.imgIcon = (ImageView) convertView.getTag(R.id.id_two);
    }

    holder.mText.setText(stopItems.get(position).getTitle());
    holder.mText.setTextColor(Color.parseColor(color));
    if (position == 0) {
      holder.mText.setTypeface(null, Typeface.BOLD_ITALIC);
      holder.mText.setTextSize(30);
    } else {
      holder.mText.setTextSize(20);
      holder.mText.setTypeface(null, Typeface.ITALIC);
    }

    if (!stopItems.get(position).getIconVisibility()) {
      holder.imgIcon.setVisibility(View.GONE);
    }

    return convertView;
  }
Пример #14
0
  private void init() {
    layoutView = new LinearLayout(cxt);
    layoutView.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    View child1 = inflater.inflate(R.layout.new_request_item, null);
    layoutView.addView(child1, lp);
    child1.setOnClickListener(this);
    Holde holde = new Holde();
    child1.setTag(holde);
    holde.tv_1 = (TextView) child1.findViewById(R.id.tv_1);
    holde.tv_2 = (TextView) child1.findViewById(R.id.tv_2);
    holde.selector_iv = (ImageView) child1.findViewById(R.id.img_l);
    holde.details_lin = (LinearLayout) child1.findViewById(R.id.content_layout);
    holde.tv_1.setText(R.string.object);
    holde.tv_2.setText(R.string.accounts);
    holde.details_lin.addView(inflater.inflate(R.layout.contact_new_request_object, null), lp);

    child1 = inflater.inflate(R.layout.new_request_item, null);
    layoutView.addView(child1, lp);
    child1.setOnClickListener(this);
    holde = new Holde();
    child1.setTag(holde);
    holde.tv_1 = (TextView) child1.findViewById(R.id.tv_1);
    holde.tv_2 = (TextView) child1.findViewById(R.id.tv_2);
    holde.selector_iv = (ImageView) child1.findViewById(R.id.img_l);
    holde.details_lin = (LinearLayout) child1.findViewById(R.id.content_layout);
    holde.details_lin.setVisibility(View.VISIBLE);
    holde.tv_1.setText(R.string.channel);
    holde.tv_2.setText(R.string.tap_to_set);
    holde.details_lin.addView(inflater.inflate(R.layout.contact_new_request_channel, null), lp);

    child1 = inflater.inflate(R.layout.new_request_item, null);
    layoutView.addView(child1, lp);
    child1.setOnClickListener(this);
    holde = new Holde();
    child1.setTag(holde);
    holde.tv_1 = (TextView) child1.findViewById(R.id.tv_1);
    holde.tv_2 = (TextView) child1.findViewById(R.id.tv_2);
    holde.selector_iv = (ImageView) child1.findViewById(R.id.img_l);
    holde.details_lin = (LinearLayout) child1.findViewById(R.id.content_layout);
    holde.tv_1.setText(R.string.details);
    holde.tv_2.setText(R.string.tap_to_set1);
    holde.details_lin.addView(inflater.inflate(R.layout.contact_new_request_description, null), lp);

    child1 = inflater.inflate(R.layout.new_request_item, null);
    layoutView.addView(child1, lp);
    child1.setOnClickListener(this);
    holde = new Holde();
    child1.setTag(holde);
    holde.tv_1 = (TextView) child1.findViewById(R.id.tv_1);
    holde.tv_2 = (TextView) child1.findViewById(R.id.tv_2);
    holde.selector_iv = (ImageView) child1.findViewById(R.id.img_l);
    holde.details_lin = (LinearLayout) child1.findViewById(R.id.content_layout);
    holde.tv_1.setText(R.string.description_);
    holde.tv_2.setText(R.string.tap_to_set1);
    holde.details_lin.addView(inflater.inflate(R.layout.contact_new_request_description, null), lp);
  }
 @Override
 public View getChildView(
     int groupPosition,
     int childPosition,
     boolean isLastChild,
     View convertView,
     ViewGroup parent) {
   CellHolder cell = null;
   if (convertView == null) {
     cell = new CellHolder();
     convertView = inflater.inflate(R.layout.index_cell, null);
     cell.titleView = (TextView) convertView.findViewById(R.id.title);
     cell.desView = (TextView) convertView.findViewById(R.id.des);
     convertView.setTag(cell);
   } else {
     cell = (CellHolder) convertView.getTag();
   }
   final PhoneIntroEntity model = (PhoneIntroEntity) getChild(groupPosition, childPosition);
   if (groupPosition == 4) {
     cell.desView.setText(model.content);
     cell.desView.setText(String.format("%s氏   人数:%s", model.family_name, model.member));
   } else if (groupPosition == 5) {
     cell.desView.setText(model.content);
     cell.desView.setText(model.family_intro);
   } else if (groupPosition == 0) {
     cell.desView.setText(String.format("人数:%s   点击数:%s", model.member, model.hits));
   } else if (groupPosition == 1) {
     cell.desView.setText(String.format("人数:%s   发起人:%s", model.member, model.creator));
   } else if (groupPosition == 2) { // activity created
     cell.desView.setText(String.format("点击数:%s   参加人数:%s", model.hits, model.member));
   } else if (groupPosition == 3) { // activity took part
     cell.desView.setText(String.format("聚会时间:%s   参加人数:%s", model.begin_at, model.member));
   }
   cell.titleView.setText(model.title);
   convertView.setTag(R.id.title, groupPosition);
   convertView.setTag(R.id.des, childPosition);
   convertView.setOnLongClickListener(
       new OnLongClickListener() {
         @Override
         public boolean onLongClick(View arg0) {
           ((Index) context).showSharePre(false, null, model);
           return false;
         }
       });
   convertView.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {
           if (model.phoneSectionType.equals(CommonValue.PhoneSectionType.OwnedSectionType)
               || model.phoneSectionType.equals(CommonValue.PhoneSectionType.JoinedSectionType)) {
             ((Index) context).showPhoneViewWeb(model);
           } else {
             ((Index) context).showActivityViewWeb(model);
           }
         }
       });
   return convertView;
 }
Пример #16
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder_Department holder_department = null;
    ViewHolder_Member holder_member = null;
    int type = getItemViewType(position);
    if (convertView == null) {
      switch (type) {
        case MarketApp.HANDLERMESS_ZERO:
          convertView = mInflater.inflate(R.layout.listitem_department, null);
          holder_department = new ViewHolder_Department();
          holder_department.name = (TextView) convertView.findViewById(R.id.name);
          convertView.setTag(holder_department);
          break;
        case MarketApp.HANDLERMESS_ONE:
          convertView = mInflater.inflate(R.layout.listitem_department_member, null);
          holder_member = new ViewHolder_Member();
          holder_member.name = (TextView) convertView.findViewById(R.id.tv_nick);
          holder_member.phone = (TextView) convertView.findViewById(R.id.tv_phone);
          holder_member.icon = (ImageView) convertView.findViewById(R.id.iv_pic);
          convertView.setTag(holder_member);
          break;
      }
    } else {
      switch (type) {
        case MarketApp.HANDLERMESS_ZERO:
          holder_department = (ViewHolder_Department) convertView.getTag();
          break;
        case MarketApp.HANDLERMESS_ONE:
          holder_member = (ViewHolder_Member) convertView.getTag();
          break;
      }
    }

    BusinessContactVo vo = list.get(position);
    switch (type) {
      case MarketApp.HANDLERMESS_ZERO:
        if (vo instanceof DepartmentVo) {
          DepartmentVo dvo = (DepartmentVo) vo;
          holder_department.name.setText(dvo.getName());
        }
        break;
      case MarketApp.HANDLERMESS_ONE:
        if (vo instanceof DepartmentMemberVo) {
          DepartmentMemberVo mvo = (DepartmentMemberVo) vo;
          holder_member.name.setText(mvo.getName());
          holder_member.phone.setText(mvo.getPhonenum());
          Utils.downloadImg(
              true,
              MarketApp.app,
              holder_member.icon,
              mvo.getPic(),
              R.drawable.icon_department_member,
              listView);
        }
        break;
    }
    return convertView;
  }
  private void initTitleView() {
    View backImageView = findViewByResName("backImageView");
    backImageView.setTag("close");
    backImageView.setOnClickListener(this);

    View okImageView = findViewByResName("okImageView");
    okImageView.setTag("ok");
    okImageView.setOnClickListener(this);
  }
Пример #18
0
  private View fillStandView(View convertView, int position) {
    StandViewHolder eliminatedHolder = null;
    EliminatedTotalEntity entity = getItem(position);
    if (convertView == null) {
      eliminatedHolder = new StandViewHolder();
      convertView =
          LayoutInflater.from(context).inflate(R.layout.standings_common_item_layout, null);
      setupChildViews(convertView, eliminatedHolder);
      convertView.setTag(eliminatedHolder);
    } else if (convertView.getTag() != null && convertView.getTag() instanceof EliminatedHolder) {
      eliminatedHolder = (StandViewHolder) convertView.getTag();
    } else {
      eliminatedHolder = new StandViewHolder();
      convertView =
          LayoutInflater.from(context).inflate(R.layout.standings_common_item_layout, null);
      setupChildViews(convertView, eliminatedHolder);
      convertView.setTag(eliminatedHolder);
    }

    if (entity.getRank() != null) {
      if (entity.getRank().equals("1") || entity.getRank().equals("2")) {
        eliminatedHolder.line.setBackgroundColor(context.getResources().getColor(R.color.title));
        eliminatedHolder.greenlinestand.setVisibility(View.VISIBLE);
        eliminatedHolder.greylinestand.setVisibility(View.INVISIBLE);
      } else {
        eliminatedHolder.line.setBackgroundColor(
            context.getResources().getColor(R.color.user_info_message));
        eliminatedHolder.greylinestand.setVisibility(View.VISIBLE);
        eliminatedHolder.greenlinestand.setVisibility(View.INVISIBLE);
      }
      eliminatedHolder.mNumber.setText(entity.getRank());
      eliminatedHolder.mTeam.setText(entity.getClub_name());
      eliminatedHolder.mTeam.setOnClickListener(
          new TeamClick(getItem(position).getTeam_id(), context));
      eliminatedHolder.ico.setOnClickListener(
          new TeamClick(getItem(position).getTeam_id(), context));
      // if (App.LOGOS.containsKey(entity.getClub_name())) {
      // // mImageLoader.displayImage("drawable://" +
      // // App.LOGOS.get(entity.getClub_name()),
      // // eliminatedHolder.ico, options,null);
      // eliminatedHolder.ico.setImageResource(App.LOGOS.get(getItem(position)
      // .getClub_name()));
      // } else {
      mImageLoader.displayImage(
          Urls.PIC_PATH + entity.getTeam_id() + ".png", eliminatedHolder.ico, options, null);
      // }
      eliminatedHolder.round.setText(entity.getMatches_total());
      eliminatedHolder.mLose.setText(entity.getMatches_lost());
      eliminatedHolder.mDraw.setText(entity.getMatches_draw());
      eliminatedHolder.mWin.setText(entity.getMatches_won());
      eliminatedHolder.mPoint.setText(entity.getPoints());
      String goal = entity.getGoals_pro();
      String conceded = entity.getGoals_against();
      eliminatedHolder.mGoalConceded.setText(goal + "/" + conceded);
    }
    return convertView;
  }
Пример #19
0
  @Override
  public View getView(final int position, View convertView, final ViewGroup parent) {
    int viewType = getItemViewType(position);

    if (viewType == TYPE_CAMERA) {
      CameraViewHolder holder;
      if (convertView == null) {
        convertView = mInflater.inflate(R.layout.media_camera_item, parent, false);
        AbsListView.LayoutParams params = (AbsListView.LayoutParams) convertView.getLayoutParams();
        int width = (mWidth - 2 * getPixelSize(R.dimen.media_item_horizontal_spacing)) / 3;
        params.width = width;
        params.height = width;
        convertView.setLayoutParams(params);

        holder = new CameraViewHolder(convertView);
        convertView.setTag(holder);
      } else {
        holder = (CameraViewHolder) convertView.getTag();
      }
    } else {
      MediaViewHolder holder;
      if (convertView == null) {
        convertView = mInflater.inflate(R.layout.media_item, parent, false);
        AbsListView.LayoutParams params = (AbsListView.LayoutParams) convertView.getLayoutParams();
        int width = (mWidth - 2 * getPixelSize(R.dimen.media_item_horizontal_spacing)) / 3;
        params.width = width;
        params.height = width;
        convertView.setLayoutParams(params);

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

      final Media media = mMedias.get(position);

      setImage(holder.photoIv, media.getData());
      setIndex(holder.indexTv, contains(media));
      setText(holder.sizeTv, ByteUtil.format(media.getSize()));
      setVisibility(holder.indexTv, true);
      setVisibility(holder.videoLayout, media.getMediaType() == MediaType.MEDIA_TYPE_VIDEO);

      final View view = convertView;
      holder.indexTv.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              if (mOnItemCheckedListener == null) return;

              mOnItemCheckedListener.onItemChecked(view, position);
            }
          });
    }

    return convertView;
  }
Пример #20
0
 public void setSelectedView(View v) {
   if (mSelectedView != null) {
     mSelectedView.setTag(R.id.selected_view, null);
     mSelectedView = null;
   }
   if (v != null && v.getParent() != null) {
     mSelectedView = v;
     mSelectedView.setTag(R.id.selected_view, TAG + "SelectedView");
     invalidate();
   }
 }
    @Override
    public View getChildView(
        final int groupPosition,
        final int childPosition,
        boolean isLastChild,
        View convertView,
        ViewGroup parent) {
      final Object child = getChild(groupPosition, childPosition);
      if (child instanceof IndexItem) {

        IndexItem item = (IndexItem) child;
        DownloadResourceGroup group = getGroupObj(groupPosition);
        ItemViewHolder viewHolder;
        if (convertView != null && convertView.getTag() instanceof ItemViewHolder) {
          viewHolder = (ItemViewHolder) convertView.getTag();
        } else {
          convertView =
              LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.two_line_with_images_list_item, parent, false);
          viewHolder = new ItemViewHolder(convertView, ctx);
          viewHolder.setShowRemoteDate(true);
          convertView.setTag(viewHolder);
        }
        if (mainGroup.getType() == DownloadResourceGroupType.REGION
            && group != null
            && group.getType() == DownloadResourceGroupType.REGION_MAPS) {
          viewHolder.setShowTypeInName(true);
          viewHolder.setShowTypeInDesc(false);
        } else if (group != null
            && (group.getType() == DownloadResourceGroupType.SRTM_HEADER
                || group.getType() == DownloadResourceGroupType.HILLSHADE_HEADER)) {
          viewHolder.setShowTypeInName(false);
          viewHolder.setShowTypeInDesc(false);
        } else {
          viewHolder.setShowTypeInDesc(true);
        }
        viewHolder.bindIndexItem(item, group);
      } else {
        DownloadResourceGroup group = (DownloadResourceGroup) child;
        DownloadGroupViewHolder viewHolder;
        if (convertView != null && convertView.getTag() instanceof DownloadGroupViewHolder) {
          viewHolder = (DownloadGroupViewHolder) convertView.getTag();
        } else {
          convertView =
              LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.simple_list_menu_item, parent, false);
          viewHolder = new DownloadGroupViewHolder(ctx, convertView);
          convertView.setTag(viewHolder);
        }
        viewHolder.bindItem(group);
      }

      return convertView;
    }
Пример #22
0
  @Override
  public View getView(int i, View view, ViewGroup viewGroup) {
    ViewHolder mViewHolder = null;
    ZhiHuBean.Stories deal = list.get(i);
    int type = getItemViewType(i);

    if (view == null) {
      mViewHolder = new ViewHolder();

      switch (type) {
        case TYPE_DATE:
          view = LayoutInflater.from(mContext).inflate(R.layout.zhihulist_2, null);
          mViewHolder.tv_item_title = (TextView) view.findViewById(R.id.text_zhihu_2);
          view.setTag(mViewHolder);
          break;
        case TYPE_INFO:
          view = LayoutInflater.from(mContext).inflate(R.layout.zhihulist_item, null);
          mViewHolder.iv_item_main = (ImageView) view.findViewById(R.id.iv_three_zhihu);
          mViewHolder.tv_item_title = (TextView) view.findViewById(R.id.tv_title_three_zhihu);
          view.setTag(mViewHolder);
          break;
      }

    } else {
      mViewHolder = (ViewHolder) view.getTag();
    }

    switch (type) {
      case TYPE_DATE:
        Date tmpDate = null;
        if (i == 0) {
          mViewHolder.tv_item_title.setText(deal.getTime());
        } else {
          try {
            tmpDate = new SimpleDateFormat("yyyyMMdd").parse(deal.getTime());
          } catch (ParseException e) {
            e.printStackTrace();
          }
          String mData = DateFormat.getDateInstance(DateFormat.FULL).format(tmpDate);
          String thisYear = Calendar.getInstance().get(Calendar.YEAR) + "年";
          if (mData.startsWith(thisYear)) {
            mData.replace(thisYear, "");
          }
          mViewHolder.tv_item_title.setText(mData);
        }

        break;
      case TYPE_INFO:
        mViewHolder.tv_item_title.setText(deal.getTitle());
        bitmapUtils.display(mViewHolder.iv_item_main, deal.images[0]);
        break;
    }
    return view;
  }
Пример #23
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      int type = getItemViewType(position);
      if (type == ROW_SEARCH || type == ROW_SUGGEST) {
        SearchEntryViewHolder viewHolder = null;

        if (convertView == null || !(convertView.getTag() instanceof SearchEntryViewHolder)) {
          convertView =
              getInflater().inflate(R.layout.awesomebar_suggestion_row, getListView(), false);

          viewHolder = new SearchEntryViewHolder();
          viewHolder.suggestionView = (FlowLayout) convertView.findViewById(R.id.suggestion_layout);
          viewHolder.iconView = (ImageView) convertView.findViewById(R.id.suggestion_icon);
          viewHolder.userEnteredView =
              (LinearLayout) convertView.findViewById(R.id.suggestion_user_entered);
          viewHolder.userEnteredTextView =
              (TextView) convertView.findViewById(R.id.suggestion_text);

          convertView.setTag(viewHolder);
        } else {
          viewHolder = (SearchEntryViewHolder) convertView.getTag();
        }

        bindSearchEngineView(mSearchEngines.get(getEngineIndex(position)), viewHolder);
      } else {
        AwesomeEntryViewHolder viewHolder = null;

        if (convertView == null || !(convertView.getTag() instanceof AwesomeEntryViewHolder)) {
          convertView = getInflater().inflate(R.layout.awesomebar_row, null);

          viewHolder = new AwesomeEntryViewHolder();
          viewHolder.titleView = (TextView) convertView.findViewById(R.id.title);
          viewHolder.urlView = (TextView) convertView.findViewById(R.id.url);
          viewHolder.faviconView = (ImageView) convertView.findViewById(R.id.favicon);
          viewHolder.bookmarkIconView = (ImageView) convertView.findViewById(R.id.bookmark_icon);

          convertView.setTag(viewHolder);
        } else {
          viewHolder = (AwesomeEntryViewHolder) convertView.getTag();
        }

        position -= getSuggestEngineCount();
        Cursor cursor = getCursor();
        if (!cursor.moveToPosition(position))
          throw new IllegalStateException("Couldn't move cursor to position " + position);

        updateTitle(viewHolder.titleView, cursor);
        updateUrl(viewHolder.urlView, cursor);
        updateBookmarkIcon(viewHolder.bookmarkIconView, cursor);
        displayFavicon(viewHolder);
      }

      return convertView;
    }
Пример #24
0
 @Test
 public void shouldNotfindViewWithTagReturnNull() {
   root.removeAllViews();
   child1.setTag("tag1");
   child2.setTag("tag2");
   child3.setTag("tag3");
   root.addView(child1);
   root.addView(child2);
   root.addView(child3, 1);
   assertThat(root.findViewWithTag("tag21"), equalTo(null));
   assertThat((ViewGroup) root.findViewWithTag("tag23"), equalTo(null));
 }
Пример #25
0
 public static View createView(Context context, APIConnection conn) {
   View v = null;
   if (conn.getType().equals(MockConnection.type))
     v = createMockConnectionView(context, (MockConnection) conn);
   else if (conn.getType().equals(TwitterConnection.type))
     v = createTwitterConnectionView(context, (TwitterConnection) conn);
   if (v != null) {
     v.setTag(R.id.kIDTag, conn.getId());
     v.setTag(R.id.kTypeTag, conn.getType());
   }
   return v;
 }
  @Override
  public View getView(int i, View view, ViewGroup viewGroup) {
    View v = view;
    TextView name, id;
    ImageView picture;
    final ImageView pictureRead;

    if (v == null) {
      v = mInflater.inflate(R.layout.grid_item, viewGroup, false);
      v.setTag(R.id.id_category, v.findViewById(R.id.id_category));
      v.setTag(R.id.picture_category, v.findViewById(R.id.picture_category));
      v.setTag(R.id.picture_category_read, v.findViewById(R.id.picture_category_read));
      v.setTag(R.id.label_category, v.findViewById(R.id.label_category));
    }

    id = (TextView) v.getTag(R.id.id_category);
    picture = (ImageView) v.getTag(R.id.picture_category);
    pictureRead = (ImageView) v.getTag(R.id.picture_category_read);
    name = (TextView) v.getTag(R.id.label_category);

    Item item = getItem(i);

    // id
    id.setText(item.id);
    // image
    if (!item.image_name.isEmpty()) {
      Picasso.with(context)
          .load(Utils.BASE_URL + Utils.URL_UPLOAD + item.image_name)
          .fit()
          .centerCrop()
          .into(picture);
    } else {
      Picasso.with(context).load(R.drawable.default_category).fit().centerCrop().into(picture);
    }
    // if book is already read or not
    SharedPreferences sharedPref =
        context.getSharedPreferences("readingchallenge", Context.MODE_PRIVATE);
    if (sharedPref.getInt(context.getString(R.string.category_id) + item.id, 0) == 1) {
      Picasso.with(context).load(R.drawable.circle_check).into(pictureRead);
      pictureRead.setVisibility(View.VISIBLE);
    } else {
      pictureRead.setVisibility(View.GONE);
    }
    // label
    if (((ReadingChallengeApplication) context.getApplicationContext())
        .getLanguage()
        .equals(Utils.FR)) {
      name.setText(item.name_fr);
    } else {
      name.setText(item.name);
    }
    return v;
  }
Пример #27
0
 @Test
 public void shouldfindViewWithTag() {
   root.removeAllViews();
   child1.setTag("tag1");
   child2.setTag("tag2");
   child3.setTag("tag3");
   root.addView(child1);
   root.addView(child2);
   root.addView(child3, 1);
   assertThat(root.findViewWithTag("tag1"), sameInstance(child1));
   assertThat(root.findViewWithTag("tag2"), sameInstance(child2));
   assertThat((ViewGroup) root.findViewWithTag("tag3"), sameInstance(child3));
 }
  protected View createPage(int index) {
    View v = mInflater.inflate(mPageLayout, null);

    ScrollView sv = (ScrollView) v.findViewById(R.id.page_scroller);
    if (sv == null) v.setTag(new Boolean(false));
    else v.setTag(new Boolean(true));

    updateViewForUser(v, true, false);

    // Get page on different thread
    new PageRetriever(v, index).start();

    return v;
  }
Пример #29
0
  // @SuppressLint("UseValueOf")
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    // 观察convertView随ListView滚动情况
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.manage_collection_lv_layout, null);
      holder = new ViewHolder();
      // 得到各个控件的对象
      holder.tvIcon = (ImageView) convertView.findViewById(R.id.manage_iv_icon);
      holder.tvName = (TextView) convertView.findViewById(R.id.manage_tv_name);
      holder.proessBarStarLevel =
          (RatingBar) convertView.findViewById(R.id.manage_ratingbar_starlevel);
      holder.tvStarLevel = (TextView) convertView.findViewById(R.id.manage_tv_startlevel);
      holder.tvDowntimes = (TextView) convertView.findViewById(R.id.manage_tv_downtimes);
      holder.tvSize = (TextView) convertView.findViewById(R.id.manage_tv_size);
      holder.btnDownInstall = (Button) convertView.findViewById(R.id.manage_btn_downinstall);
      holder.btnDelete = (Button) convertView.findViewById(R.id.manage_btn_delcollection);
      holder.proessBarStarLevel.setMax(5);
      // 绑定ViewHolder对象
      convertView.setTag(holder);
    } else {
      // 取出ViewHolder对象
      holder = (ViewHolder) convertView.getTag();
    }
    CollectionInfo gameInfo = (CollectionInfo) group.get(position);
    if (null != gameInfo) {
      holder.tvName.setText(gameInfo.getName());

      holder.proessBarStarLevel.setProgress((int) Float.parseFloat(gameInfo.getStarLevel()));
      holder.tvStarLevel.setText(gameInfo.getStarLevel() + mContext.getString(R.string.game_share));
      holder.tvSize.setText(
          String.valueOf(StringTool.StringToFloat(gameInfo.getSize()))
              + mContext.getString(R.string.game_MB));
      holder.tvDowntimes.setText(
          String.valueOf(gameInfo.getDownCounts()) + mContext.getString(R.string.game_down_num));
      bindRoundImg(gameInfo.getIconMin(), holder.tvIcon, 10);
      convertView.setOnClickListener(detail);
      // 为下载安装按钮提供监听
      holder.btnDownInstall.setOnClickListener(new DownLoadorInstallListern());
      // 为移除收藏提供监听
      holder.btnDelete.setOnClickListener(new CollectionDeleteListern());
    }
    convertView.setTag(convertView.getId(), Integer.valueOf(position));
    // 为每个按钮设置一个tag..
    holder.btnDownInstall.setTag(Integer.valueOf(position));
    holder.btnDelete.setTag(Integer.valueOf(position));
    return convertView;
  }
Пример #30
0
  @Override
  public View getView(int position, View convertView, ViewGroup arg2) {
    // TODO Auto-generated method stub
    ViewHolder holder = null;
    if (convertView == null) {
      holder = new ViewHolder();
      convertView =
          LayoutInflater.from(context).inflate(R.layout.sales_ware_summer_list_item, null);
      holder.textView1 = (TextView) convertView.findViewById(R.id.waresummer_kuanhao);
      holder.textView2 = (TextView) convertView.findViewById(R.id.waresummer_count);
      holder.textView3 = (TextView) convertView.findViewById(R.id.waresummer_money);
      holder.textView4 = (TextView) convertView.findViewById(R.id.waresummer_mincheng);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    Order order = list.get(position);
    holder.textView1.setText(order.getOrderDate());
    holder.textView2.setText(order.getCardNum());
    holder.textView3.setText(order.getKuanHao());
    holder.textView4.setText(order.getKuanHao());

    int[] colors = {Color.WHITE, Color.rgb(219, 238, 244)}; // RGB颜色

    convertView.setBackgroundColor(colors[position % 2]); // 每隔item之间颜色不同
    return convertView;
  }