Example usage for android.text SpannableStringBuilder append

List of usage examples for android.text SpannableStringBuilder append

Introduction

In this page you can find the example usage for android.text SpannableStringBuilder append.

Prototype

public SpannableStringBuilder append(char text) 

Source Link

Usage

From source file:cc.mintcoin.wallet.ui.RequestCoinsFragment.java

private void updateView() {
    if (!isResumed())
        return;/*from w w w.j  a  v a 2 s .  co m*/

    final String bitcoinRequest = determineBitcoinRequestStr(true);
    final byte[] paymentRequest = determinePaymentRequest(true);

    // update qr-code
    final int size = (int) (256 * getResources().getDisplayMetrics().density);
    final String qrContent;
    if (config.getQrPaymentRequestEnabled())
        qrContent = "MINTCOIN:-" + Qr.encodeBinary(paymentRequest);
    else
        qrContent = bitcoinRequest;
    qrCodeBitmap = Qr.bitmap(qrContent, size);
    qrView.setImageBitmap(qrCodeBitmap);

    // update nfc ndef message
    final boolean nfcSuccess;
    if (config.getNfcPaymentRequestEnabled())
        nfcSuccess = Nfc.publishMimeObject(nfcManager, activity, Constants.MIMETYPE_PAYMENTREQUEST,
                paymentRequest, false);
    else
        nfcSuccess = Nfc.publishUri(nfcManager, activity, bitcoinRequest);

    // update initiate request message
    final SpannableStringBuilder initiateText = new SpannableStringBuilder(
            getString(R.string.request_coins_fragment_initiate_request_qr));
    if (nfcSuccess)
        initiateText.append(' ').append(getString(R.string.request_coins_fragment_initiate_request_nfc));
    initiateRequestView.setText(initiateText);

    // focus linking
    final int activeAmountViewId = amountCalculatorLink.activeTextView().getId();
    addressView.setNextFocusUpId(activeAmountViewId);
}

From source file:com.guldencoin.androidwallet.nlg.ui.RequestCoinsFragment.java

private void updateView() {
    if (!isResumed())
        return;/*from w w  w. j a  va 2 s .c  om*/

    final String bitcoinRequest = determineBitcoinRequestStr(true);
    final byte[] paymentRequest = determinePaymentRequest(true);

    // update qr-code
    final int size = (int) (256 * getResources().getDisplayMetrics().density);
    final String qrContent;
    if (config.getQrPaymentRequestEnabled())
        qrContent = "GULDENCOIN:-" + Qr.encodeBinary(paymentRequest);
    else
        qrContent = bitcoinRequest;
    qrCodeBitmap = Qr.bitmap(qrContent, size);
    qrView.setImageBitmap(qrCodeBitmap);

    // update nfc ndef message
    final boolean nfcSuccess;
    if (config.getNfcPaymentRequestEnabled())
        nfcSuccess = Nfc.publishMimeObject(nfcManager, activity, Constants.MIMETYPE_PAYMENTREQUEST,
                paymentRequest, false);
    else
        nfcSuccess = Nfc.publishUri(nfcManager, activity, bitcoinRequest);

    // update initiate request message
    final SpannableStringBuilder initiateText = new SpannableStringBuilder(
            getString(R.string.request_coins_fragment_initiate_request_qr));
    if (nfcSuccess)
        initiateText.append(' ').append(getString(R.string.request_coins_fragment_initiate_request_nfc));
    initiateRequestView.setText(initiateText);

    // update bluetooth message
    final boolean serviceRunning = application.isServiceRunning(AcceptBluetoothService.class);
    bluetoothEnabledView.setVisibility(
            bluetoothAdapter != null && bluetoothAdapter.isEnabled() && serviceRunning ? View.VISIBLE
                    : View.GONE);

    // focus linking
    final int activeAmountViewId = amountCalculatorLink.activeTextView().getId();
    addressView.setNextFocusUpId(activeAmountViewId);
}

From source file:com.ubercab.client.feature.notification.handler.TripNotificationHandler.java

private NotificationCompat.InboxStyle buildStyleInbox(NotificationCompat.Builder paramBuilder,
          TripNotificationData paramTripNotificationData, String paramString) {
      NotificationCompat.InboxStyle localInboxStyle = new NotificationCompat.InboxStyle(paramBuilder)
              .setSummaryText(paramString);
      Iterator localIterator = paramTripNotificationData.getFareSplitClients().iterator();
      while (localIterator.hasNext()) {
          TripNotificationData.FareSplitClient localFareSplitClient = (TripNotificationData.FareSplitClient) localIterator
                  .next();/* ww w  . java 2  s .  c  om*/
          SpannableString localSpannableString = new SpannableString(localFareSplitClient.getName());
          localSpannableString.setSpan(new StyleSpan(1), 0, localSpannableString.length(), 33);
          SpannableStringBuilder localSpannableStringBuilder = new SpannableStringBuilder();
          localSpannableStringBuilder.append(localSpannableString);
          localSpannableStringBuilder.append(" ");
          localSpannableStringBuilder.append(localFareSplitClient.getDisplayStatus(getContext()));
          localInboxStyle.addLine(localSpannableStringBuilder);
      }
      return localInboxStyle;
  }

From source file:org.hopestarter.wallet.ui.RequestCoinsFragment.java

private void updateView() {
    if (!isResumed())
        return;//from  ww  w  .  j a v a 2s  . c  o  m

    final String bitcoinRequest = determineBitcoinRequestStr(true);
    final byte[] paymentRequest = determinePaymentRequest(true);

    // update qr-code
    final int size = getResources().getDimensionPixelSize(R.dimen.bitmap_dialog_qr_size);
    final String qrContent;
    if (config.getQrPaymentRequestEnabled())
        qrContent = "BITCOIN:-" + Qr.encodeBinary(paymentRequest);
    else
        qrContent = bitcoinRequest;
    qrCodeBitmap = Qr.bitmap(qrContent, size);
    qrView.setImageBitmap(qrCodeBitmap);

    // update initiate request message
    final SpannableStringBuilder initiateText = new SpannableStringBuilder(
            getString(R.string.request_coins_fragment_initiate_request_qr));
    if (nfcAdapter != null && nfcAdapter.isEnabled())
        initiateText.append(' ').append(getString(R.string.request_coins_fragment_initiate_request_nfc));
    initiateRequestView.setText(initiateText);

    // focus linking
    final int activeAmountViewId = amountCalculatorLink.activeTextView().getId();
    acceptBluetoothPaymentView.setNextFocusUpId(activeAmountViewId);

    paymentRequestRef.set(paymentRequest);
}

From source file:com.deliciousdroid.fragment.ViewBookmarkFragment.java

public void loadBookmark() {
    if (bookmark != null) {

        if (isMyself() && bookmark.getId() != 0) {
            try {
                int id = bookmark.getId();
                bookmark = BookmarkManager.GetById(id, base);
            } catch (ContentNotFoundException e) {
            }//from  w  w  w .  java2 s . c o m
        }

        if (viewType == BookmarkViewType.VIEW) {
            mBookmarkView.setVisibility(View.VISIBLE);
            readSection.setVisibility(View.GONE);
            mWebContent.setVisibility(View.GONE);
            if (isMyself()) {
                Date d = new Date(bookmark.getTime());

                mTitle.setText(bookmark.getDescription());
                mUrl.setText(bookmark.getUrl());
                mNotes.setText(bookmark.getNotes());
                mTime.setText(d.toString());
                mUsername.setText(bookmark.getAccount());

                if (mIcon != null) {
                    if (!bookmark.getShared()) {
                        mIcon.setImageResource(R.drawable.padlock);
                    }
                }

                SpannableStringBuilder tagBuilder = new SpannableStringBuilder();

                for (Tag t : bookmark.getTags()) {
                    addTag(tagBuilder, t, tagOnClickListener);
                }

                mTags.setText(tagBuilder);
                mTags.setMovementMethod(LinkMovementMethod.getInstance());
            } else {

                Date d = new Date(bookmark.getTime());

                if (bookmark.getDescription() != null && !bookmark.getDescription().equals("null"))
                    mTitle.setText(bookmark.getDescription());

                mUrl.setText(bookmark.getUrl());

                if (bookmark.getNotes() != null && !bookmark.getNotes().equals("null"))
                    mNotes.setText(bookmark.getNotes());

                mTime.setText(d.toString());

                SpannableStringBuilder tagBuilder = new SpannableStringBuilder();

                for (Tag t : bookmark.getTags()) {
                    addTag(tagBuilder, t, userTagOnClickListener);
                }

                mTags.setText(tagBuilder);
                mTags.setMovementMethod(LinkMovementMethod.getInstance());

                if (bookmark.getAccount() != null) {
                    SpannableStringBuilder builder = new SpannableStringBuilder();
                    int start = builder.length();
                    builder.append(bookmark.getAccount());
                    int end = builder.length();

                    AccountSpan span = new AccountSpan(bookmark.getAccount());
                    span.setOnAccountClickListener(accountOnClickListener);

                    builder.setSpan(span, start, end, 0);

                    mUsername.setText(builder);
                }

                mUsername.setMovementMethod(LinkMovementMethod.getInstance());
            }
        } else if (viewType == BookmarkViewType.READ) {
            new GetArticleTask().execute(bookmark.getUrl());
        } else if (viewType == BookmarkViewType.WEB) {
            showInWebView();
        }
    }
}

From source file:com.android.messaging.datamodel.MessageNotificationState.java

public static Notification buildConversationPageForWearable(final String conversationId, int participantCount) {
    final Context context = Factory.get().getApplicationContext();

    // Limit the number of messages to show. We just want enough to provide context for the
    // notification. Fetch one more than we need, so we can tell if there are more messages
    // before the one we're showing.
    // TODO: in the query, a multipart message will contain a row for each part.
    // We might need a smarter GROUP_BY. On the other hand, we might want to show each of the
    // parts as separate messages on the wearable.
    final int limit = MAX_MESSAGES_IN_WEARABLE_PAGE + 1;

    final List<CharSequence> messages = Lists.newArrayList();
    boolean hasSeenMessagesBeforeNotification = false;
    Cursor convMessageCursor = null;
    try {/*from   w w w  .  j  av a2s  .  c o m*/
        final DatabaseWrapper db = DataModel.get().getDatabase();

        final String[] queryArgs = { conversationId };
        final String convPageSql = ConversationMessageData.getWearableQuerySql() + " LIMIT " + limit;
        convMessageCursor = db.rawQuery(convPageSql, queryArgs);

        if (convMessageCursor == null || !convMessageCursor.moveToFirst()) {
            return null;
        }
        final ConversationMessageData convMessageData = new ConversationMessageData();

        final HashMap<String, Integer> firstNames = scanFirstNames(conversationId);
        do {
            convMessageData.bind(convMessageCursor);

            final String authorFullName = convMessageData.getSenderFullName();
            final String authorFirstName = convMessageData.getSenderFirstName();
            String text = convMessageData.getText();

            final boolean isSmsPushNotification = convMessageData.getIsMmsNotification();

            // if auto-download was off to show a message to tap to download the message. We
            // might need to get that working again.
            if (isSmsPushNotification && text != null) {
                text = convertHtmlAndStripUrls(text).toString();
            }
            // Skip messages without any content
            if (TextUtils.isEmpty(text) && !convMessageData.hasAttachments()) {
                continue;
            }
            // Track whether there are messages prior to the one(s) shown in the notification.
            if (convMessageData.getIsSeen()) {
                hasSeenMessagesBeforeNotification = true;
            }

            final boolean usedMoreThanOnce = firstNameUsedMoreThanOnce(firstNames, authorFirstName);
            String displayName = usedMoreThanOnce ? authorFullName : authorFirstName;
            if (TextUtils.isEmpty(displayName)) {
                if (convMessageData.getIsIncoming()) {
                    displayName = convMessageData.getSenderDisplayDestination();
                    if (TextUtils.isEmpty(displayName)) {
                        displayName = context.getString(R.string.unknown_sender);
                    }
                } else {
                    displayName = context.getString(R.string.unknown_self_participant);
                }
            }

            Uri attachmentUri = null;
            String attachmentType = null;
            final List<MessagePartData> attachments = convMessageData.getAttachments();
            for (final MessagePartData messagePartData : attachments) {
                // Look for the first attachment that's not the text piece.
                if (!messagePartData.isText()) {
                    attachmentUri = messagePartData.getContentUri();
                    attachmentType = messagePartData.getContentType();
                    break;
                }
            }

            final CharSequence message = BugleNotifications.buildSpaceSeparatedMessage(displayName, text,
                    attachmentUri, attachmentType);
            messages.add(message);

        } while (convMessageCursor.moveToNext());
    } finally {
        if (convMessageCursor != null) {
            convMessageCursor.close();
        }
    }

    // If there is no conversation history prior to what is already visible in the main
    // notification, there's no need to include the conversation log, too.
    final int maxMessagesInNotification = getMaxMessagesInConversationNotification();
    if (!hasSeenMessagesBeforeNotification && messages.size() <= maxMessagesInNotification) {
        return null;
    }

    final SpannableStringBuilder bigText = new SpannableStringBuilder();
    // There is at least 1 message prior to the first one that we're going to show.
    // Indicate this by inserting an ellipsis at the beginning of the conversation log.
    if (convMessageCursor.getCount() == limit) {
        bigText.append(context.getString(R.string.ellipsis) + "\n\n");
        if (messages.size() > MAX_MESSAGES_IN_WEARABLE_PAGE) {
            messages.remove(messages.size() - 1);
        }
    }
    // Messages are sorted in descending timestamp order, so iterate backwards
    // to get them back in ascending order for display purposes.
    for (int i = messages.size() - 1; i >= 0; --i) {
        bigText.append(messages.get(i));
        if (i > 0) {
            bigText.append("\n\n");
        }
    }
    ++participantCount; // Add in myself

    if (participantCount > 2) {
        final SpannableString statusText = new SpannableString(context.getResources()
                .getQuantityString(R.plurals.wearable_participant_count, participantCount, participantCount));
        statusText.setSpan(
                new ForegroundColorSpan(
                        context.getResources().getColor(R.color.wearable_notification_participants_count)),
                0, statusText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        bigText.append("\n\n").append(statusText);
    }

    final NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context);
    final NotificationCompat.Style notifStyle = new NotificationCompat.BigTextStyle(notifBuilder)
            .bigText(bigText);
    notifBuilder.setStyle(notifStyle);

    final WearableExtender wearableExtender = new WearableExtender();
    wearableExtender.setStartScrollBottom(true);
    notifBuilder.extend(wearableExtender);

    return notifBuilder.build();
}

From source file:org.catrobat.catroid.ui.MainMenuActivity.java

private void setMainMenuButtonContinueText() {
    Button mainMenuButtonContinue = (Button) this.findViewById(R.id.main_menu_button_continue);
    TextAppearanceSpan textAppearanceSpan = new TextAppearanceSpan(this, R.style.MainMenuButtonTextSecondLine);
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
    String mainMenuContinue = this.getString(R.string.main_menu_continue);

    spannableStringBuilder.append(mainMenuContinue);
    spannableStringBuilder.append("\n");
    spannableStringBuilder.append(Utils.getCurrentProjectName(this));

    spannableStringBuilder.setSpan(textAppearanceSpan, mainMenuContinue.length() + 1,
            spannableStringBuilder.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);

    mainMenuButtonContinue.setText(spannableStringBuilder);
}

From source file:tw.idv.gasolin.pycontw2012.ui.SessionDetailFragment.java

/**
 * Handle {@link SessionsQuery} {@link Cursor}.
 *//* w  w  w . j  av  a  2s . com*/
private void onSessionQueryComplete(Cursor cursor) {
    try {
        mSessionCursor = true;
        if (!cursor.moveToFirst()) {
            return;
        }

        // Format time block this session occupies
        final long blockStart = cursor.getLong(SessionsQuery.BLOCK_START);
        final long blockEnd = cursor.getLong(SessionsQuery.BLOCK_END);
        final Locale locale = getResources().getConfiguration().locale;
        final String roomName = UIUtils.getBestLocaleString(locale, cursor.getString(SessionsQuery.ROOM_NAME),
                cursor.getString(SessionsQuery.ROOM_NAME_ZH_TW),
                cursor.getString(SessionsQuery.ROOM_NAME_ZH_CN));
        final String subtitle = UIUtils.formatSessionSubtitle(blockStart, blockEnd, roomName, getActivity());

        mTitleString = cursor.getString(SessionsQuery.TITLE);
        mTitle.setText(mTitleString);
        mSubtitle.setText(subtitle);

        mUrl = cursor.getString(SessionsQuery.URL);
        if (TextUtils.isEmpty(mUrl)) {
            mUrl = "";
        }

        mHashtag = cursor.getString(SessionsQuery.HASHTAG);
        mTagDisplay = (TextView) mRootView.findViewById(R.id.session_tags_button);
        if (!TextUtils.isEmpty(mHashtag)) {
            // Create the button text
            SpannableStringBuilder sb = new SpannableStringBuilder();
            sb.append(getString(R.string.tag_stream) + " ");
            int boldStart = sb.length();
            sb.append(getHashtagsString());
            sb.setSpan(sBoldSpan, boldStart, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

            mTagDisplay.setText(sb);

            mTagDisplay.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    Intent intent = new Intent(getActivity(), TagStreamActivity.class);
                    intent.putExtra(TagStreamFragment.EXTRA_QUERY, getHashtagsString());
                    startActivity(intent);
                }
            });
        } else {
            mTagDisplay.setVisibility(View.GONE);
        }

        mRoomId = cursor.getString(SessionsQuery.ROOM_ID);

        // Unregister around setting checked state to avoid triggering
        // listener since change isn't user generated.
        mStarred.setOnCheckedChangeListener(null);
        mStarred.setChecked(cursor.getInt(SessionsQuery.STARRED) != 0);
        mStarred.setOnCheckedChangeListener(this);

        final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT);
        if (!TextUtils.isEmpty(sessionAbstract)) {
            UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract);
            mAbstract.setVisibility(View.VISIBLE);
            mHasSummaryContent = true;
        } else {
            mAbstract.setVisibility(View.GONE);
        }

        // Show empty message when all data is loaded, and nothing to show
        if (mSpeakersCursor && !mHasSummaryContent) {
            mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE);
        }

        AnalyticsUtils.getInstance(getActivity()).trackPageView("/Sessions/" + mTitleString);

        updateLinksTab(cursor);

    } finally {
        cursor.close();
    }
}

From source file:com.gsma.rcs.ri.messaging.adapter.TalkCursorAdapter.java

private CharSequence formatMessageWithSmiley(String txt) {
    SpannableStringBuilder buf = new SpannableStringBuilder();
    if (!TextUtils.isEmpty(txt)) {
        SmileyParser smileyParser = new SmileyParser(txt, mSmileyResources);
        smileyParser.parse();//  w w w .  ja  v a  2 s . c o  m
        buf.append(smileyParser.getSpannableString(mContext));
    }
    return buf;
}

From source file:com.battlelancer.seriesguide.service.NotificationService.java

private void onNotify(final Cursor upcomingEpisodes, List<Integer> notifyPositions, long latestAirtime) {
    final Context context = getApplicationContext();

    CharSequence tickerText;//from  www. ja  va  2s  .  c  om
    CharSequence contentTitle;
    CharSequence contentText;
    PendingIntent contentIntent;
    // base intent for task stack
    final Intent showsIntent = new Intent(context, ShowsActivity.class);
    showsIntent.putExtra(ShowsActivity.InitBundle.SELECTED_TAB, ShowsActivity.InitBundle.INDEX_TAB_UPCOMING);

    final int count = notifyPositions.size();
    if (count == 1) {
        // notify in detail about one episode
        Timber.d("Notifying about 1 new episode");
        upcomingEpisodes.moveToPosition(notifyPositions.get(0));

        final String showTitle = upcomingEpisodes.getString(NotificationQuery.SHOW_TITLE);
        tickerText = getString(R.string.upcoming_show, showTitle);
        contentTitle = showTitle + " "
                + Utils.getEpisodeNumber(this, upcomingEpisodes.getInt(NotificationQuery.SEASON),
                        upcomingEpisodes.getInt(NotificationQuery.NUMBER));

        // "8:00 PM on Network"
        final String releaseTime = TimeTools.formatToLocalReleaseTime(this, TimeTools.getEpisodeReleaseTime(
                this, upcomingEpisodes.getLong(NotificationQuery.EPISODE_FIRST_RELEASE_MS)));
        final String network = upcomingEpisodes.getString(NotificationQuery.NETWORK);
        contentText = getString(R.string.upcoming_show_detailed, releaseTime, network);

        Intent episodeDetailsIntent = new Intent(context, EpisodesActivity.class);
        episodeDetailsIntent.putExtra(EpisodesActivity.InitBundle.EPISODE_TVDBID,
                upcomingEpisodes.getInt(NotificationQuery._ID));
        episodeDetailsIntent.putExtra(KEY_EPISODE_CLEARED_TIME, latestAirtime);

        contentIntent = TaskStackBuilder.create(context).addNextIntent(showsIntent)
                .addNextIntent(episodeDetailsIntent)
                .getPendingIntent(REQUEST_CODE_SINGLE_EPISODE, PendingIntent.FLAG_CANCEL_CURRENT);
    } else {
        // notify about multiple episodes
        Timber.d("Notifying about " + count + " new episodes");
        tickerText = getString(R.string.upcoming_episodes);
        contentTitle = getString(R.string.upcoming_episodes_number, count);
        contentText = getString(R.string.upcoming_display);

        contentIntent = TaskStackBuilder.create(context)
                .addNextIntent(showsIntent.putExtra(KEY_EPISODE_CLEARED_TIME, latestAirtime))
                .getPendingIntent(REQUEST_CODE_MULTIPLE_EPISODES, PendingIntent.FLAG_CANCEL_CURRENT);
    }

    final NotificationCompat.Builder nb = new NotificationCompat.Builder(context);

    if (AndroidUtils.isJellyBeanOrHigher()) {
        Timber.d("Building rich notification (JB+)");
        // JELLY BEAN and above
        if (count == 1) {
            // single episode
            upcomingEpisodes.moveToPosition(notifyPositions.get(0));
            maybeSetPoster(context, nb, upcomingEpisodes.getString(NotificationQuery.POSTER));

            final String episodeTitle = upcomingEpisodes.getString(NotificationQuery.TITLE);
            final String episodeSummary = upcomingEpisodes.getString(NotificationQuery.OVERVIEW);

            final SpannableStringBuilder bigText = new SpannableStringBuilder();
            bigText.append(TextUtils.isEmpty(episodeTitle) ? "" : episodeTitle);
            bigText.setSpan(new StyleSpan(Typeface.BOLD), 0, bigText.length(), 0);
            bigText.append("\n");
            bigText.append(TextUtils.isEmpty(episodeSummary) ? "" : episodeSummary);

            nb.setStyle(new NotificationCompat.BigTextStyle().bigText(bigText).setSummaryText(contentText));

            // Action button to check in
            Intent checkInActionIntent = new Intent(context, QuickCheckInActivity.class);
            checkInActionIntent.putExtra(QuickCheckInActivity.InitBundle.EPISODE_TVDBID,
                    upcomingEpisodes.getInt(NotificationQuery._ID));
            checkInActionIntent
                    .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            PendingIntent checkInIntent = PendingIntent.getActivity(context, REQUEST_CODE_ACTION_CHECKIN,
                    checkInActionIntent, PendingIntent.FLAG_CANCEL_CURRENT);
            nb.addAction(R.drawable.ic_action_checkin, getString(R.string.checkin), checkInIntent);
        } else {
            // multiple episodes
            NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();

            // display at most the first five
            for (int displayIndex = 0; displayIndex < Math.min(count, 5); displayIndex++) {
                if (!upcomingEpisodes.moveToPosition(notifyPositions.get(displayIndex))) {
                    // could not go to the desired position (testing just in case)
                    break;
                }

                final SpannableStringBuilder lineText = new SpannableStringBuilder();

                // show title
                String showTitle = upcomingEpisodes.getString(NotificationQuery.SHOW_TITLE);
                lineText.append(TextUtils.isEmpty(showTitle) ? "" : showTitle);
                lineText.setSpan(new StyleSpan(Typeface.BOLD), 0, lineText.length(), 0);

                lineText.append(" ");

                // "8:00 PM on Network"
                String releaseTime = TimeTools.formatToLocalReleaseTime(this, TimeTools.getEpisodeReleaseTime(
                        this, upcomingEpisodes.getLong(NotificationQuery.EPISODE_FIRST_RELEASE_MS)));
                String network = upcomingEpisodes.getString(NotificationQuery.NETWORK);
                lineText.append(getString(R.string.upcoming_show_detailed, releaseTime, network));

                inboxStyle.addLine(lineText);
            }

            // tell if we could not display all episodes
            if (count > 5) {
                inboxStyle.setSummaryText(getString(R.string.more, count - 5));
            }

            nb.setStyle(inboxStyle);
            nb.setContentInfo(String.valueOf(count));
        }
    } else {
        // ICS and below
        if (count == 1) {
            // single episode
            upcomingEpisodes.moveToPosition(notifyPositions.get(0));
            maybeSetPoster(context, nb, upcomingEpisodes.getString(NotificationQuery.POSTER));
        }
    }

    // notification sound
    final String ringtoneUri = NotificationSettings.getNotificationsRingtone(context);
    // If the string is empty, the user chose silent...
    if (ringtoneUri.length() != 0) {
        // ...otherwise set the specified ringtone
        Timber.d("Notification has sound");
        nb.setSound(Uri.parse(ringtoneUri));
    }
    // vibration
    if (NotificationSettings.isNotificationVibrating(context)) {
        Timber.d("Notification vibrates");
        nb.setVibrate(VIBRATION_PATTERN);
    }
    nb.setDefaults(Notification.DEFAULT_LIGHTS);
    nb.setWhen(System.currentTimeMillis());
    nb.setAutoCancel(true);
    nb.setTicker(tickerText);
    nb.setContentTitle(contentTitle);
    nb.setContentText(contentText);
    nb.setContentIntent(contentIntent);
    nb.setSmallIcon(R.drawable.ic_notification);
    nb.setColor(getResources().getColor(R.color.accent_primary));
    nb.setPriority(NotificationCompat.PRIORITY_DEFAULT);
    nb.setCategory(NotificationCompat.CATEGORY_EVENT);

    Timber.d("Setting delete intent with episode time: " + latestAirtime);
    Intent i = new Intent(this, NotificationService.class);
    i.putExtra(KEY_EPISODE_CLEARED_TIME, latestAirtime);
    PendingIntent deleteIntent = PendingIntent.getService(this, REQUEST_CODE_DELETE_INTENT, i,
            PendingIntent.FLAG_CANCEL_CURRENT);
    nb.setDeleteIntent(deleteIntent);

    // build the notification
    Notification notification = nb.build();

    // use string resource id, always unique within app
    final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(R.string.upcoming_show, notification);
}