예제 #1
0
 @Override
 public void onBindViewHolder(ViewHolder holder, int position) {
   final TreeNode item = getItem(position);
   int itemViewType = getItemViewType(position);
   View convertView = holder.itemView;
   convertView.setTag(position);
   if (type == RosterHelper.ACTIVE_CONTACTS) {
     RosterItemView rosterItemView = (RosterItemView) holder.itemView;
     rosterItemView.setNull();
     if (item != null) {
       if (itemViewType == ITEM_LAYER) {
         rosterItemView.addLayer(item.getText());
       }
       if (itemViewType == ITEM_CONTACT) {
         Contact contact = (Contact) item;
         populateFromContact(
             rosterItemView, RosterHelper.getInstance(), contact.getProtocol(), contact);
       }
       setShowDivider(rosterItemView, getItemViewType(position + 1) == ITEM_CONTACT);
     }
     rosterItemView.repaint();
   } else {
     if (itemViewType == ITEM_PROTOCOL) {
       RosterItemView rosterItemView = (RosterItemView) ((ViewGroup) convertView).getChildAt(0);
       ProgressBar progressBar = (ProgressBar) ((ViewGroup) convertView).getChildAt(1);
       MyImageButton imageButton = (MyImageButton) ((ViewGroup) convertView).getChildAt(2);
       rosterItemView.setNull();
       if (item != null) {
         progressBar.setVisibility(
             ((ProtocolBranch) item).getProtocol().getConnectingProgress() != 100
                 ? View.VISIBLE
                 : View.GONE);
         imageButton.setTag(item);
         imageButton.setOnClickListener(this);
         populateFromProtocol(rosterItemView, (ProtocolBranch) item);
         setShowDivider(rosterItemView, true);
       }
       rosterItemView.repaint();
     } else if (itemViewType == ITEM_GROUP) {
       RosterItemView rosterItemView = (RosterItemView) convertView;
       rosterItemView.setNull();
       if (item != null) {
         populateFromGroup(rosterItemView, (Group) item);
         setShowDivider(rosterItemView, true);
       }
       rosterItemView.repaint();
     } else if (itemViewType == ITEM_CONTACT) {
       RosterItemView rosterItemView = (RosterItemView) convertView;
       rosterItemView.setNull();
       if (item != null) {
         Contact contact = (Contact) item;
         populateFromContact(
             rosterItemView, RosterHelper.getInstance(), contact.getProtocol(), contact);
         setShowDivider(rosterItemView, true);
       }
       rosterItemView.repaint();
     }
   }
 }
예제 #2
0
 @Override
 public int getItemViewType(int position) {
   TreeNode node = getItem(position);
   if (node != null) {
     if (node.getType() == TreeNode.LAYER) return ITEM_LAYER;
     if (node.getType() == TreeNode.PROTOCOL) return ITEM_PROTOCOL;
     if (node.getType() == TreeNode.GROUP) return ITEM_GROUP;
     if (node.getType() == TreeNode.CONTACT) return ITEM_CONTACT;
   }
   return -1;
 }
예제 #3
0
 public boolean isEnabled(int position) {
   TreeNode node = items.get(position);
   if (node.getType() == TreeNode.LAYER) return false;
   return true;
 }