예제 #1
0
  /** Open the clicked contacts sms history view */
  public void clickedText(View view) {
    try {
      final int position = (Integer) view.getTag();
      final Conversation conversation = msgList.get(position);
      final String address =
          conversation.hasLocalNumber() ? conversation.getAddress() : conversation.getFixedNumber();

      Intent intent = new Intent(view.getContext(), ConversationActivity.class);
      intent.putExtra("position", position);
      intent.putExtra("name", getContactByNbr(address));
      intent.putExtra("number", conversation.getFixedNumber());
      startActivity(intent);
    } catch (Exception e) {

    }
  }
예제 #2
0
    @Override
    public View getView(int i, final View v, ViewGroup viewGroup) {
      View view = v;

      try {
        final ViewHolder holder;

        if (i < 0 || i >= list.size()) {
          return null;
        }

        if (view == null) {
          LayoutInflater inflater = ((Activity) context).getLayoutInflater();
          view = inflater.inflate(R.layout.sms_item, viewGroup, false);
          holder = new ViewHolder();
          holder.contactName = (TextView) view.findViewById(R.id.sender);
          holder.date = (TextView) view.findViewById(R.id.date);
          view.setTag(holder);
        } else {
          holder = (ViewHolder) view.getTag();
        }

        // get the current sms conversation
        Conversation currentConv = list.get(i);
        Set<ListableMessage> messageSet = currentConv.getSmsList();
        List<ListableMessage> messageList = new ArrayList<>();
        messageList.addAll(messageSet);
        Collections.sort(messageList);
        Button tryButton = (Button) view.findViewById(R.id.imageButton);

        // Link an sms to the playbutton
        int counter = messageList.size() - 1;

        while (messageList.get(counter).isSent() && counter >= 1) {
          counter--;
        }
        if (!messageList.get(counter).isRead()) {
          tryButton.setBackgroundResource(R.drawable.new_message_1);
        } else {
          tryButton.setBackgroundResource(R.drawable.old_message_1);
        }
        view.findViewById(R.id.imageButton).setTag(messageList.get(counter));
        String address =
            currentConv.hasLocalNumber() ? currentConv.getAddress() : currentConv.getFixedNumber();
        // set the correct data of the element
        holder.contactName.setText(getContactByNbr(address));
        holder.contactName.setPaintFlags(
            holder.contactName.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
        holder.contactName.setTag(i);

        Object[] messages = list.get(i).getSmsList().toArray();
        holder.date.setText(
            DateDiffUtility.callDateToString(
                ((ListableMessage) messages[messages.length - 1]).getTimestamp().getTimeInMillis(),
                context));
      } catch (Exception e) {

      }

      return view;
    }