List of usage examples for android.text TextWatcher TextWatcher
TextWatcher
From source file:net.exclaimindustries.geohashdroid.wiki.WikiMessageEditor.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); mInfo = (Info) getIntent().getParcelableExtra(GeohashDroid.INFO); setContentView(R.layout.wikieditor); Button submitButton = (Button) findViewById(R.id.wikieditbutton); submitButton.setOnClickListener(new View.OnClickListener() { @Override// ww w .j a v a2 s. co m public void onClick(View view) { // We don't want to let the Activity handle the dialog. That WILL // cause it to show up properly and all, but after a configuration // change (i.e. orientation shift), it won't show or update any text // (as far as I know), as we can't reassign the handler properly. // So, we'll handle it ourselves. mProgress = ProgressDialog.show(WikiMessageEditor.this, "", "", true, true, WikiMessageEditor.this); mConnectionHandler = new MessageConnectionRunner(mProgressHandler, WikiMessageEditor.this); mWikiConnectionThread = new Thread(mConnectionHandler, "WikiConnectionThread"); mWikiConnectionThread.start(); } }); // In the event the text changes, update the submit button accordingly. TextWatcher tw = new TextWatcher() { @Override public void afterTextChanged(Editable s) { resetSubmitButton(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Blah! } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // BLAH! } }; EditText editText = (EditText) findViewById(R.id.wikiedittext); editText.addTextChangedListener(tw); // Now, let's see if we have anything retained... try { RetainedThings retain = (RetainedThings) getLastNonConfigurationInstance(); if (retain != null) { // We have something retained! Thus, we need to construct the // popup and update it with the right status, assuming the // thread's still going. if (retain.thread != null && retain.thread.isAlive()) { mProgress = ProgressDialog.show(WikiMessageEditor.this, "", "", true, true, WikiMessageEditor.this); mConnectionHandler = retain.handler; mConnectionHandler.resetHandler(mProgressHandler); mWikiConnectionThread = retain.thread; } } } catch (Exception ex) { } }
From source file:com.aibasis.parent.ui.entrance.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharePreferenceUtil sharePreferenceUtil = new SharePreferenceUtil(LoginActivity.this); // ????//from w w w . j av a 2 s .c om if (DemoHXSDKHelper.getInstance().isLogined() && !TextUtils.isEmpty(sharePreferenceUtil.getParentId())) { autoLogin = true; startActivity(new Intent(LoginActivity.this, MainActivity.class)); return; } setContentView(R.layout.activity_login); usernameEditText = (EditText) findViewById(R.id.username); passwordEditText = (EditText) findViewById(R.id.password); // ???? usernameEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { passwordEditText.setText(null); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); if (DemoApplication.getInstance().getUserName() != null) { usernameEditText.setText(DemoApplication.getInstance().getUserName()); } }
From source file:com.lastsoft.plog.wizard.ui.CustomerInfoFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mNameView.addTextChangedListener(new TextWatcher() { @Override//ww w .jav a2 s . c om public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mPage.getData().putString(CustomerInfoPage.NAME_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); mEmailView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mPage.getData().putString(CustomerInfoPage.EMAIL_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); mPasswordView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mPage.getData().putString(CustomerInfoPage.PASSWORD_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); }
From source file:dtu.ds.warnme.app.dialog.RegisterDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_register, null); builder.setView(view);/* w w w .j a v a 2s . c o m*/ builder.setTitle(R.string.register); builder.setPositiveButton(R.string.register, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int which) { // Nothing to do here... } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int which) { // Nothing to do here... } }); progressView = view.findViewById(R.id.dialog_register_progress); formView = view.findViewById(R.id.dialog_register_form); usernameEditText = (EditText) view.findViewById(R.id.dialog_register_edit_text_username); usernameEditText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { // Nothing to do here... } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Nothing to do here... } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { usernameEditText.setError(null); } }); passwordEditText = (EditText) view.findViewById(R.id.dialog_register_edit_text_password); passwordEditText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { // Nothing to do here... } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Nothing to do here... } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { passwordEditText.setError(null); } }); emailEditText = (EditText) view.findViewById(R.id.dialog_register_edit_text_email); emailEditText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { // Nothing to do here... } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Nothing to do here... } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { emailEditText.setError(null); } }); dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE); positiveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String username = usernameEditText.getText().toString(); String password = passwordEditText.getText().toString(); String email = emailEditText.getText().toString(); boolean formOk = true; if (StringUtils.isBlank(username)) { usernameEditText.setError(getString(R.string.cannot_be_empty)); formOk = false; } if (StringUtils.isBlank(password)) { passwordEditText.setError(getString(R.string.cannot_be_empty)); formOk = false; } if (StringUtils.isBlank(email)) { emailEditText.setError(getString(R.string.cannot_be_empty)); formOk = false; } if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) { emailEditText.setError(getString(R.string.invalid_email)); formOk = false; } if (!formOk) { Log.d(TAG, "Form contains errors."); return; } password = SecurityUtils.hashSHA512Base64(password); User newUser = new User(); newUser.setUsername(username); newUser.setPassword(password); newUser.setEmail(email); tempRestClient = new RestClient(Prefs.getHost(), Prefs.getPort(), Prefs.getWsContextPath(), username, password, Prefs.getRealm()); tempRestClient.registerUser(dialog.getContext(), newUser, new GsonHttpResponseHandler<User>(new TypeToken<User>() { }.getType()) { @Override public void onFailure(int statusCode, Header[] headers, String responseBody, Throwable error) { Log.e(TAG, "Registration failed. [statusCode = " + statusCode + ", error=" + error + "]"); if (statusCode == 0) { Toast.makeText(dialog.getOwnerActivity(), R.string.check_connection, Toast.LENGTH_LONG).show(); ; return; } Toast.makeText(dialog.getContext(), R.string.pick_different_username, Toast.LENGTH_LONG).show(); listener.onRegisterFailure(); } @Override public void onFinish() { positiveButton.setEnabled(true); UiUtilities.fadeInFadeOut(formView, progressView); } @Override public void onStart() { positiveButton.setEnabled(false); UiUtilities.fadeInFadeOut(progressView, formView); } @Override public void onSuccess(int statusCode, Header[] headers, User object) { Log.i(TAG, "Registration succeeded. [statusCode = " + statusCode + "]"); dialog.dismiss(); listener.onRegisterSuccess(); } }); } }); final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE); negativeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (tempRestClient != null) { tempRestClient.cancelRequests(dialog.getOwnerActivity(), true); } dialog.dismiss(); } }); } }); return dialog; }
From source file:cc.softwarefactory.lokki.android.fragments.AddContactsFragment.java
private void enableSearchFilter() { inputSearch.addTextChangedListener(new TextWatcher() { @Override//ww w .j a v a 2 s .co m public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { // When user changed the Text if (adapter != null) { adapter.getFilter().filter(cs); } clearFilter.setVisibility(cs.length() == 0 ? View.INVISIBLE : View.VISIBLE); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable arg0) { // TODO Auto-generated method stub } }); clearFilter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { inputSearch.setText(""); } }); }
From source file:com.easemob.chatuidemo.activity.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ????//from w w w . ja v a 2 s . co m if (DemoHXSDKHelper.getInstance().isLogined() && Preferences.getCookie() != null) { autoLogin = true; // LoginActivity.this.usernameEditText; LoginActivity.this.finish(); startActivity(new Intent(LoginActivity.this, MainActivity.class)); return; } setContentView(R.layout.activity_login); usernameEditText = (EditText) findViewById(R.id.username); passwordEditText = (EditText) findViewById(R.id.password); // ???? usernameEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { passwordEditText.setText(null); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); if (MyApplication.getInstance().getUserName() != null) { usernameEditText.setText(MyApplication.getInstance().getUserName()); } }
From source file:com.example.com.benasque2014.mercurio.HorasInfoFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mHoraInicioView.addTextChangedListener(new TextWatcher() { @Override/*from w w w.j a v a 2 s . co m*/ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mPage.getData().putString(HorasInfoPage.HORA_INICIO_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); mHoraFinView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mPage.getData().putString(HorasInfoPage.HORA_FIN_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); mFrecuenciaView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mPage.getData().putString(HorasInfoPage.FRECUENCIA_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); }
From source file:com.example.com.benasque2014.mercurio.RecorridoBasicInfoFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mNameView.addTextChangedListener(new TextWatcher() { @Override//from w ww . j av a2 s.com public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mPage.getData().putString(RecorridoBasicInfoPage.NAME_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); mCodigoView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mPage.getData().putString(RecorridoBasicInfoPage.CODIGO_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); mClassView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mPage.getData().putString(RecorridoBasicInfoPage.CLASE_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); }
From source file:com.romanenco.gitt.BrowserActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_browse); filterBar = findViewById(R.id.filter_bar); findViewById(R.id.filter_close).setOnClickListener(new View.OnClickListener() { @Override//w ww.j a va2 s .c om public void onClick(View v) { showFilterBar(false); } }); filterText = (EditText) findViewById(R.id.filter_text); filterText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { adapter.reFilter(s.toString()); } }); if (savedInstanceState == null) { current = (Repo) getIntent().getSerializableExtra(REPO); path = browseCache.get(current.getFolder()); if (path == null) { path = "."; } } else { current = (Repo) savedInstanceState.getSerializable(REPO); path = savedInstanceState.getString(PATH); filterBar.setVisibility(savedInstanceState.getInt(FILTER)); } updateTitleWithPath(); adapter = new FileListAdapter(this, current, path); getListView().setAdapter(adapter); }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.common.DialogPasswordSettings.java
@Override public void onStart() { super.onStart(); Dialog dialog = getDialog();/*w ww. j a v a2s . c om*/ currentPasswordText = (EditText) dialog.findViewById(R.id.currentPassword); newPasswordText = (EditText) dialog.findViewById(R.id.tempPassword1); confirmPasswordText = (EditText) dialog.findViewById(R.id.tempPassword2); currentPasswordLabel = (TextInputLayout) dialog.findViewById(R.id.currentPasswordLabel); confirmPasswordLabel = (TextInputLayout) dialog.findViewById(R.id.tempPassword2Label); currentPasswordText.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) { currentPasswordLabel.setError(null); } }); confirmPasswordText.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) { confirmPasswordLabel.setError(null); } }); }