Example usage for android.text SpannableStringBuilder SpannableStringBuilder

List of usage examples for android.text SpannableStringBuilder SpannableStringBuilder

Introduction

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

Prototype

public SpannableStringBuilder() 

Source Link

Document

Create a new SpannableStringBuilder with empty contents

Usage

From source file:com.google.android.apps.iosched.ui.SessionDetailFragment.java

/**
 * Handle {@link SessionsQuery} {@link Cursor}.
 *///from   www.  ja  v  a2 s . c o  m
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 String roomName = cursor.getString(SessionsQuery.ROOM_NAME);
        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);
        }

        final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block);
        final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS);
        if (!TextUtils.isEmpty(sessionRequirements)) {
            UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements);
            requirementsBlock.setVisibility(View.VISIBLE);
            mHasSummaryContent = true;
        } else {
            requirementsBlock.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);
        updateNotesTab();

    } finally {
        cursor.close();
    }
}

From source file:org.androidtitlan.estoesgoogle.ui.SessionDetailFragment.java

/**
 * Handle {@link SessionsQuery} {@link Cursor}.
 *///from  ww w  .j  a v  a  2 s . c  o m
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 String roomName = cursor.getString(SessionsQuery.ROOM_NAME);
        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);
        }

        final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block);
        final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS);
        if (!TextUtils.isEmpty(sessionRequirements)) {
            UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements);
            requirementsBlock.setVisibility(View.VISIBLE);
            mHasSummaryContent = true;
        } else {
            requirementsBlock.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);
        updateNotesTab();
        updateLinksTab(cursor);

    } finally {
        cursor.close();
    }
}

From source file:org.dalmasso.ietfsched.ui.SessionDetailFragment.java

/**
 * Handle {@link SessionsQuery} {@link Cursor}.
 */// w w w  . j ava2  s.  c om
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 String roomName = cursor.getString(SessionsQuery.ROOM_NAME);
        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);
                    */ Log.d(TAG, "on click mTagDisplay");
                }
            });
        } 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);
        }

        /*            final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block);
                    final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS);
                    if (!TextUtils.isEmpty(sessionRequirements)) {
        UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements);
        requirementsBlock.setVisibility(View.VISIBLE);
        mHasSummaryContent = true;
                    } else {
        requirementsBlock.setVisibility(View.GONE);
                    }
                      
        */

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

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

        updateLinksTab(cursor);
        updateNotesTab();

    } finally {
        cursor.close();
    }
}

From source file:com.goliathonline.android.kegbot.ui.DrinkDetailFragment.java

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

        // Format time block this session occupies
        //final long blockStart = cursor.getLong(DrinksQuery.BLOCK_START);
        //final long blockEnd = cursor.getLong(DrinksQuery.BLOCK_END);
        //final String roomName = cursor.getString(DrinksQuery.ROOM_NAME);
        //final String subtitle = UIUtils.formatSessionSubtitle(blockStart,
        //        blockEnd, roomName, getActivity());

        mTitleString = "Drink " + cursor.getString(DrinksQuery.DRINK_ID);
        mTitle.setText(mTitleString);
        String userId = cursor.getString(DrinksQuery.USER_ID);
        if (TextUtils.isEmpty(userId))
            userId = "guest";
        mSubtitle.setText(userId);

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

        //mHashtag = cursor.getString(DrinksQuery.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(DrinksQuery.ROOM_ID);

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

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

        final View requirementsBlock = mRootView.findViewById(R.id.drink_pour_block);
        final String sessionRequirements = UnitUtils.mlToOz(cursor.getString(DrinksQuery.VOLUME)) + "oz";
        if (!TextUtils.isEmpty(sessionRequirements)) {
            UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements);
            requirementsBlock.setVisibility(View.VISIBLE);
            mHasSummaryContent = true;
        } else {
            requirementsBlock.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("/Drinks/" + mTitleString);

        updateLinksTab(cursor);
        updateNotesTab();

    } finally {
        cursor.close();
    }
}

From source file:com.microsoft.rightsmanagement.ui.widget.UserPolicyViewerFragment.java

/**
 * Updates the policy viewer according to the ownership
 *///  w w w .  j  a v a2 s .  co m
private void updateViewAccordingToOwnership() {
    UserPolicyModel userPolicyModel = mUserPolicyDataProvider.getUserPolicyModel();
    // if this is not owner just show the rights with no header
    if (userPolicyModel.isIssuedToOwner()) {
        Logger.d(TAG, "user is the owner of user policy");
        mUpperTitleTextView.setText(getString(R.string.policy_viewer_owner_content));
        mOwnerNameTextView.setVisibility(View.GONE);
        setPolicyEditingButtonViewState(mUserPolicyDataProvider.isUserPolicyEditingEnabled());
    } else {
        Logger.d(TAG, "user is not the owner of user policy");
        //ignore input of allowing edit enabled and hide policy edit button 
        setPolicyEditingButtonViewState(false);
        mUpperTitleTextView.setText(R.string.policy_viewer_non_owner_content);
        SpannableStringBuilder sb = new SpannableStringBuilder();
        String grantedBy = getString(R.string.granted_by_string);
        sb.append(grantedBy);
        sb.append(" ");
        sb.append(userPolicyModel.getOwner());
        sb.setSpan(new StyleSpan(Typeface.BOLD), grantedBy.length(), sb.length(), 0);
        mOwnerNameTextView.setText(sb);
        drawRights();
    }
}

From source file:es.usc.citius.servando.calendula.activities.ReminderNotification.java

private static void styleForSchedule(Context context, NotificationCompat.InboxStyle style, Schedule schedule) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    final Medicine med = schedule.medicine();
    final SpannableStringBuilder SpItem = new SpannableStringBuilder();
    SpItem.append(med.name());//from  w  ww .  j  a  v  a2  s .  c  o  m
    SpItem.append("   " + schedule.dose() + " " + med.presentation().units(context.getResources()));
    style.addLine(SpItem);

    String delayMinutesStr = prefs.getString("alarm_repeat_frequency", "15");
    int delayMinutes = (int) Long.parseLong(delayMinutesStr);

    if (delayMinutes > 0) {
        String repeatTime = DateTime.now().plusMinutes((int) delayMinutes).toString("kk:mm");
        style.setSummaryText(context.getString(R.string.notification_repeat_message, repeatTime));
    } else {
        style.setSummaryText(med.name() + "(" + context.getString(R.string.every) + " "
                + schedule.rule().interval() + " " + context.getString(R.string.hours) + ")");
    }
}

From source file:com.google.android.apps.iosched2.ui.SessionDetailFragment.java

/**
 * Handle {@link SessionsQuery} {@link Cursor}.
 *//*from   w  ww.  ja v a2 s  .  c  o  m*/
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 String roomName = cursor.getString(SessionsQuery.ROOM_NAME);
        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 intent = new Intent(getActivity(), Setup.TagStreamActivityClass);

                    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);
        }

        final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block);
        final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS);
        if (!TextUtils.isEmpty(sessionRequirements)) {
            UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements);
            requirementsBlock.setVisibility(View.VISIBLE);
            mHasSummaryContent = true;
        } else {
            requirementsBlock.setVisibility(View.GONE);
        }

        final View levelBlock = mRootView.findViewById(R.id.session_level_block);
        final String sessionLevel = cursor.getString(SessionsQuery.LEVEL);
        if (!TextUtils.isEmpty(sessionLevel)) {
            UIUtils.setTextMaybeHtml(mLevel, sessionLevel);
            levelBlock.setVisibility(View.VISIBLE);
            mHasSummaryContent = true;
        } else {
            levelBlock.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);
        updateNotesTab();

    } finally {
        cursor.close();
    }
}

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

private void loadBookmark() {
    if (bookmark != null) {
        if (viewType == BookmarkViewType.VIEW) {

            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")
                    && !bookmark.getNotes().equals("")) {
                mNotes.setText(bookmark.getNotes());
                notesSection.setVisibility(View.VISIBLE);
            } else {
                notesSection.setVisibility(View.GONE);
            }/*from   w w w .  j  ava  2  s. c  o m*/

            mTime.setText(d.toString());

            mTags.setMovementMethod(LinkMovementMethod.getInstance());
            SpannableStringBuilder tagBuilder = new SpannableStringBuilder();

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

                mTags.setText(tagBuilder);

                tagsSection.setVisibility(View.VISIBLE);
            } else {
                tagsSection.setVisibility(View.GONE);
            }

            if (isMyself()) {
                Uri.Builder ub = new Uri.Builder();
                ub.scheme("content");
                ub.authority(BookmarkContentProvider.AUTHORITY);
                ub.appendPath("bookmark");
                ub.appendPath(Integer.toString(bookmark.getId()));

                getActivity().getContentResolver().unregisterContentObserver(observer);
                getActivity().getContentResolver().registerContentObserver(ub.build(), true, observer);

                mUsername.setText(bookmark.getAccount());

                if (bookmark.getToRead() && bookmark.getShared()) {
                    bookmarkIcon.setImageResource(R.drawable.ic_unread);
                } else if (!bookmark.getToRead() && bookmark.getShared()) {
                    bookmarkIcon.setImageResource(R.drawable.ic_bookmark);
                } else if (bookmark.getToRead() && !bookmark.getShared()) {
                    bookmarkIcon.setImageResource(R.drawable.ic_unread_private);
                } else if (!bookmark.getToRead() && !bookmark.getShared()) {
                    bookmarkIcon.setImageResource(R.drawable.ic_bookmark_private);
                }

            } else {
                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) {
            showInWebView(Constants.INSTAPAPER_URL + bookmark.getUrl());

            if (isMyself() && bookmark.getToRead() && SettingsHelper.getMarkAsRead(getActivity()))
                bookmarkSelectedListener.onBookmarkMark(bookmark);
        } else if (viewType == BookmarkViewType.WEB) {
            showInWebView(bookmark.getUrl());
        }
    } else {
        clearView();
    }
}

From source file:com.appeaser.sublimepickerlibrary.timepicker.SublimeTimePicker.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private CharSequence obtainVerbatim(String text) {
    return (SUtils.isApi_21_OrHigher())
            ? new SpannableStringBuilder().append(text, new TtsSpan.VerbatimBuilder(text).build(), 0)
            : text;//from   ww w.  j  a  va  2 s  . c  om
}

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 .  ja v  a  2s.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();
        }
    }
}