use of android.text.Editable in project k-9 by k9mail.
the class RecipientSelectView method getTokenViewForRecipient.
/**
* Find the token view tied to a given recipient. This method relies on spans to
* be of the RecipientTokenSpan class, as created by the buildSpanForObject method.
*/
private View getTokenViewForRecipient(Recipient currentRecipient) {
Editable text = getText();
if (text == null) {
return null;
}
RecipientTokenSpan[] recipientSpans = text.getSpans(0, text.length(), RecipientTokenSpan.class);
for (RecipientTokenSpan recipientSpan : recipientSpans) {
if (recipientSpan.getToken().equals(currentRecipient)) {
return recipientSpan.view;
}
}
return null;
}
use of android.text.Editable in project Jota-Text-Editor-old by jiro-aqua.
the class Main method sendDirectIntent.
private void sendDirectIntent(Intent intent) {
if (intent == null) {
return;
} else {
String substr = null;
Editable text = mEditor.getText();
int startsel = mEditor.getSelectionStart();
int endsel = mEditor.getSelectionEnd();
if (startsel != endsel) {
if (endsel < startsel) {
int temp = startsel;
startsel = endsel;
endsel = temp;
}
if (endsel - startsel > jp.sblo.pandora.jota.text.TextView.MAX_PARCELABLE) {
Toast.makeText(Main.this, R.string.toast_overflow_of_limit, Toast.LENGTH_LONG).show();
return;
}
substr = text.subSequence(startsel, endsel).toString();
}
if (intent.getAction().equals(Intent.ACTION_SEND)) {
if (substr != null) {
intent.putExtra(Intent.EXTRA_TEXT, substr);
} else {
if (text.length() <= jp.sblo.pandora.jota.text.TextView.MAX_PARCELABLE) {
intent.putExtra(Intent.EXTRA_TEXT, text.toString());
} else {
Toast.makeText(Main.this, R.string.toast_overflow_of_limit, Toast.LENGTH_LONG).show();
return;
}
}
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
}
} else if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
if (substr != null) {
intent.putExtra(SearchManager.QUERY, substr);
} else {
return;
}
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
}
} else if (intent.getAction().equals("com.adamrocker.android.simeji.ACTION_INTERCEPT")) {
if (substr != null) {
intent.putExtra("replace_key", substr);
} else {
intent.putExtra("replace_key", "");
}
startActivityForResult(intent, REQUESTCODE_MUSHROOM);
} else if (intent.getAction().equals(Intent.ACTION_VIEW)) {
if (mInstanceState.filename != null || mEditor.isChanged()) {
mProcViewByIntent.setIntent(intent);
confirmSave(mProcViewByIntent);
}
}
}
}
use of android.text.Editable in project Jota-Text-Editor-old by jiro-aqua.
the class WordCounter method count.
public static Result count(TextView textview) {
Result result = new Result();
Editable text = (Editable) textview.getText();
result.charactrers = text.length();
result.lines = textview.getLineCount();
result.logicallines = countPatterns("\n", text);
result.words = countPatterns("\\w+", text);
return result;
}
use of android.text.Editable in project Klyph by jonathangerbaud.
the class FriendPickerActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
singleChoice = getIntent().getBooleanExtra(KlyphBundleExtras.SINGLE_CHOICE, false);
setTitle(singleChoice ? R.string.friend_picker_single_choice_title : R.string.friend_picker_title);
setListAdapter(new MultiObjectAdapter(getListView(), singleChoice ? SpecialLayout.FRIEND_PICKER_SINGLE : SpecialLayout.FRIEND_PICKER));
getListView().setItemsCanFocus(false);
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
searchText = (EditText) findViewById(R.id.search_text);
searchText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
filter(s.toString());
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
setRequestType(Query.ALL_FRIENDS);
if (getIntent().hasExtra(KlyphBundleExtras.FRIEND_PICKER_IDS)) {
ArrayList<String> ids = getIntent().getStringArrayListExtra(KlyphBundleExtras.FRIEND_PICKER_IDS);
if (ids != null && ids.size() > 0) {
initialIds = ids;
}
}
if (FRIEND_LIST == null) {
load();
} else {
// reset previously selected objects
for (GraphObject graphObject : FRIEND_LIST) {
graphObject.setSelected(false);
}
populate(FRIEND_LIST);
}
}
use of android.text.Editable in project UltimateAndroid by cymcsg.
the class CalligraphyUtils method applyFontToTextView.
/**
* Applies a Typeface to a TextView, its recommend you don't call this multiple times, as this
* adds a TextWatcher.
*
* @param textView Not null, TextView or child of.
* @param typeface Not null, Typeface to apply to the TextView.
* @return true if applied otherwise false.
*/
public static boolean applyFontToTextView(final TextView textView, final Typeface typeface) {
if (textView == null || typeface == null)
return false;
textView.setPaintFlags(textView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
textView.setText(applyTypefaceSpan(textView.getText(), typeface), TextView.BufferType.SPANNABLE);
textView.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) {
}
@Override
public void afterTextChanged(Editable s) {
applyTypefaceSpan(s, typeface);
}
});
return true;
}
Aggregations