/** * Test if the given {@link CharSequence} contains any graphic characters, * first checking {@link TextUtils#isEmpty(CharSequence)} to handle null. */ public static boolean isGraphic(CharSequence str) { return !TextUtils.isEmpty(str) && TextUtils.isGraphic(str); }
private String getValueFormattedInGraphicCharacters(byte[] value, ElementPath elementPath) { String valueString = getValueFormatted(value, elementPath.dataFormat); // if format is auto and the result is not visible, change the format to hex if (valueString != null && elementPath.dataFormat == kDataFormat_Auto && !TextUtils.isGraphic(valueString)) { elementPath.dataFormat = kDataFormat_Hex; valueString = getValueFormatted(value, elementPath.dataFormat); } return valueString; }
final boolean validValue = (value != null && TextUtils.isGraphic(value)); if (!validValue || !canInsert) return null;
public void format(final Editable to, final int toStart, final int toEnd, final CharSequence from, final int fromStart, final int fromEnd) { final int selectionStart = Selection.getSelectionStart(to); final int selectionEnd = Selection.getSelectionStart(to); buffer.clear(); buffer.append(to); if (selectionStart != -1 && selectionEnd != -1) { Selection.setSelection(buffer, selectionStart, selectionEnd); } buffer.replace(toStart, toEnd, from, fromStart, fromEnd); if (!TextUtils.isGraphic(buffer)) { return; } formatPhoneNumberInput(buffer); }