use of android.text.Editable in project Talon-for-Twitter by klinker24.
the class UserAutoCompleteHelper method on.
private void on(final EditText textView) {
userAutoComplete.setAnchorView(textView);
textView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
String tvText = textView.getText().toString();
try {
int position = textView.getSelectionStart() - 1;
if (tvText.charAt(position) == '@') {
userAutoComplete.show();
} else if (!tvText.contains("@")) {
userAutoComplete.dismiss();
} else if (userAutoComplete.isShowing()) {
String searchText = "";
do {
searchText = tvText.charAt(position--) + searchText;
} while (tvText.charAt(position) != '@');
searchText = searchText.replace("@", "");
search(searchText);
}
} catch (Exception e) {
e.printStackTrace();
userAutoComplete.dismiss();
}
}
});
userAutoComplete.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
userAutoComplete.dismiss();
autoCompleter.completeTweet(textView, users.get(i).getScreenName(), '@');
if (callback != null) {
callback.onUserSelected(users.get(i));
}
}
});
}
use of android.text.Editable in project KJFrameForAndroid by kymjs.
the class TweetRecordFragment method initWidget.
@Override
protected void initWidget(View view) {
super.initWidget(view);
RelativeLayout.LayoutParams params = (LayoutParams) mBtnRecort.getLayoutParams();
params.width = DensityUtils.getScreenW(getActivity());
params.height = (int) (DensityUtils.getScreenH(getActivity()) * 0.4);
mBtnRecort.setLayoutParams(params);
mBtnRecort.setOnFinishedRecordListener(new OnFinishedRecordListener() {
@Override
public void onFinishedRecord(String audioPath, int recordTime) {
mLayout.setVisibility(View.VISIBLE);
if (recordTime < 10) {
mTvTime.setText("0" + recordTime + "\"");
} else {
mTvTime.setText(recordTime + "\"");
}
mImgAdd.setVisibility(View.GONE);
filePath = null;
}
@Override
public void onCancleRecord() {
mLayout.setVisibility(View.GONE);
}
});
drawable = (AnimationDrawable) mImgVolume.getBackground();
mBtnRecort.getAudioUtil().setOnPlayListener(new OnPlayListener() {
@Override
public void stopPlay() {
drawable.stop();
mImgVolume.setBackgroundDrawable(drawable.getFrame(0));
}
@Override
public void starPlay() {
mImgVolume.setBackgroundDrawable(drawable);
drawable.start();
}
});
mEtSpeech.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() > MAX_LEN) {
mTvInputLen.setText("已达到最大长度");
} else {
mTvInputLen.setText("你还可以输入" + (MAX_LEN - s.length()) + "个字");
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
if (s.length() > MAX_LEN) {
mEtSpeech.setText(s.subSequence(0, MAX_LEN));
CharSequence text = mEtSpeech.getText();
if (text instanceof Spannable) {
Selection.setSelection((Spannable) text, MAX_LEN);
}
}
}
});
}
use of android.text.Editable in project k-9 by k9mail.
the class AccountSetupNames method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.account_setup_names);
mDescription = (EditText) findViewById(R.id.account_description);
mName = (EditText) findViewById(R.id.account_name);
mDoneButton = (Button) findViewById(R.id.done);
mDoneButton.setOnClickListener(this);
TextWatcher validationTextWatcher = new TextWatcher() {
public void afterTextChanged(Editable s) {
validateFields();
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
};
mName.addTextChangedListener(validationTextWatcher);
mName.setKeyListener(TextKeyListener.getInstance(false, Capitalize.WORDS));
String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
// mDescription.setText(mAccount.getDescription());
if (mAccount.getName() != null) {
mName.setText(mAccount.getName());
}
if (!Utility.requiredFieldValid(mName)) {
mDoneButton.setEnabled(false);
}
}
use of android.text.Editable in project Signal-Android by WhisperSystems.
the class PassphraseChangeActivity method verifyAndSavePassphrases.
private void verifyAndSavePassphrases() {
Editable originalText = this.originalPassphrase.getText();
Editable newText = this.newPassphrase.getText();
Editable repeatText = this.repeatPassphrase.getText();
String original = (originalText == null ? "" : originalText.toString());
String passphrase = (newText == null ? "" : newText.toString());
String passphraseRepeat = (repeatText == null ? "" : repeatText.toString());
if (TextSecurePreferences.isPasswordDisabled(this)) {
original = MasterSecretUtil.UNENCRYPTED_PASSPHRASE;
}
if (!passphrase.equals(passphraseRepeat)) {
this.newPassphrase.setText("");
this.repeatPassphrase.setText("");
this.newPassphrase.setError(getString(R.string.PassphraseChangeActivity_passphrases_dont_match_exclamation));
this.newPassphrase.requestFocus();
} else if (passphrase.equals("")) {
this.newPassphrase.setError(getString(R.string.PassphraseChangeActivity_enter_new_passphrase_exclamation));
this.newPassphrase.requestFocus();
} else {
new ChangePassphraseTask(this).execute(original, passphrase);
}
}
use of android.text.Editable in project Signal-Android by WhisperSystems.
the class PassphrasePromptActivity method handlePassphrase.
private void handlePassphrase() {
try {
Editable text = passphraseText.getText();
String passphrase = (text == null ? "" : text.toString());
MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(this, passphrase);
setMasterSecret(masterSecret);
} catch (InvalidPassphraseException ipe) {
passphraseText.setText("");
passphraseText.setError(getString(R.string.PassphrasePromptActivity_invalid_passphrase_exclamation));
}
}
Aggregations