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:com.googlecode.eyesfree.brailleback.BrailleIME.java

public void updateDisplay() {
    if (mExtractedText == null) {
        return;/*from   w w  w.j  a v  a2 s  . co  m*/
    }
    DisplayManager displayManager = getCurrentDisplayManager();
    if (displayManager == null) {
        return;
    }
    EditorInfo ei = getCurrentInputEditorInfo();
    if (ei == null) {
        LogUtils.log(this, Log.WARN, "No input editor info");
        return;
    }
    CharSequence label = ei.label;
    CharSequence hint = ei.hintText;
    if (TextUtils.isEmpty(label)) {
        label = hint;
        hint = null;
    }
    SpannableStringBuilder text = new SpannableStringBuilder();
    if (!TextUtils.isEmpty(label)) {
        text.append(label);
        text.append(": "); // TODO: Put in a resource.
    }
    int editStart = text.length();
    text.append(mCurrentText);
    addMarkingSpan(text, EDIT_TEXT_SPAN, editStart);
    CharSequence actionLabel = getActionLabel();
    if (actionLabel != null) {
        text.append(" [");
        text.append(actionLabel);
        text.append("]");
        addMarkingSpan(text, ACTION_LABEL_SPAN, text.length() - (actionLabel.length() + 2));
    }
    DisplaySpans.addSelection(text, editStart + mSelectionStart, editStart + mSelectionEnd);
    displayManager.setContent(new DisplayManager.Content(text).setPanStrategy(DisplayManager.Content.PAN_CURSOR)
            .setSplitParagraphs(isMultiLineField()));
}

From source file:cn.figo.mydemo.ui.activity.VideoActivity.java

private SpannableStringBuilder createSpannable(Drawable drawable) {
    String text = "bitmap";
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(text);
    ImageSpan span = new ImageSpan(drawable);//ImageSpan.ALIGN_BOTTOM);
    spannableStringBuilder.setSpan(span, 0, text.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableStringBuilder.append("");
    spannableStringBuilder.setSpan(new BackgroundColorSpan(Color.parseColor("#8A2233B1")), 0,
            spannableStringBuilder.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
    return spannableStringBuilder;
}

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

/**
 * Handle {@link SessionsQuery} {@link Cursor}.
 */// w  w w.j  a  va  2  s.c om
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:systems.soapbox.ombuds.client.ui.WalletTransactionsFragment.java

@Override
public void onLoadFinished(final Loader<List<Transaction>> loader, final List<Transaction> transactions) {
    final Direction direction = ((TransactionsLoader) loader).getDirection();

    adapter.replace(transactions);/*  w w  w .j  a va2s  . c om*/

    if (transactions.isEmpty()) {
        viewGroup.setDisplayedChild(1);

        final SpannableStringBuilder emptyText = new SpannableStringBuilder("You have no Bitcoin.");
        emptyText.setSpan(new StyleSpan(Typeface.BOLD), 0, emptyText.length(),
                SpannableStringBuilder.SPAN_POINT_MARK);
        emptyText.append("\n\n").append(getString(R.string.profile_email_for_bitcoin));
        emptyView.setText(emptyText);
    } else {
        viewGroup.setDisplayedChild(2);
    }
}

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

private CharSequence formatMessage(Cursor cursor) {
    SpannableStringBuilder buf = new SpannableStringBuilder();
    /*//from www .jav  a 2 s.c  om
    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;
}

From source file:org.kontalk.ui.view.ConversationListItem.java

public final void bind(Context context, final Conversation conv) {
    mConversation = conv;//from w ww  . ja v  a2s.  c o m

    setChecked(false);

    Contact contact;
    // used for the conversation subject: either group subject or contact name
    String recipient = null;

    if (mConversation.isGroupChat()) {
        recipient = mConversation.getGroupSubject();
        if (TextUtils.isEmpty(recipient))
            recipient = context.getString(R.string.group_untitled);

        loadAvatar(null);
    } else {
        contact = mConversation.getContact();

        if (contact != null) {
            recipient = contact.getDisplayName();
        }

        if (recipient == null) {
            if (BuildConfig.DEBUG) {
                recipient = conv.getRecipient();
            } else {
                recipient = context.getString(R.string.peer_unknown);
            }
        }

        loadAvatar(contact);
    }

    SpannableStringBuilder from = new SpannableStringBuilder(recipient);
    if (conv.getUnreadCount() > 0)
        from.setSpan(STYLE_BOLD, 0, from.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);

    // draft indicator
    int lastpos = from.length();
    String draft = conv.getDraft();
    if (draft != null) {
        from.append(" ");
        from.append(context.getResources().getString(R.string.has_draft));
        from.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.text_color_draft)),
                lastpos, from.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    }

    mFromView.setText(from);
    mDateView.setText(MessageUtils.formatTimeStampString(context, conv.getDate()));
    mSticky.setVisibility(conv.isSticky() ? VISIBLE : GONE);

    // error indicator
    int resId = -1;
    int statusId = -1;
    switch (conv.getStatus()) {
    case Messages.STATUS_SENDING:
        // use pending icon even for errors
    case Messages.STATUS_ERROR:
    case Messages.STATUS_PENDING:
    case Messages.STATUS_QUEUED:
        resId = R.drawable.ic_msg_pending;
        statusId = R.string.msg_status_sending;
        break;
    case Messages.STATUS_SENT:
        resId = R.drawable.ic_msg_sent;
        statusId = R.string.msg_status_sent;
        break;
    case Messages.STATUS_RECEIVED:
        resId = R.drawable.ic_msg_delivered;
        statusId = R.string.msg_status_delivered;
        break;
    // here we use the error icon
    case Messages.STATUS_NOTACCEPTED:
        resId = R.drawable.ic_thread_error;
        statusId = R.string.msg_status_notaccepted;
        break;
    case Messages.STATUS_NOTDELIVERED:
        resId = R.drawable.ic_msg_notdelivered;
        statusId = R.string.msg_status_notdelivered;
        break;
    }

    // no matching resource or draft - hide status icon
    boolean incoming = resId < 0;
    if (incoming || draft != null) {
        mErrorIndicator.setVisibility(GONE);

        int unread = mConversation.getUnreadCount();
        if (unread > 0) {
            mCounterView.setText(String.valueOf(unread));
            mCounterView.setVisibility(VISIBLE);
        } else {
            mCounterView.setVisibility(GONE);
        }
    } else {
        mCounterView.setVisibility(GONE);
        mErrorIndicator.setVisibility(VISIBLE);
        mErrorIndicator.setImageResource(resId);
        mErrorIndicator.setContentDescription(getResources().getString(statusId));
    }

    CharSequence text;

    // last message or draft??
    if (conv.getRequestStatus() == Threads.REQUEST_WAITING) {
        text = new SpannableString(context.getString(R.string.text_invitation_info));
        ((Spannable) text).setSpan(STYLE_ITALIC, 0, text.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    } else {
        String subject = conv.getSubject();
        String source = (draft != null) ? draft : subject;

        if (source != null) {
            if (GroupCommandComponent.supportsMimeType(conv.getMime()) && draft == null) {
                if (incoming) {
                    // content is in a special format
                    GroupThreadContent parsed = GroupThreadContent.parseIncoming(subject);
                    subject = parsed.command;
                }
                text = new SpannableString(
                        GroupCommandComponent.getTextContent(getContext(), subject, incoming));
                ((Spannable) text).setSpan(STYLE_ITALIC, 0, text.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
            } else {
                if (incoming && conv.isGroupChat()) {
                    // content is in a special format
                    GroupThreadContent parsed = GroupThreadContent.parseIncoming(subject);
                    contact = parsed.sender != null ? Contact.findByUserId(context, parsed.sender) : null;
                    source = parsed.command;

                    String displayName = null;
                    if (contact != null)
                        displayName = contact.getDisplayName();

                    if (displayName == null) {
                        if (BuildConfig.DEBUG) {
                            displayName = conv.getRecipient();
                        } else {
                            displayName = context.getString(R.string.peer_unknown);
                        }
                    }

                    if (source == null) {
                        // determine from mime type
                        source = CompositeMessage.getSampleTextContent(conv.getMime());
                    }

                    text = new SpannableString(displayName + ": " + source);
                    ((Spannable) text).setSpan(STYLE_ITALIC, 0, displayName.length() + 1,
                            Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
                } else {
                    text = source;
                }
            }
        }

        else if (conv.isEncrypted()) {
            text = context.getString(R.string.text_encrypted);
        }

        else {
            // determine from mime type
            text = CompositeMessage.getSampleTextContent(conv.getMime());
        }
    }

    if (conv.getUnreadCount() > 0) {
        text = new SpannableString(text);
        ((Spannable) text).setSpan(STYLE_BOLD, 0, text.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    }

    mSubjectView.setText(text);
}

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

/**
 * Handle {@link SessionsQuery} {@link Cursor}.
 *///from  w  ww.  j a  va  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 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:com.google.android.apps.iosched.ui.SessionDetailFragment.java

/**
 * Handle {@link SessionsQuery} {@link Cursor}.
 *///from   w  w  w.  j av a 2  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);
                }
            });
        } 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:net.sf.fakenames.fddemo.PermissionActivity.java

private CharSequence toLabel(int uid, String[] packages) {
    final SpannableStringBuilder ssb = new SpannableStringBuilder();

    if (packages != null) {
        try {//from   w ww  . ja v a2 s.  com
            final PackageManager pm = getPackageManager();

            if (packages.length == 1) {
                final ApplicationInfo soleInfo = pm.getApplicationInfo(packages[0], 0);
                if (soleInfo != null) {
                    final CharSequence label = soleInfo.loadLabel(pm);

                    if (!TextUtils.isEmpty(label)) {
                        ssb.append(label);
                        setBold(ssb, 0, ssb.length());
                        return ssb;
                    }
                }

                ssb.append(packages[0]);
                setBold(ssb, 0, ssb.length());
                return ssb;
            } else {
                Arrays.sort(packages);

                int named = 0;

                ssb.append("UID ").append(String.valueOf(uid)).append(" (");

                final ApplicationInfo firstInfo = pm.getApplicationInfo(packages[0], 0);

                if (firstInfo != null) {
                    final CharSequence label = firstInfo.loadLabel(pm);

                    if (!TextUtils.isEmpty(label)) {
                        ++named;

                        int old = ssb.length();
                        ssb.append(label);
                        setBold(ssb, old, ssb.length());
                    }
                }

                final int maxSummary = Math.min(packages.length, 3);
                int i;
                for (i = 1; i < maxSummary; ++i) {
                    final ApplicationInfo appInfo = pm.getApplicationInfo(packages[i], 0);

                    if (appInfo != null) {
                        final CharSequence label = appInfo.loadLabel(pm);

                        if (!TextUtils.isEmpty(label)) {
                            ++named;

                            ssb.append(", ");
                            int old = ssb.length();
                            ssb.append(label);
                            setBold(ssb, old, ssb.length());
                        }
                    }
                }

                if (named == 0) {
                    ssb.append(String.valueOf(packages.length)).append(" packages)");
                    setBold(ssb, 0, ssb.length());
                } else {
                    if (packages.length <= 4) {
                        ssb.append(")");
                    } else {
                        ssb.append(" and ");
                        ssb.append(String.valueOf(packages.length - named));
                        ssb.append(" others)");
                    }
                }

                return ssb;
            }
        } catch (PackageManager.NameNotFoundException ignored) {
        }
    }

    ssb.append("UID ").append(String.valueOf(uid));
    setBold(ssb, 0, ssb.length());
    return ssb;
}

From source file:com.gh4a.activities.IssueActivity.java

private void fillData() {
    // set details inside listview header
    ImageView ivGravatar = (ImageView) mListHeaderView.findViewById(R.id.iv_gravatar);
    AvatarHandler.assignAvatar(ivGravatar, mIssue.getUser());
    ivGravatar.setOnClickListener(this);

    TextView tvState = (TextView) mHeader.findViewById(R.id.tv_state);
    boolean closed = Constants.Issue.STATE_CLOSED.equals(mIssue.getState());
    int stateTextResId = closed ? R.string.closed : R.string.open;
    int stateColorAttributeId = closed ? R.attr.colorIssueClosed : R.attr.colorIssueOpen;

    tvState.setText(getString(stateTextResId).toUpperCase(Locale.getDefault()));
    transitionHeaderToColor(stateColorAttributeId,
            closed ? R.attr.colorIssueClosedDark : R.attr.colorIssueOpenDark);
    UiUtils.trySetListOverscrollColor(mRecyclerView, UiUtils.resolveColor(this, stateColorAttributeId));

    TextView tvExtra = (TextView) mListHeaderView.findViewById(R.id.tv_extra);
    tvExtra.setText(ApiHelpers.getUserLogin(this, mIssue.getUser()));

    TextView tvTimestamp = (TextView) mListHeaderView.findViewById(R.id.tv_timestamp);
    tvTimestamp.setText(StringUtils.formatRelativeTime(this, mIssue.getCreatedAt(), true));

    TextView tvTitle = (TextView) mHeader.findViewById(R.id.tv_title);
    tvTitle.setText(mIssue.getTitle());/*from   w  w w.jav a 2s. c om*/

    String body = mIssue.getBodyHtml();
    TextView descriptionView = (TextView) mListHeaderView.findViewById(R.id.tv_desc);
    if (!StringUtils.isBlank(body)) {
        body = HtmlUtils.format(body).toString();
        mImageGetter.bind(descriptionView, body, mIssue.getNumber());
    }
    descriptionView.setMovementMethod(UiUtils.CHECKING_LINK_METHOD);

    View milestoneGroup = mListHeaderView.findViewById(R.id.milestone_container);
    if (mIssue.getMilestone() != null) {
        TextView tvMilestone = (TextView) mListHeaderView.findViewById(R.id.tv_milestone);
        tvMilestone.setText(mIssue.getMilestone().getTitle());
        milestoneGroup.setVisibility(View.VISIBLE);
    } else {
        milestoneGroup.setVisibility(View.GONE);
    }

    View assigneeGroup = mListHeaderView.findViewById(R.id.assignee_container);
    if (mIssue.getAssignee() != null) {
        TextView tvAssignee = (TextView) mListHeaderView.findViewById(R.id.tv_assignee);
        tvAssignee.setText(mIssue.getAssignee().getLogin());

        ImageView ivAssignee = (ImageView) mListHeaderView.findViewById(R.id.iv_assignee);
        AvatarHandler.assignAvatar(ivAssignee, mIssue.getAssignee());
        ivAssignee.setOnClickListener(this);
        assigneeGroup.setVisibility(View.VISIBLE);
    } else {
        assigneeGroup.setVisibility(View.GONE);
    }

    List<Label> labels = mIssue.getLabels();
    View labelGroup = mListHeaderView.findViewById(R.id.label_container);
    if (labels != null && !labels.isEmpty()) {
        TextView labelView = (TextView) mListHeaderView.findViewById(R.id.labels);
        SpannableStringBuilder builder = new SpannableStringBuilder();

        for (Label label : labels) {
            int pos = builder.length();
            IssueLabelSpan span = new IssueLabelSpan(this, label, true);
            builder.append(label.getName());
            builder.setSpan(span, pos, pos + label.getName().length(), 0);
        }
        labelView.setText(builder);
        labelGroup.setVisibility(View.VISIBLE);
    } else {
        labelGroup.setVisibility(View.GONE);
    }

    TextView tvPull = (TextView) mListHeaderView.findViewById(R.id.tv_pull);
    if (mIssue.getPullRequest() != null && mIssue.getPullRequest().getDiffUrl() != null) {
        tvPull.setVisibility(View.VISIBLE);
        tvPull.setOnClickListener(this);
    } else {
        tvPull.setVisibility(View.GONE);
    }

    mHeader.setVisibility(View.VISIBLE);
    updateFabVisibility();
    updateCommentLockState();
}