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);
}
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;
}
use of android.text.Editable in project FlexibleAdapter by davideas.
the class EditItemDialog method onCreateDialog.
@SuppressLint({ "InflateParams", "HandlerLeak" })
@Override
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
//Pick up bundle parameters
Bundle bundle;
if (savedInstanceState == null) {
bundle = getArguments();
} else {
bundle = savedInstanceState;
}
mTitle = bundle.getString(ARG_TITLE);
mPosition = bundle.getInt(ARG_ITEM_POSITION);
//Inflate custom view
View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_edit_item, null);
final EditText editText = (EditText) dialogView.findViewById(R.id.text_edit_title);
//, R.style.AppTheme_AlertDialog);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.dialog_edit_title).setView(dialogView).setNegativeButton(R.string.CANCEL, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Utils.hideSoftInputFrom(getActivity(), editText);
dialog.dismiss();
}
}).setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
getListener().onTitleModified(mPosition, editText.getText().toString().trim());
Utils.hideSoftInputFrom(getActivity(), editText);
dialog.dismiss();
}
});
final AlertDialog editDialog = builder.create();
editDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
updateOkButtonState(editDialog, null);
}
});
if (mTitle != null) {
editText.setText(mTitle);
editText.selectAll();
}
editText.requestFocus();
editText.addTextChangedListener(new SimpleTextWatcher() {
private static final long DELAY = 400L;
private static final int TRIGGER = 1;
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.what == TRIGGER) {
updateOkButtonState(editDialog, editText);
}
}
};
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
updateOkButtonState(editDialog, null);
}
@Override
public void afterTextChanged(Editable s) {
mHandler.removeMessages(TRIGGER);
mHandler.sendEmptyMessageDelayed(TRIGGER, DELAY);
}
});
editDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
return editDialog;
}
use of android.text.Editable in project philm by chrisbanes.
the class FloatLabelLayout method setEditText.
private void setEditText(EditText editText) {
// If we already have an EditText, throw an exception
if (mEditText != null) {
throw new IllegalArgumentException("We already have an EditText, can only have one");
}
mEditText = editText;
// Update the label visibility with no animation
updateLabelVisibility(false);
// Add a TextWatcher so that we know when the text input has changed
mEditText.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
updateLabelVisibility(true);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
});
// Add focus listener to the EditText so that we can notify the label that it is activated.
// Allows the use of a ColorStateList for the text color on the label
mEditText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean focused) {
updateLabelVisibility(true);
}
});
// If we do not have a valid hint, try and retrieve it from the EditText
if (TextUtils.isEmpty(mHint)) {
setHint(mEditText.getHint());
}
}
Aggregations