@Override
  public View getView(int i, View convertView, ViewGroup viewGroup) {
    Holder holder;

    if (convertView == null) {
      holder = new Holder();
      if (getItemViewType(i) == LocalMessageType.INCOMING.getId()) {
        convertView = mInflater.inflate(R.layout.list_view_item_message_incoming, viewGroup, false);
      } else if (getItemViewType(i) == LocalMessageType.OUTGOING_NOT_RECEIVED.getId()) {
        convertView =
            mInflater.inflate(
                R.layout.list_view_item_message_outgoing_not_received, viewGroup, false);
      } else {
        convertView =
            mInflater.inflate(R.layout.list_view_item_message_outgoing_received, viewGroup, false);
      }
      holder.content = (TextView) convertView.findViewById(R.id.item_message_content);
      holder.sendDate = (TextView) convertView.findViewById(R.id.item_message_date);
      convertView.setTag(holder);
    } else {
      holder = (Holder) convertView.getTag();
    }

    Message item = getItem(i);
    holder.content.setText(item.getContent());
    holder.sendDate.setText(convertDate(item.getSendDate()));

    return convertView;
  }
Exemple #2
0
 public void enqueue(E content, double priority) {
   Holder holder = new Holder();
   holder.content = content;
   holder.priority = priority;
   if (first == null || first.priority > priority) {
     if (first != null) {
       others.add(0, first);
     }
     first = holder;
     return;
   }
   int i = 0;
   while (i < others.size() && holder.compareTo(others.get(i)) == 1) {
     i++;
   }
   others.add(i, holder);
 }