Search in sources :

Example 1 with UserSpan

use of im.actor.sdk.controllers.compose.view.UserSpan in project actor-platform by actorapp.

the class GroupUsersFragment method updateEditText.

private void updateEditText() {
    Integer[] selected = getSelected();
    String src = "";
    for (int i = 0; i < selected.length; i++) {
        src += "!";
    }
    Spannable spannable = new SpannableString(src);
    for (int i = 0; i < selected.length; i++) {
        spannable.setSpan(new UserSpan(users().get(selected[i]), Screen.dp(200)), i, i + 1, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    }
    searchField.removeTextChangedListener(textWatcher);
    searchField.setText(spannable);
    searchField.setSelection(spannable.length());
    searchField.addTextChangedListener(textWatcher);
    filter("");
    getAdapter().notifyDataSetChanged();
}
Also used : SpannableString(android.text.SpannableString) UserSpan(im.actor.sdk.controllers.compose.view.UserSpan) SpannableString(android.text.SpannableString) Spannable(android.text.Spannable)

Example 2 with UserSpan

use of im.actor.sdk.controllers.compose.view.UserSpan in project actor-platform by actorapp.

the class GroupUsersFragment method checkForDeletions.

private void checkForDeletions(Editable editable) {
    Integer[] selected = getSelected();
    boolean hasDeletions = false;
    UserSpan[] spans = editable.getSpans(0, editable.length(), UserSpan.class);
    for (Integer u : selected) {
        boolean founded = false;
        for (UserSpan span : spans) {
            if (span.getUser().getId() == u) {
                if (editable.getSpanStart(span) == editable.getSpanEnd(span)) {
                    break;
                } else {
                    founded = true;
                    break;
                }
            }
        }
        if (!founded) {
            hasDeletions = true;
            unselect(u);
        }
    }
    if (hasDeletions) {
        getActivity().invalidateOptionsMenu();
        getAdapter().notifyDataSetChanged();
    }
}
Also used : UserSpan(im.actor.sdk.controllers.compose.view.UserSpan)

Aggregations

UserSpan (im.actor.sdk.controllers.compose.view.UserSpan)2 Spannable (android.text.Spannable)1 SpannableString (android.text.SpannableString)1