/**
   * Only used for header binding.
   *
   * @param message the message contents to bind
   */
  public void bind(CellBroadcastMessage message, boolean bSelected, boolean bRead) {
    mCbMessage = message;
    int backgroundId;
    if (bSelected) {
      backgroundId = R.drawable.list_selected_holo_light;
    } else {
      backgroundId =
          message.isRead()
              ? R.drawable.list_item_background_read
              : R.drawable.list_item_background_unread;
    }
    Drawable background = getResources().getDrawable(backgroundId);
    setBackground(background);

    mChannelView.setText(CellBroadcastResources.getDialogTitleResource(message));
    String time = message.getDateString(getContext());
    String splitStr[] = time.split(",");
    if (splitStr != null && splitStr.length == 3) {
      time = time.substring(time.indexOf(",") + 2);
    }
    Log.d("CellBroadcastListItem", "time = " + time);
    mDateView.setText(time);
    mMessageView.setText(message.getMessageBody());
    if (!bRead) {
      mPresenceView.setVisibility(View.VISIBLE);
    } else {
      mPresenceView.setVisibility(View.GONE);
    }
  }
  private static CharSequence formatMessage(CellBroadcastMessage message) {
    String body = message.getMessageBody();

    SpannableStringBuilder buf = new SpannableStringBuilder(body);

    // Unread messages are shown in bold
    if (!message.isRead()) {
      buf.setSpan(
          new StyleSpan(Typeface.BOLD), 0, buf.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    return buf;
  }
Exemple #3
0
 @Override
 public void onReceive(Context context, Intent intent) {
   String action = intent.getAction();
   if (CB_AREA_INFO_RECEIVED_ACTION.equals(action)) {
     Bundle extras = intent.getExtras();
     if (extras == null) {
       return;
     }
     CellBroadcastMessage cbMessage = (CellBroadcastMessage) extras.get("message");
     if (cbMessage != null && cbMessage.getServiceCategory() == 50) {
       String latestAreaInfo = cbMessage.getMessageBody();
       updateAreaInfo(latestAreaInfo);
     }
   }
 }