Example usage for android.text SpannableStringBuilder length

List of usage examples for android.text SpannableStringBuilder length

Introduction

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

Prototype

public int length() 

Source Link

Document

Return the number of chars in the buffer.

Usage

From source file:com.heath_bar.tvdb.EpisodeDetails.java

/** Populate the GUI with the data we've found */
public void PopulateStuff(TvEpisode theEpisode) {

    // Set Title/*from   ww  w  .  jav  a 2s  .  c  o  m*/
    TextView textview = (TextView) findViewById(R.id.title);
    textview.setVisibility(View.VISIBLE);
    textview.setText(theEpisode.getSeason() + "x" + String.format("%02d", theEpisode.getNumber()) + " "
            + theEpisode.getName());

    // Set Thumb
    if (theEpisode.getImage() != null
            && (theEpisode.getImage().getBitmap() == null || theEpisode.getImage().getUrl().equals(""))) {
        // do nothin
    } else {
        imageId = theEpisode.getImage().getId();
        ImageButton banner = (ImageButton) findViewById(R.id.episode_thumb);
        banner.setImageBitmap(theEpisode.getImage().getBitmap());
        banner.setVisibility(View.VISIBLE);
        banner.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                shareImage();
            }
        });
    }

    // Overview
    textview = (TextView) findViewById(R.id.overview_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.overview);
    textview.setVisibility(View.VISIBLE);
    textview.setText(theEpisode.getOverview());

    // Director
    textview = (TextView) findViewById(R.id.director_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.director);
    textview.setVisibility(View.VISIBLE);
    textview.setText(theEpisode.getDirector());

    // Writer
    textview = (TextView) findViewById(R.id.writer_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.writer);
    textview.setVisibility(View.VISIBLE);
    textview.setText(theEpisode.getWriter());

    // Rating
    textview = (TextView) findViewById(R.id.rating_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.rating);
    textview.setVisibility(View.VISIBLE);
    textview.setText(theEpisode.getRating() + " / 10");

    // First Aired
    textview = (TextView) findViewById(R.id.first_aired_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.first_aired);
    textview.setVisibility(View.VISIBLE);
    textview.setText(DateUtil.toString(theEpisode.getAirDate()));

    // Guest Stars
    textview = (TextView) findViewById(R.id.guest_stars_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.guest_stars);
    textview.setVisibility(View.VISIBLE);
    textview.setText(theEpisode.getGuestStars());

    textview = (TextView) findViewById(R.id.imdb_link);
    textview.setVisibility(View.VISIBLE);

    final String imdbId = theEpisode.getIMDB();
    if (imdbId != "") {
        SpannableStringBuilder ssb = new SpannableStringBuilder(getResources().getString(R.string.imdb));
        ssb.setSpan(new NonUnderlinedClickableSpan(getResources().getString(R.string.imdb)) {
            @Override
            public void onClick(View v) {
                Intent myIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://www.imdb.com/title/" + imdbId));
                startActivity(myIntent);
            }
        }, 0, ssb.length(), 0);

        ssb.setSpan(new TextAppearanceSpan(this, R.style.episode_link), 0, ssb.length(), 0); // Set the style of the text
        textview.setText(ssb, BufferType.SPANNABLE);
        textview.setMovementMethod(LinkMovementMethod.getInstance());
    }
}

From source file:org.kontalk.ui.GroupInfoFragment.java

private void showIdentityDialog(Contact c, boolean subscribed) {
    final String jid = c.getJID();
    final String dialogFingerprint;
    final String fingerprint;
    final boolean selfJid = Authenticator.isSelfJID(getContext(), jid);
    int titleResId = R.string.title_identity;
    String uid;//from  w w  w.  ja  va 2 s  . c  o m

    PGPPublicKeyRing publicKey = Keyring.getPublicKey(getContext(), jid, MyUsers.Keys.TRUST_UNKNOWN);
    if (publicKey != null) {
        PGPPublicKey pk = PGP.getMasterKey(publicKey);
        String rawFingerprint = PGP.getFingerprint(pk);
        fingerprint = PGP.formatFingerprint(rawFingerprint);

        uid = PGP.getUserId(pk, XmppStringUtils.parseDomain(jid));
        dialogFingerprint = selfJid ? null : rawFingerprint;
    } else {
        // FIXME using another string
        fingerprint = getString(R.string.peer_unknown);
        uid = null;
        dialogFingerprint = null;
    }

    if (Authenticator.isSelfJID(getContext(), jid)) {
        titleResId = R.string.title_identity_self;
    }

    SpannableStringBuilder text = new SpannableStringBuilder();

    if (c.getName() != null && c.getNumber() != null) {
        text.append(c.getName()).append('\n').append(c.getNumber());
    } else {
        int start = text.length();
        text.append(uid != null ? uid : c.getJID());
        text.setSpan(SystemUtils.getTypefaceSpan(Typeface.BOLD), start, text.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }

    text.append('\n').append(getString(R.string.text_invitation2)).append('\n');

    int start = text.length();
    text.append(fingerprint);
    text.setSpan(SystemUtils.getTypefaceSpan(Typeface.BOLD), start, text.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    int trustStringId;
    CharacterStyle[] trustSpans;

    if (subscribed) {
        int trustedLevel;
        if (c.isKeyChanged()) {
            // the key has changed and was not trusted yet
            trustedLevel = MyUsers.Keys.TRUST_UNKNOWN;
        } else {
            trustedLevel = c.getTrustedLevel();
        }

        switch (trustedLevel) {
        case MyUsers.Keys.TRUST_IGNORED:
            trustStringId = R.string.trust_ignored;
            trustSpans = new CharacterStyle[] { SystemUtils.getTypefaceSpan(Typeface.BOLD),
                    SystemUtils.getColoredSpan(getContext(), R.color.button_danger) };
            break;

        case MyUsers.Keys.TRUST_VERIFIED:
            trustStringId = R.string.trust_verified;
            trustSpans = new CharacterStyle[] { SystemUtils.getTypefaceSpan(Typeface.BOLD),
                    SystemUtils.getColoredSpan(getContext(), R.color.button_success) };
            break;

        case MyUsers.Keys.TRUST_UNKNOWN:
        default:
            trustStringId = R.string.trust_unknown;
            trustSpans = new CharacterStyle[] { SystemUtils.getTypefaceSpan(Typeface.BOLD),
                    SystemUtils.getColoredSpan(getContext(), R.color.button_danger) };
            break;
        }
    } else {
        trustStringId = R.string.status_notsubscribed;
        trustSpans = new CharacterStyle[] { SystemUtils.getTypefaceSpan(Typeface.BOLD), };
    }

    text.append('\n').append(getString(R.string.status_label));
    start = text.length();
    text.append(getString(trustStringId));
    for (CharacterStyle span : trustSpans)
        text.setSpan(span, start, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    MaterialDialog.Builder builder = new MaterialDialog.Builder(getContext()).content(text).title(titleResId);

    if (dialogFingerprint != null && subscribed) {
        builder.onAny(new MaterialDialog.SingleButtonCallback() {
            @Override
            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                switch (which) {
                case POSITIVE:
                    // trust the key
                    trustKey(jid, dialogFingerprint, MyUsers.Keys.TRUST_VERIFIED);
                    break;
                case NEUTRAL:
                    // ignore the key
                    trustKey(jid, dialogFingerprint, MyUsers.Keys.TRUST_IGNORED);
                    break;
                case NEGATIVE:
                    // untrust the key
                    trustKey(jid, dialogFingerprint, MyUsers.Keys.TRUST_UNKNOWN);
                    break;
                }
            }
        }).positiveText(R.string.button_accept).positiveColorRes(R.color.button_success)
                .neutralText(R.string.button_ignore).negativeText(R.string.button_refuse)
                .negativeColorRes(R.color.button_danger);
    } else if (!selfJid) {
        builder.onPositive(new MaterialDialog.SingleButtonCallback() {
            @Override
            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                openChat(jid);
            }
        }).positiveText(R.string.button_private_chat);
    }

    builder.show();
}

From source file:com.android.tv.guide.ProgramItemView.java

public void setValues(TableEntry entry, int selectedGenreId, long fromUtcMillis, long toUtcMillis,
        String gapTitle) {/*from  w w w. j  a  v a  2s. co m*/
    mTableEntry = entry;

    ViewGroup.LayoutParams layoutParams = getLayoutParams();
    layoutParams.width = entry.getWidth();
    setLayoutParams(layoutParams);

    String title = entry.program != null ? entry.program.getTitle() : null;
    String episode = entry.program != null ? entry.program.getEpisodeDisplayTitle(getContext()) : null;

    TextAppearanceSpan titleStyle = sGrayedOutProgramTitleStyle;
    TextAppearanceSpan episodeStyle = sGrayedOutEpisodeTitleStyle;

    if (entry.getWidth() < sVisibleThreshold) {
        setText(null);
    } else {
        if (entry.isGap()) {
            title = gapTitle;
            episode = null;
        } else if (entry.hasGenre(selectedGenreId)) {
            titleStyle = sProgramTitleStyle;
            episodeStyle = sEpisodeTitleStyle;
        }
        if (TextUtils.isEmpty(title)) {
            title = getResources().getString(R.string.program_title_for_no_information);
        }
        if (mTableEntry.scheduledRecording != null) {
            //TODO(dvr): use a proper icon for UI status.
            title = "" + title;
        }

        SpannableStringBuilder description = new SpannableStringBuilder();
        description.append(title);
        if (!TextUtils.isEmpty(episode)) {
            description.append('\n');

            // Add a 'zero-width joiner'/ZWJ in order to ensure we have the same line height for
            // all lines. This is a non-printing character so it will not change the horizontal
            // spacing however it will affect the line height. As we ensure the ZWJ has the same
            // text style as the title it will make sure the line height is consistent.
            description.append('\u200D');

            int middle = description.length();
            description.append(episode);

            description.setSpan(titleStyle, 0, middle, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            description.setSpan(episodeStyle, middle, description.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        } else {
            description.setSpan(titleStyle, 0, description.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        setText(description);
    }
    measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    mTextWidth = getMeasuredWidth() - getPaddingStart() - getPaddingEnd();
    int start = GuideUtils.convertMillisToPixel(entry.entryStartUtcMillis);
    int guideStart = GuideUtils.convertMillisToPixel(fromUtcMillis);
    layoutVisibleArea(guideStart - start);

    // Maximum width for us to use a ripple
    mMaxWidthForRipple = GuideUtils.convertMillisToPixel(fromUtcMillis, toUtcMillis);
}

From source file:com.roamprocess1.roaming4world.ui.messages.ConversationsAdapter.java

private CharSequence formatMessage(Cursor cursor) {
    SpannableStringBuilder buf = new SpannableStringBuilder();
    String remoteContactFull = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM_FULL));
    CallerInfo callerInfo = CallerInfo.getCallerInfoFromSipUri(mContext, remoteContactFull);

    System.out.println("remoteContactFull:" + remoteContactFull);

    if (callerInfo != null && callerInfo.contactExists) {
        buf.append(callerInfo.name);//from  w ww .ja  v a 2 s. c  o m
    } else {
        buf.append(SipUri.getDisplayedSimpleContact(remoteContactFull));
    }

    int counter = cursor.getInt(cursor.getColumnIndex("counter"));

    if (counter > 1) {
        buf.append(" (" + counter + ") ");
    }

    int read = cursor.getInt(cursor.getColumnIndex(SipMessage.FIELD_READ));
    // Unread messages are shown in bold
    if (read == 0) {
        buf.setSpan(STYLE_BOLD, 0, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    }
    System.out.println("return:" + buf);
    return buf;
}

From source file:com.googlecode.eyesfree.brailleback.NodeBrailler.java

/**
 * Formats {@code node} and its descendants, appending the result
 * to {@code sb}./*from   w w  w .jav a 2  s.c  o  m*/
 */
private void formatSubtree(AccessibilityNodeInfoCompat node, Editable result) {
    if (!node.isVisibleToUser()) {
        return;
    }

    BrailleRule rule = mRuleRepository.find(node);
    SpannableStringBuilder subtreeResult = new SpannableStringBuilder();
    rule.format(subtreeResult, mContext, node);
    if (rule.includeChildren(node, mContext)) {
        int childCount = node.getChildCount();
        for (int i = 0; i < childCount; ++i) {
            AccessibilityNodeInfoCompat child = node.getChild(i);
            if (child == null) {
                continue;
            }
            formatSubtree(child, subtreeResult);
            child.recycle();
        }
    }
    if (!TextUtils.isEmpty(subtreeResult)) {
        // If the node is accessibility focused, add the focus span
        // here to cover the node and its formatted children.
        // This is a fallback in case the formatting rule hasn't set
        // focus by itself.
        if (node.isAccessibilityFocused() && subtreeResult.getSpans(0, subtreeResult.length(),
                DisplaySpans.FocusSpan.class).length == 0) {
            DisplaySpans.addFocus(subtreeResult, 0, subtreeResult.length());
        }
        addNodeSpanForUncovered(node, subtreeResult);
        StringUtils.appendWithSpaces(result, subtreeResult);
    }
}

From source file:at.jclehner.rxdroid.DoseView.java

private void updateView() {
    mStatus = STATUS_INDETERMINATE;/*from  w  w  w .ja va 2 s  . com*/
    mIntakeStatus.setImageDrawable(null);

    if (mDrug != null) {
        if (!mDrug.isActive())
            mDoseText.setText("0");
        else if (!mDisplayDose.isZero()) {
            setStatus(STATUS_TAKEN);

            SpannableStringBuilder sb = new SpannableStringBuilder(Util.prettify(mDisplayDose));

            final Date lastScheduleUpdate = mDrug.getLastScheduleUpdateDate();

            if (lastScheduleUpdate == null || !mDate.before(lastScheduleUpdate)) {
                final Fraction scheduledDose = mDrug.getDose(mDoseTime, mDate);
                int cmp = mDisplayDose.compareTo(scheduledDose);
                String suffix;

                if (cmp < 0)
                    suffix = "-";
                else if (cmp > 0)
                    suffix = "+";
                else
                    suffix = null;

                if (suffix != null) {
                    sb.append(suffix);
                    sb.setSpan(new SuperscriptSpan(), sb.length() - 1, sb.length(), 0);
                }
            }

            mDoseText.setText(sb);
        } else {
            Fraction dose = mDrug.getDose(mDoseTime, mDate);
            mDoseText.setText(Util.prettify(dose));

            if (mIntakeCount == 0) {
                if (!dose.isZero() && !mDrug.isAsNeeded()) {
                    int offset = (int) Settings.getTrueDoseTimeEndOffset(mDoseTime);
                    Date end = DateTime.add(mDate, Calendar.MILLISECOND, offset);

                    if (DateTime.now().after(end))
                        setStatus(STATUS_MISSED);
                }
            } else
                setStatus(STATUS_IGNORED);
        }

    } else if (mDisplayDose != null)
        mDoseText.setText(Util.prettify(mDisplayDose));

    if ("0".equals(mDoseText.getText())) {
        String zeroStr = null;

        if (BuildConfig.DEBUG)
            zeroStr = Settings.getString("doseview_zero");

        if (zeroStr == null)
            zeroStr = "-";

        mDoseText.setText(zeroStr);

    }
}

From source file:com.android.mms.transaction.MessagingNotification.java

private static CharSequence formatSenders(Context context, ArrayList<NotificationInfo> senders) {
    final TextAppearanceSpan notificationSenderSpan = new TextAppearanceSpan(context,
            R.style.NotificationPrimaryText);

    String separator = context.getString(R.string.enumeration_comma); // ", "
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
    int len = senders.size();
    for (int i = 0; i < len; i++) {
        if (i > 0) {
            spannableStringBuilder.append(separator);
        }//w w  w .ja  va 2s . c  o  m
        spannableStringBuilder.append(senders.get(i).mSender.getName());
    }
    spannableStringBuilder.setSpan(notificationSenderSpan, 0, spannableStringBuilder.length(), 0);
    return spannableStringBuilder;
}

From source file:net.kourlas.voipms_sms.adapters.ConversationRecyclerViewAdapter.java

@Override
public void onBindViewHolder(MessageViewHolder messageViewHolder, int i) {
    Message message = messages.get(i);/* w  w  w  . ja v  a  2 s.c o  m*/
    int viewType = getItemViewType(i);

    if (viewType == ITEM_LEFT_PRIMARY || viewType == ITEM_RIGHT_PRIMARY) {
        QuickContactBadge contactBadge = messageViewHolder.getContactBadge();
        if (viewType == ITEM_LEFT_PRIMARY) {
            contactBadge.assignContactFromPhone(message.getContact(), true);
        } else {
            contactBadge.assignContactFromPhone(message.getDid(), true);
        }
        String photoUri;
        if (viewType == ITEM_LEFT_PRIMARY) {
            photoUri = Utils.getContactPhotoUri(applicationContext, message.getContact());

        } else {
            photoUri = Utils.getContactPhotoUri(applicationContext, ContactsContract.Profile.CONTENT_URI);
            if (photoUri == null) {
                photoUri = Utils.getContactPhotoUri(applicationContext, message.getDid());
            }
        }
        if (photoUri != null) {
            contactBadge.setImageURI(Uri.parse(photoUri));
        } else {
            contactBadge.setImageToDefault();
        }
    }

    View smsContainer = messageViewHolder.getSmsContainer();

    TextView messageText = messageViewHolder.getMessageText();
    SpannableStringBuilder messageTextBuilder = new SpannableStringBuilder();
    messageTextBuilder.append(message.getText());
    if (!filterConstraint.equals("")) {
        int index = message.getText().toLowerCase().indexOf(filterConstraint.toLowerCase());
        if (index != -1) {
            messageTextBuilder.setSpan(
                    new BackgroundColorSpan(ContextCompat.getColor(applicationContext, R.color.highlight)),
                    index, index + filterConstraint.length(), SpannableString.SPAN_INCLUSIVE_EXCLUSIVE);
            messageTextBuilder.setSpan(
                    new ForegroundColorSpan(ContextCompat.getColor(applicationContext, R.color.dark_gray)),
                    index, index + filterConstraint.length(), SpannableString.SPAN_INCLUSIVE_EXCLUSIVE);
        }
    }
    messageText.setText(messageTextBuilder);

    TextView dateText = messageViewHolder.getDateText();
    if (!message.isDelivered()) {
        if (!message.isDeliveryInProgress()) {
            SpannableStringBuilder dateTextBuilder = new SpannableStringBuilder();
            if (isItemChecked(i)) {
                dateTextBuilder
                        .append(applicationContext.getString(R.string.conversation_message_not_sent_selected));
            } else {
                dateTextBuilder.append(applicationContext.getString(R.string.conversation_message_not_sent));
            }
            dateTextBuilder.setSpan(
                    new ForegroundColorSpan(
                            isItemChecked(i) ? ContextCompat.getColor(applicationContext, android.R.color.white)
                                    : ContextCompat.getColor(applicationContext,
                                            android.R.color.holo_red_dark)),
                    0, dateTextBuilder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
            dateText.setText(dateTextBuilder);
            dateText.setVisibility(View.VISIBLE);
        } else {
            dateText.setText(applicationContext.getString(R.string.conversation_message_sending));
            dateText.setVisibility(View.VISIBLE);
        }
    } else if (i == messages.size() - 1
            || ((viewType == ITEM_LEFT_PRIMARY || viewType == ITEM_LEFT_SECONDARY)
                    && getItemViewType(i + 1) != ITEM_LEFT_SECONDARY)
            || ((viewType == ITEM_RIGHT_PRIMARY || viewType == ITEM_RIGHT_SECONDARY)
                    && getItemViewType(i + 1) != ITEM_RIGHT_SECONDARY)) {
        dateText.setText(Utils.getFormattedDate(applicationContext, message.getDate(), false));
        dateText.setVisibility(View.VISIBLE);
    } else {
        dateText.setVisibility(View.GONE);
    }

    if (viewType == ITEM_LEFT_PRIMARY || viewType == ITEM_LEFT_SECONDARY) {
        smsContainer.setBackgroundResource(isItemChecked(i) ? android.R.color.holo_blue_dark : R.color.primary);
    } else {
        smsContainer.setBackgroundResource(
                isItemChecked(i) ? android.R.color.holo_blue_dark : android.R.color.white);
        messageText.setTextColor(
                isItemChecked(i) ? ContextCompat.getColor(applicationContext, android.R.color.white)
                        : ContextCompat.getColor(applicationContext, R.color.dark_gray));
        messageText.setLinkTextColor(
                isItemChecked(i) ? ContextCompat.getColor(applicationContext, android.R.color.white)
                        : ContextCompat.getColor(applicationContext, R.color.dark_gray));
        dateText.setTextColor(
                isItemChecked(i) ? ContextCompat.getColor(applicationContext, R.color.message_translucent_white)
                        : ContextCompat.getColor(applicationContext, R.color.message_translucent_dark_grey));
    }
}

From source file:com.heath_bar.tvdb.SeriesOverview.java

/** Populate the interface with the data pulled from the webz */
private void PopulateStuff(TvSeries seriesInfo) {

    if (seriesInfo == null) {
        Toast.makeText(getApplicationContext(), "Something bad happened. No data was found.",
                Toast.LENGTH_SHORT).show();
        return;//w  w  w . j  a  v  a 2s .  co  m
    }

    // Set title
    getSupportActionBar().setTitle(seriesInfo.getName());

    // Hide/Activate the favorites button
    if (seriesInfo.isFavorite(getApplicationContext())) {
        Button b = (Button) findViewById(R.id.btn_add_to_favorites);
        b.setVisibility(View.GONE);
    } else {
        Button b = (Button) findViewById(R.id.btn_add_to_favorites);
        b.setVisibility(View.VISIBLE);
        b.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Button b = (Button) findViewById(R.id.btn_add_to_favorites);
                b.setVisibility(View.GONE);
                addToFavorites();
            }
        });
    }

    // Set the banner
    ImageView imageView = (ImageView) findViewById(R.id.series_banner);
    imageView.setImageBitmap(seriesInfo.getImage().getBitmap());
    imageView.setVisibility(View.VISIBLE);
    final String seriesName = seriesInfo.getName();

    imageView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            shareImage();
        }
    });

    // Set the banner link
    TextView textview = (TextView) findViewById(R.id.banner_listing_link);
    textview.setTextColor(getResources().getColor(R.color.tvdb_green));
    textview.setVisibility(View.VISIBLE);
    textview.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(getApplicationContext(), BannerListing.class);
            i.putExtra("seriesId", seriesId);
            i.putExtra("seriesName", seriesName);
            startActivity(i);
        }
    });

    // Set air info
    textview = (TextView) findViewById(R.id.airs_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.last_episode);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.next_episode);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.series_air_info);
    StringBuffer sb = new StringBuffer();
    sb.append(seriesInfo.getAirDay());
    if (!seriesInfo.getAirTime().equals(""))
        sb.append(" at " + seriesInfo.getAirTime());
    if (!seriesInfo.getNetwork().equals(""))
        sb.append(" on " + seriesInfo.getNetwork());
    textview.setText(sb.toString());
    textview.setVisibility(View.VISIBLE);

    // Set actors
    textview = (TextView) findViewById(R.id.starring);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.series_actors);
    textview.setVisibility(View.VISIBLE);

    SpannableStringBuilder text = tagsBuilder(seriesInfo.getActors(), "|");
    textview.setText(text, BufferType.SPANNABLE);
    textview.setMovementMethod(LinkMovementMethod.getInstance());

    // Set rating
    textview = (TextView) findViewById(R.id.rating_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.rating);
    textview.setText(seriesInfo.getRating() + " / 10");
    textview.setVisibility(View.VISIBLE);

    // Set genre
    textview = (TextView) findViewById(R.id.genre_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.genre);
    textview.setText(StringUtil.commafy(seriesInfo.getGenre()));
    textview.setVisibility(View.VISIBLE);

    // Set runtime
    textview = (TextView) findViewById(R.id.runtime_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.runtime);
    textview.setText(seriesInfo.getRuntime() + " minutes");
    textview.setVisibility(View.VISIBLE);

    // Set overview
    textview = (TextView) findViewById(R.id.overview_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.overview);
    textview.setText(seriesInfo.getOverview());
    textview.setVisibility(View.VISIBLE);

    // Show Seasons header
    textview = (TextView) findViewById(R.id.seasons_header);
    textview.setVisibility(View.VISIBLE);

    // IMDB Link
    textview = (TextView) findViewById(R.id.imdb_link);
    textview.setVisibility(View.VISIBLE);

    final String imdbId = seriesInfo.getIMDB();
    SpannableStringBuilder ssb = new SpannableStringBuilder(getResources().getString(R.string.imdb));
    ssb.setSpan(new NonUnderlinedClickableSpan(getResources().getString(R.string.imdb)) {
        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.imdb.com/title/" + imdbId));
            startActivity(myIntent);
        }
    }, 0, ssb.length(), 0);

    ssb.setSpan(new TextAppearanceSpan(this, R.style.episode_link), 0, ssb.length(), 0); // Set the style of the text
    textview.setText(ssb, BufferType.SPANNABLE);
    textview.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:com.csipsimple.ui.messages.ConversationsAdapter.java

private CharSequence formatMessage(Cursor cursor) {
    SpannableStringBuilder buf = new SpannableStringBuilder();
    /*/*from  ww  w . j a  v a2  s .  com*/
    String remoteContact = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM));
    if (remoteContact.equals("SELF")) {
    remoteContact = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_TO));
    buf.append("To: ");
    }
    */
    String remoteContactFull = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM_FULL));
    CallerInfo callerInfo = CallerInfo.getCallerInfoFromSipUri(mContext, remoteContactFull);
    if (callerInfo != null && callerInfo.contactExists) {
        buf.append(callerInfo.name);
        buf.append(" / ");
        buf.append(SipUri.getDisplayedSimpleContact(remoteContactFull));
    } else {
        buf.append(SipUri.getDisplayedSimpleContact(remoteContactFull));
    }

    int counter = cursor.getInt(cursor.getColumnIndex("counter"));
    if (counter > 1) {
        buf.append(" (" + counter + ") ");
    }

    int read = cursor.getInt(cursor.getColumnIndex(SipMessage.FIELD_READ));
    // Unread messages are shown in bold
    if (read == 0) {
        buf.setSpan(STYLE_BOLD, 0, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    }
    return buf;
}