Search in sources :

Example 86 with Editable

use of android.text.Editable in project CoCoin by Nightonke.

the class HelpFeedbackFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mScrollView = (ObservableScrollView) view.findViewById(R.id.scrollView);
    MaterialViewPagerHelper.registerScrollView(getActivity(), mScrollView, null);
    title = (TextView) view.findViewById(R.id.title);
    title.setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    input = (EditText) view.findViewById(R.id.edittext);
    input.setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    help = (TextView) view.findViewById(R.id.helper);
    help.setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    number = (TextView) view.findViewById(R.id.number);
    number.setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    send = (TextView) view.findViewById(R.id.send);
    send.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (exceed) {
                new MaterialDialog.Builder(mContext).title(R.string.help_feedback_dialog_title).content(R.string.help_feedback_dialog_content).positiveText(R.string.ok_1).show();
            } else {
                CoCoinUtil.getInstance().showToast(CoCoinApplication.getAppContext(), CoCoinApplication.getAppContext().getResources().getString(R.string.help_feedback_sent));
                Feedback feedback = new Feedback();
                feedback.setContent(input.getText().toString());
                feedback.save(CoCoinApplication.getAppContext(), new SaveListener() {

                    @Override
                    public void onSuccess() {
                        CoCoinUtil.getInstance().showToast(CoCoinApplication.getAppContext(), CoCoinApplication.getAppContext().getResources().getString(R.string.help_feedback_sent_successfully));
                    }

                    @Override
                    public void onFailure(int code, String arg0) {
                        CoCoinUtil.getInstance().showToast(CoCoinApplication.getAppContext(), CoCoinApplication.getAppContext().getResources().getString(R.string.help_feedback_sent_fail));
                    }
                });
            }
        }
    });
    input.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            setNumberText();
            try {
                ((OnTextChangeListener) activity).onTextChange(input.getText().toString(), exceed);
            } catch (ClassCastException cce) {
                cce.printStackTrace();
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    send.requestFocus();
    setNumberText();
}
Also used : SaveListener(cn.bmob.v3.listener.SaveListener) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) TextView(android.widget.TextView) ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) View(android.view.View) Feedback(com.nightonke.saver.model.Feedback) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

Example 87 with Editable

use of android.text.Editable in project HoloEverywhere by Prototik.

the class MultiAutoCompleteTextView method replaceText.

@Override
protected void replaceText(CharSequence text) {
    clearComposingText();
    int end = getSelectionEnd();
    int start = mTokenizer.findTokenStart(getText(), end);
    Editable editable = getText();
    String original = TextUtils.substring(editable, start, end);
    QwertyKeyListener.markAsReplaced(editable, start, end, original);
    editable.replace(start, end, mTokenizer.terminateToken(text));
}
Also used : Editable(android.text.Editable) SpannableString(android.text.SpannableString) SuppressLint(android.annotation.SuppressLint)

Example 88 with Editable

use of android.text.Editable in project HoloEverywhere by Prototik.

the class MultiAutoCompleteTextView method performValidation.

@Override
public void performValidation() {
    Validator v = getValidator();
    if (v == null || mTokenizer == null) {
        return;
    }
    Editable e = getText();
    int i = getText().length();
    while (i > 0) {
        int start = mTokenizer.findTokenStart(e, i);
        int end = mTokenizer.findTokenEnd(e, start);
        CharSequence sub = e.subSequence(start, end);
        if (TextUtils.isEmpty(sub)) {
            e.replace(start, i, "");
        } else if (!v.isValid(sub)) {
            e.replace(start, i, mTokenizer.terminateToken(v.fixText(sub)));
        }
        i = start;
    }
}
Also used : Editable(android.text.Editable) SuppressLint(android.annotation.SuppressLint)

Example 89 with Editable

use of android.text.Editable in project Anki-Android by Ramblurr.

the class CardEditor method initFieldEditText.

private void initFieldEditText(FieldEditText editText, int index, String[] values, Typeface customTypeface) {
    String name = values[0];
    String content = values[1];
    if (mPrefFixArabic) {
        content = ArabicUtilities.reshapeSentence(content);
    }
    editText.init(index, name, content);
    if (customTypeface != null) {
        editText.setTypeface(customTypeface);
    }
    if (index == 0) {
        editText.addTextChangedListener(new TextWatcher() {

            @Override
            public void afterTextChanged(Editable arg0) {
                mTimerHandler.removeCallbacks(checkDuplicatesRunnable);
                mTimerHandler.postDelayed(checkDuplicatesRunnable, WAIT_TIME_UNTIL_UPDATE);
            }

            @Override
            public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
            }

            @Override
            public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
            }
        });
    }
}
Also used : TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

Example 90 with Editable

use of android.text.Editable in project k-9 by k9mail.

the class RecipientSelectView method onTouchEvent.

@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
    int action = event.getActionMasked();
    Editable text = getText();
    if (text != null && action == MotionEvent.ACTION_UP) {
        int offset = getOffsetForPosition(event.getX(), event.getY());
        if (offset != -1) {
            TokenImageSpan[] links = text.getSpans(offset, offset, RecipientTokenSpan.class);
            if (links.length > 0) {
                showAlternates(links[0].getToken());
                return true;
            }
        }
    }
    return super.onTouchEvent(event);
}
Also used : Editable(android.text.Editable) SuppressLint(android.annotation.SuppressLint)

Aggregations

Editable (android.text.Editable)511 TextWatcher (android.text.TextWatcher)158 View (android.view.View)117 TextView (android.widget.TextView)77 Paint (android.graphics.Paint)73 Spannable (android.text.Spannable)45 TextPaint (android.text.TextPaint)44 EditText (android.widget.EditText)39 KeyEvent (android.view.KeyEvent)34 InputMethodManager (android.view.inputmethod.InputMethodManager)33 Intent (android.content.Intent)30 ImageView (android.widget.ImageView)30 SpellCheckSpan (android.text.style.SpellCheckSpan)26 SuppressLint (android.annotation.SuppressLint)24 AdapterView (android.widget.AdapterView)23 Spanned (android.text.Spanned)22 SuggestionSpan (android.text.style.SuggestionSpan)21 ListView (android.widget.ListView)19 SpannableStringBuilder (android.text.SpannableStringBuilder)18 DialogInterface (android.content.DialogInterface)16