List of usage examples for android.view.inputmethod BaseInputConnection removeComposingSpans
public static final void removeComposingSpans(Spannable text)
From source file:com.android.mail.compose.ComposeActivity.java
/** * Removes any composing spans from the specified string. This will create a new * SpannableString instance, as to not modify the behavior of the EditText view. *//*from w ww . j a v a 2s. c om*/ private static SpannableString removeComposingSpans(Spanned body) { final SpannableString messageBody = new SpannableString(body); BaseInputConnection.removeComposingSpans(messageBody); // Remove watcher spans while we're at it, so any off-UI thread manipulation of these // spans doesn't trigger unexpected side-effects. This copy is essentially 100% detached // from the EditText. // // (must remove SpanWatchers first to avoid triggering them as we remove other spans) removeSpansOfType(messageBody, SpanWatcher.class); removeSpansOfType(messageBody, TextWatcher.class); return messageBody; }
From source file:com.tct.mail.compose.ComposeActivity.java
/** * Removes any composing spans from the specified string. This will create a new * SpannableString instance, as to not modify the behavior of the EditText view. *///from w ww . j av a 2 s . c o m private static SpannableString removeComposingSpans(Spanned body) { // TS: tao.gan 2015-09-18 EMAIL BUGFIX_1088747 MOD_S //Why init the SpanableString would throw IndexOutOfBoundsException? //Only catch it... SpannableString messageBody; try { messageBody = new SpannableString(body); } catch (IndexOutOfBoundsException e) { messageBody = new SpannableString(""); LogUtils.e(LogUtils.TAG, "IndexOutOfBoundsException while init the spannableString"); } // TS: tao.gan 2015-09-18 EMAIL BUGFIX_1088747 MOD_S //TS: kaifeng.lu 2015-8-7 EMAIL BUGFIX_1063281 MOD_S try { BaseInputConnection.removeComposingSpans(messageBody); } catch (IndexOutOfBoundsException e) { LogUtils.e(LOG_TAG, "Occur IndexOutOfBoundsException"); } //TS: kaifeng.lu 2015-8-7 EMAIL BUGFIX_1063281 MOD_E // Remove watcher spans while we're at it, so any off-UI thread manipulation of these // spans doesn't trigger unexpected side-effects. This copy is essentially 100% detached // from the EditText. // // (must remove SpanWatchers first to avoid triggering them as we remove other spans) removeSpansOfType(messageBody, SpanWatcher.class); removeSpansOfType(messageBody, TextWatcher.class); return messageBody; }