public override void performValidation()
        {
            android.widget.AutoCompleteTextView.Validator v = getValidator();
            if (v == null || mTokenizer == null)
            {
                return;
            }
            android.text.Editable e = ((android.text.Editable)getText());
            int i = ((android.text.Editable)getText()).Length;

            while (i > 0)
            {
                int start = mTokenizer.findTokenStart(e, i);
                int end   = mTokenizer.findTokenEnd(e, start);
                java.lang.CharSequence sub = e.SubSequence(start, end);
                if (android.text.TextUtils.isEmpty(sub))
                {
                    e.replace(start, i, java.lang.CharSequenceProxy.Wrap(string.Empty));
                }
                else
                {
                    if (!v.isValid(sub))
                    {
                        e.replace(start, i, mTokenizer.terminateToken(v.fixText(sub)));
                    }
                }
                i = start;
            }
        }
Exemple #2
0
        private void spellCheck()
        {
            if (mSpellCheckerSession == null)
            {
                return;
            }
            android.text.Editable editable = (android.text.Editable)mTextView.getText();
            int selectionStart             = android.text.Selection.getSelectionStart(editable);
            int selectionEnd = android.text.Selection.getSelectionEnd(editable);

            android.view.textservice.TextInfo[] textInfos = new android.view.textservice.TextInfo
                                                            [mLength];
            int textInfosCount = 0;

            {
                for (int i = 0; i < mLength; i++)
                {
                    android.text.style.SpellCheckSpan spellCheckSpan = mSpellCheckSpans[i];
                    if (spellCheckSpan.isSpellCheckInProgress())
                    {
                        continue;
                    }
                    int start = editable.getSpanStart(spellCheckSpan);
                    int end   = editable.getSpanEnd(spellCheckSpan);
                    // Do not check this word if the user is currently editing it
                    if (start >= 0 && end > start && (selectionEnd < start || selectionStart > end))
                    {
                        string word = editable.SubSequence(start, end).ToString();
                        spellCheckSpan.setSpellCheckInProgress(true);
                        textInfos[textInfosCount++] = new android.view.textservice.TextInfo(word, mCookie
                                                                                            , mIds[i]);
                    }
                }
            }
            if (textInfosCount > 0)
            {
                if (textInfosCount < textInfos.Length)
                {
                    android.view.textservice.TextInfo[] textInfosCopy = new android.view.textservice.TextInfo
                                                                        [textInfosCount];
                    System.Array.Copy(textInfos, 0, textInfosCopy, 0, textInfosCount);
                    textInfos = textInfosCopy;
                }
                mSpellCheckerSession.getSuggestions(textInfos, android.text.style.SuggestionSpan.
                                                    SUGGESTIONS_MAX_SIZE, false);
            }
        }