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:org.telegram.ui.GroupCreateActivity.java

public Emoji.XImageSpan createAndPutChipForUser(TLRPC.User user) {
    LayoutInflater lf = (LayoutInflater) parentActivity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    View textView = lf.inflate(R.layout.group_create_bubble, null);
    TextView text = (TextView) textView.findViewById(R.id.bubble_text_view);
    text.setText(Utilities.formatName(user.first_name, user.last_name));

    int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    textView.measure(spec, spec);/* w w w. ja  v a  2 s. c  o m*/
    textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
    Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(b);
    canvas.translate(-textView.getScrollX(), -textView.getScrollY());
    textView.draw(canvas);
    textView.setDrawingCacheEnabled(true);
    Bitmap cacheBmp = textView.getDrawingCache();
    Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true);
    textView.destroyDrawingCache();

    final BitmapDrawable bmpDrawable = new BitmapDrawable(b);
    bmpDrawable.setBounds(0, 0, b.getWidth(), b.getHeight());

    SpannableStringBuilder ssb = new SpannableStringBuilder("");
    Emoji.XImageSpan span = new Emoji.XImageSpan(bmpDrawable, ImageSpan.ALIGN_BASELINE);
    allSpans.add(span);
    selectedContacts.put(user.id, span);
    for (ImageSpan sp : allSpans) {
        ssb.append("<<");
        ssb.setSpan(sp, ssb.length() - 2, ssb.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    userSelectEditText.setText(ssb);
    userSelectEditText.setSelection(ssb.length());
    return span;
}

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:org.telegram.ui.GroupCreateActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (fragmentView == null) {
        fragmentView = inflater.inflate(R.layout.group_create_layout, container, false);

        epmtyTextView = (TextView) fragmentView.findViewById(R.id.searchEmptyView);
        userSelectEditText = (EditText) fragmentView.findViewById(R.id.bubble_input_text);
        countTextView = (TextView) fragmentView.findViewById(R.id.bubble_counter_text);
        if (Build.VERSION.SDK_INT >= 11) {
            userSelectEditText.setTextIsSelectable(false);
        }//w  w w. j a  va2 s .  c  o m
        userSelectEditText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {
                if (!ignoreChange) {
                    beforeChangeIndex = userSelectEditText.getSelectionStart();
                    changeString = new SpannableString(charSequence);
                }
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                if (!ignoreChange) {
                    boolean search = false;
                    int afterChangeIndex = userSelectEditText.getSelectionEnd();
                    if (editable.toString().length() < changeString.toString().length()) {
                        String deletedString = "";
                        try {
                            deletedString = changeString.toString().substring(afterChangeIndex,
                                    beforeChangeIndex);
                        } catch (Exception e) {
                            FileLog.e("tmessages", e);
                        }
                        if (deletedString.length() > 0) {
                            if (searching && searchWas) {
                                search = true;
                            }
                            Spannable span = userSelectEditText.getText();
                            for (int a = 0; a < allSpans.size(); a++) {
                                Emoji.XImageSpan sp = allSpans.get(a);
                                if (span.getSpanStart(sp) == -1) {
                                    allSpans.remove(sp);
                                    selectedContacts.remove(sp.uid);
                                }
                            }
                            if (selectedContacts.isEmpty()) {
                                doneTextView.setText(getStringEntry(R.string.Done));
                            } else {
                                doneTextView.setText(
                                        getStringEntry(R.string.Done) + " (" + selectedContacts.size() + ")");
                            }
                            countTextView.setText(selectedContacts.size() + "/200");
                            listView.invalidateViews();
                        } else {
                            search = true;
                        }
                    } else {
                        search = true;
                    }
                    if (search) {
                        String text = userSelectEditText.getText().toString().replace("<", "");
                        if (text.length() != 0) {
                            searchDialogs(text);
                            searching = true;
                            searchWas = true;
                            epmtyTextView.setText(getStringEntry(R.string.NoResult));
                            listViewAdapter.notifyDataSetChanged();
                        } else {
                            searchResult = null;
                            searchResultNames = null;
                            searching = false;
                            searchWas = false;
                            epmtyTextView.setText(getStringEntry(R.string.NoContacts));
                            listViewAdapter.notifyDataSetChanged();
                        }
                    }
                }
            }
        });

        listView = (PinnedHeaderListView) fragmentView.findViewById(R.id.listView);
        listView.setEmptyView(epmtyTextView);
        listView.setVerticalScrollBarEnabled(false);

        listView.setAdapter(listViewAdapter = new ListAdapter(parentActivity));
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                TLRPC.User user;
                int section = listViewAdapter.getSectionForPosition(i);
                int row = listViewAdapter.getPositionInSectionForPosition(i);
                if (searching && searchWas) {
                    user = searchResult.get(row);
                } else {
                    ArrayList<TLRPC.TL_contact> arr = ContactsController.Instance.usersSectionsDict
                            .get(ContactsController.Instance.sortedUsersSectionsArray.get(section));
                    user = MessagesController.Instance.users.get(arr.get(row).user_id);
                    listView.invalidateViews();
                }
                if (selectedContacts.containsKey(user.id)) {
                    Emoji.XImageSpan span = selectedContacts.get(user.id);
                    selectedContacts.remove(user.id);
                    SpannableStringBuilder text = new SpannableStringBuilder(userSelectEditText.getText());
                    text.delete(text.getSpanStart(span), text.getSpanEnd(span));
                    allSpans.remove(span);
                    ignoreChange = true;
                    userSelectEditText.setText(text);
                    userSelectEditText.setSelection(text.length());
                    ignoreChange = false;
                } else {
                    if (selectedContacts.size() == 200) {
                        return;
                    }
                    ignoreChange = true;
                    Emoji.XImageSpan span = createAndPutChipForUser(user);
                    span.uid = user.id;
                    ignoreChange = false;
                }
                if (selectedContacts.isEmpty()) {
                    doneTextView.setText(getStringEntry(R.string.Done));
                } else {
                    doneTextView.setText(getStringEntry(R.string.Done) + " (" + selectedContacts.size() + ")");
                }
                countTextView.setText(selectedContacts.size() + "/200");
                if (searching || searchWas) {
                    searching = false;
                    searchWas = false;
                    epmtyTextView.setText(getStringEntry(R.string.NoContacts));

                    ignoreChange = true;
                    SpannableStringBuilder ssb = new SpannableStringBuilder("");
                    for (ImageSpan sp : allSpans) {
                        ssb.append("<<");
                        ssb.setSpan(sp, ssb.length() - 2, ssb.length(),
                                SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
                    }
                    userSelectEditText.setText(ssb);
                    userSelectEditText.setSelection(ssb.length());
                    ignoreChange = false;

                    listViewAdapter.notifyDataSetChanged();
                } else {
                    listView.invalidateViews();
                }
            }
        });
    } else {
        ViewGroup parent = (ViewGroup) fragmentView.getParent();
        if (parent != null) {
            parent.removeView(fragmentView);
        }
    }
    return fragmentView;
}

From source file:com.abcvoipsip.ui.messages.MessageAdapter.java

private CharSequence formatMessage(String contact, String body, String contentType) {
    SpannableStringBuilder buf = new SpannableStringBuilder();
    if (!TextUtils.isEmpty(body)) {
        // Converts html to spannable if ContentType is "text/html".
        if (contentType != null && "text/html".equals(contentType)) {
            buf.append("\n");
            buf.append(Html.fromHtml(body));
        } else {//  ww w  .ja  v  a  2 s .c om
            SmileyParser parser = SmileyParser.getInstance();
            buf.append(parser.addSmileySpans(body));
        }
    }

    // We always show two lines because the optional icon bottoms are
    // aligned with the
    // bottom of the text field, assuming there are two lines for the
    // message and the sent time.
    buf.append("\n");
    int startOffset = buf.length();

    startOffset = buf.length();

    buf.setSpan(mTextSmallSpan, startOffset, buf.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    return buf;
}

From source file:de.schildbach.litecoinwallet.ui.WalletDisclaimerFragment.java

private void updateView() {
    if (!isResumed())
        return;//from  w  w w .jav a2  s  . c om

    final boolean showBackup = prefs.getBoolean(Constants.PREFS_KEY_REMIND_BACKUP, true);
    final boolean showSafety = prefs.getBoolean(Constants.PREFS_KEY_DISCLAIMER, true);

    final int progressResId;
    if (download == BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_OK)
        progressResId = 0;
    else if ((download & BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_STORAGE_PROBLEM) != 0)
        progressResId = R.string.blockchain_state_progress_problem_storage;
    else if ((download & BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_NETWORK_PROBLEM) != 0)
        progressResId = R.string.blockchain_state_progress_problem_network;
    else
        throw new IllegalStateException("download=" + download);

    final SpannableStringBuilder text = new SpannableStringBuilder();
    if (progressResId != 0)
        text.append(Html.fromHtml("<b>" + getString(progressResId) + "</b>"));
    if (progressResId != 0 && (showBackup || showSafety))
        text.append('\n');
    if (showBackup)
        text.append(Html.fromHtml(getString(R.string.wallet_disclaimer_fragment_remind_backup)));
    if (showBackup && showSafety)
        text.append('\n');
    if (showSafety)
        text.append(Html.fromHtml(getString(R.string.wallet_disclaimer_fragment_remind_safety)));
    messageView.setText(text);

    final View view = getView();
    final ViewParent parent = view.getParent();
    final View fragment = parent instanceof FrameLayout ? (FrameLayout) parent : view;
    fragment.setVisibility(text.length() > 0 ? View.VISIBLE : View.GONE);
}

From source file:com.yahala.ui.GroupCreateActivity.java

public XImageSpan createAndPutChipForUser(TLRPC.User user) {
    LayoutInflater lf = (LayoutInflater) parentActivity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    View textView = lf.inflate(R.layout.group_create_bubble, null);
    TextView text = (TextView) textView.findViewById(R.id.bubble_text_view);
    String name = Utilities.formatName(user.first_name, user.last_name);
    if (name.length() == 0 && user.phone != null && user.phone.length() != 0) {
        name = PhoneFormat.getInstance().format("+" + user.phone);
    }//from   w  ww .java 2s  .co m
    text.setText(name + ", ");

    int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    textView.measure(spec, spec);
    textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
    Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(b);
    canvas.translate(-textView.getScrollX(), -textView.getScrollY());
    textView.draw(canvas);
    textView.setDrawingCacheEnabled(true);
    Bitmap cacheBmp = textView.getDrawingCache();
    Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true);
    textView.destroyDrawingCache();

    final BitmapDrawable bmpDrawable = new BitmapDrawable(b);
    bmpDrawable.setBounds(0, 0, b.getWidth(), b.getHeight());

    SpannableStringBuilder ssb = new SpannableStringBuilder("");
    XImageSpan span = new XImageSpan(bmpDrawable, ImageSpan.ALIGN_BASELINE);
    allSpans.add(span);
    selectedContacts.put(user.jid, span);
    for (ImageSpan sp : allSpans) {
        ssb.append("<<");
        ssb.setSpan(sp, ssb.length() - 2, ssb.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    userSelectEditText.setText(ssb);
    userSelectEditText.setSelection(ssb.length());
    return span;
}

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

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

    final boolean showBackup = config.remindBackup();
    final boolean showDisclaimer = config.getDisclaimerEnabled();

    final int progressResId;
    if (download == BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_OK)
        progressResId = 0;
    else if ((download & BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_STORAGE_PROBLEM) != 0)
        progressResId = R.string.blockchain_state_progress_problem_storage;
    else if ((download & BlockchainService.ACTION_BLOCKCHAIN_STATE_DOWNLOAD_NETWORK_PROBLEM) != 0)
        progressResId = R.string.blockchain_state_progress_problem_network;
    else
        throw new IllegalStateException("download=" + download);

    final SpannableStringBuilder text = new SpannableStringBuilder();
    if (progressResId != 0)
        text.append(Html.fromHtml("<b>" + getString(progressResId) + "</b>"));
    if (progressResId != 0 && (showBackup || showDisclaimer))
        text.append('\n');
    if (showBackup)
        text.append(Html.fromHtml(getString(R.string.wallet_disclaimer_fragment_remind_backup)));
    if (showBackup && showDisclaimer)
        text.append('\n');
    if (showDisclaimer)
        text.append(Html.fromHtml(getString(R.string.wallet_disclaimer_fragment_remind_safety)));
    messageView.setText(text);

    final View view = getView();
    final ViewParent parent = view.getParent();
    final View fragment = parent instanceof FrameLayout ? (FrameLayout) parent : view;
    fragment.setVisibility(text.length() > 0 ? View.VISIBLE : View.GONE);
}

From source file:com.juick.android.JuickMessagesAdapter.java

private static void setStyleSpans(SpannableStringBuilder ssb, int ssbOffset, Object what, String styleChar) {
    String txt;/*  w  ww.jav a2s  .  c om*/
    txt = ssb.subSequence(ssbOffset, ssb.length()).toString();
    txt = " " + txt + " ";
    ssbOffset -= 1;
    //
    int scan = 0;
    int cnt = 0;
    while (cnt++ < 20) { // don't need bugs in production.
        int ix = txt.indexOf(styleChar, scan);
        if (ix < 0)
            break;
        if (" \n".indexOf(txt.charAt(ix - 1)) != -1) {
            int ix2 = txt.indexOf(styleChar, ix + 1);
            if (ix2 < 0)
                break;
            if (" \n".indexOf(txt.charAt(ix2 + 1)) == -1 // not ends with space
                    || txt.substring(ix, ix2).indexOf("\n") != -1) { // spans several lines
                scan = ix2; // not ok
                continue;
            } else {
                CharacterStyle span = null;
                CharacterStyle span2 = null;
                // found needed stuff
                if (what instanceof Integer && (((Integer) what) == Typeface.BOLD)) {
                    span = new StyleSpan(Typeface.BOLD);
                    if (helvNueFonts) {
                        span2 = new CustomTypefaceSpan("", JuickAdvancedApplication.helvNueBold);
                    }
                }
                if (what instanceof Integer && (((Integer) what) == Typeface.ITALIC)) {
                    span = new StyleSpan(Typeface.ITALIC);
                }
                if (what == UnderlineSpan.class) {
                    span = new UnderlineSpan();
                }
                if (span != null && ix2 - ix > 1) {
                    ssb.delete(ssbOffset + ix, ssbOffset + ix + 1); // delete styling char
                    txt = stringDelete(txt, ix, ix + 1);
                    ix2--; // moves, too
                    ssb.delete(ssbOffset + ix2, ssbOffset + ix2 + 1); // second char deleted
                    txt = stringDelete(txt, ix2, ix2 + 1);
                    ssb.setSpan(span, ssbOffset + ix, ssbOffset + ix2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                    if (span2 != null) {
                        ssb.setSpan(span2, ssbOffset + ix, ssbOffset + ix2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                    }
                }
                scan = ix2;
            }
        }
    }
}

From source file:com.abcvoipsip.ui.messages.ConverstationsAdapter.java

private CharSequence formatMessage(Cursor cursor) {
    SpannableStringBuilder buf = new SpannableStringBuilder();
    /*/*www.  jav a2s . c o  m*/
    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));
    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:com.yahala.ui.GroupCreateActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (fragmentView == null) {

        searching = false;//w ww .j  a v a  2  s . co m
        searchWas = false;

        fragmentView = inflater.inflate(R.layout.group_create_layout, container, false);

        emptyTextView = (TextView) fragmentView.findViewById(R.id.searchEmptyView);
        emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
        userSelectEditText = (EditText) fragmentView.findViewById(R.id.bubble_input_text);
        userSelectEditText.setHint(LocaleController.getString("SendMessageTo", R.string.SendMessageTo));
        if (Build.VERSION.SDK_INT >= 11) {
            userSelectEditText.setTextIsSelectable(false);
        }
        userSelectEditText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {
                if (!ignoreChange) {
                    beforeChangeIndex = userSelectEditText.getSelectionStart();
                    changeString = new SpannableString(charSequence);
                }
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                if (!ignoreChange) {
                    boolean search = false;
                    int afterChangeIndex = userSelectEditText.getSelectionEnd();
                    if (editable.toString().length() < changeString.toString().length()) {
                        String deletedString = "";
                        try {
                            deletedString = changeString.toString().substring(afterChangeIndex,
                                    beforeChangeIndex);
                        } catch (Exception e) {
                            FileLog.e("tmessages", e);
                        }
                        if (deletedString.length() > 0) {
                            if (searching && searchWas) {
                                search = true;
                            }
                            Spannable span = userSelectEditText.getText();
                            for (int a = 0; a < allSpans.size(); a++) {
                                XImageSpan sp = allSpans.get(a);
                                if (span.getSpanStart(sp) == -1) {
                                    allSpans.remove(sp);
                                    selectedContacts.remove(sp.jid);
                                }
                            }
                            if (parentActivity != null) {
                                ActionBar actionBar = parentActivity.getSupportActionBar();
                                actionBar.setSubtitle(String.format("%d/200 %s", selectedContacts.size(),
                                        LocaleController.getString("Members", R.string.Members)));
                            }
                            listView.invalidateViews();
                        } else {
                            search = true;
                        }
                    } else {
                        search = true;
                    }
                    if (search) {
                        String text = userSelectEditText.getText().toString().replace("<", "");
                        if (text.length() != 0) {
                            searchDialogs(text);
                            searching = true;
                            searchWas = true;
                            emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
                            listViewAdapter.notifyDataSetChanged();
                        } else {
                            searchResult = null;
                            searchResultNames = null;
                            searching = false;
                            searchWas = false;
                            emptyTextView
                                    .setText(LocaleController.getString("NoContacts", R.string.NoContacts));
                            listViewAdapter.notifyDataSetChanged();
                        }
                    }
                }
            }
        });

        listView = (PinnedHeaderListView) fragmentView.findViewById(R.id.listView);
        listView.setEmptyView(emptyTextView);
        listView.setVerticalScrollBarEnabled(false);

        listView.setAdapter(listViewAdapter = new ListAdapter(parentActivity));
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                TLRPC.User user;
                int section = listViewAdapter.getSectionForPosition(i);
                int row = listViewAdapter.getPositionInSectionForPosition(i);
                if (searching && searchWas) {
                    user = searchResult.get(row);
                } else {
                    ArrayList<TLRPC.User> arr = com.yahala.xmpp.ContactsController
                            .getInstance().usersSectionsDict.get(
                                    com.yahala.xmpp.ContactsController.getInstance().sortedUsersSectionsArray
                                            .get(section));
                    user = com.yahala.xmpp.ContactsController.getInstance().friendsDict.get(arr.get(row).jid);
                    listView.invalidateViews();
                }
                if (selectedContacts.containsKey(user.jid)) {
                    XImageSpan span = selectedContacts.get(user.jid);
                    selectedContacts.remove(user.jid);
                    SpannableStringBuilder text = new SpannableStringBuilder(userSelectEditText.getText());
                    text.delete(text.getSpanStart(span), text.getSpanEnd(span));
                    allSpans.remove(span);
                    ignoreChange = true;
                    userSelectEditText.setText(text);
                    userSelectEditText.setSelection(text.length());
                    ignoreChange = false;
                } else {
                    if (selectedContacts.size() == 200) {
                        return;
                    }
                    ignoreChange = true;
                    XImageSpan span = createAndPutChipForUser(user);
                    span.jid = user.jid;
                    ignoreChange = false;
                }
                if (parentActivity != null) {
                    ActionBar actionBar = parentActivity.getSupportActionBar();
                    actionBar.setSubtitle(String.format("%d/200 %s", selectedContacts.size(),
                            LocaleController.getString("Members", R.string.Members)));
                }
                if (searching || searchWas) {
                    searching = false;
                    searchWas = false;
                    emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));

                    ignoreChange = true;
                    SpannableStringBuilder ssb = new SpannableStringBuilder("");
                    for (ImageSpan sp : allSpans) {
                        ssb.append("<<");
                        ssb.setSpan(sp, ssb.length() - 2, ssb.length(),
                                SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
                    }
                    userSelectEditText.setText(ssb);
                    userSelectEditText.setSelection(ssb.length());
                    ignoreChange = false;

                    listViewAdapter.notifyDataSetChanged();
                } else {
                    listView.invalidateViews();
                }
            }
        });
    } else {
        ViewGroup parent = (ViewGroup) fragmentView.getParent();
        if (parent != null) {
            parent.removeView(fragmentView);
        }
    }
    return fragmentView;
}