Example usage for android.text TextWatcher TextWatcher

List of usage examples for android.text TextWatcher TextWatcher

Introduction

In this page you can find the example usage for android.text TextWatcher TextWatcher.

Prototype

TextWatcher

Source Link

Usage

From source file:com.hardcopy.retroband.fragments.LLSettingsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    AppSettings.initializeAppSettings(mContext);

    View rootView = inflater.inflate(R.layout.fragment_settings, container, false);

    // 'Run in background' setting
    mCheckBackground = (CheckBox) rootView.findViewById(R.id.check_background_service);
    mCheckBackground.setChecked(AppSettings.getBgService());
    mCheckBackground.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override/* w w  w.  j a va 2s .c  o m*/
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            AppSettings.setSettingsValue(AppSettings.SETTINGS_BACKGROUND_SERVICE, isChecked, 0, null);
            mFragmentListener.OnFragmentCallback(IFragmentListener.CALLBACK_RUN_IN_BACKGROUND, 0, 0, null, null,
                    null);
        }
    });

    // User's weight input form
    mEditWeight = (EditText) rootView.findViewById(R.id.edit_weight);
    mEditWeight.setText(Integer.toString(AppSettings.getWeight()));
    mEditWeight.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s != null && s.length() > 0) {
                int weight = Integer.parseInt(s.toString());
                if (weight > 0 && weight < 1000) {
                    AppSettings.setSettingsValue(AppSettings.SETTINGS_WEIGHT, true, weight, null);
                    Analyzer.setWeight(AppSettings.getWeight());
                }
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    return rootView;
}

From source file:com.hardcopy.vcontroller.fragments.ControllerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRootView = inflater.inflate(R.layout.fragment_controller, container, false);

    mEditTopic = (EditText) mRootView.findViewById(R.id.topic);
    mEditTopic.addTextChangedListener(new TextWatcher() {
        @Override//from   ww w  .  j av a 2 s .  com
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (mTopicWarningEnabled) {
                showTopicWarning(false);
                mEditTopic.setHint(mContext.getString(R.string.setTargetTopic));
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    mImageTopicWarning = (ImageView) mRootView.findViewById(R.id.topicWarningImage);
    showTopicWarning(false);
    mEditMessage = (EditText) mRootView.findViewById(R.id.message);
    mRadioQos = (RadioGroup) mRootView.findViewById(R.id.qosRadio);
    mCheckRetained = (CheckBox) mRootView.findViewById(R.id.retained);

    mVoiceImageView = (ImageView) mRootView.findViewById(R.id.voiceImageView);
    mVoiceImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // request voice recognition to activity
            mFragmentListener.OnFragmentCallback(IFragmentListener.CALLBACK_REQUEST_START_VOICE, 0, 0, null,
                    null, null);
        }
    });
    mTextStatus = (TextView) mRootView.findViewById(R.id.statusText);

    // TODO:

    ControllerContainer cc = new ControllerContainer(mContext, mFragmentListener);
    cc.initControlViews(mRootView);

    addAutoCompleteAdapter();
    initUserInput();

    return mRootView;
}

From source file:com.ihelp101.instagram.NewItemFragment.java

@NonNull
@Override//from   ww  w .  ja va 2 s  .co m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(R.layout.nnf_dialog_folder_name).setTitle(R.string.nnf_new_folder)
            .setNegativeButton(android.R.string.cancel, null).setPositiveButton(android.R.string.ok, null);

    final AlertDialog dialog = builder.create();

    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog1) {
            final AlertDialog dialog = (AlertDialog) dialog1;
            final EditText editText = (EditText) dialog.findViewById(R.id.edit_text);

            Button cancel = dialog.getButton(AlertDialog.BUTTON_NEGATIVE);
            cancel.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    dialog.cancel();
                }
            });

            final Button ok = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
            // Start disabled
            ok.setEnabled(false);
            ok.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    String itemName = editText.getText().toString();
                    if (validateName(itemName)) {
                        if (listener != null) {
                            listener.onNewFolder(itemName);
                        }
                        dialog.dismiss();
                    }
                }
            });

            editText.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(final CharSequence s, final int start, final int count,
                        final int after) {
                }

                @Override
                public void onTextChanged(final CharSequence s, final int start, final int before,
                        final int count) {
                }

                @Override
                public void afterTextChanged(final Editable s) {
                    ok.setEnabled(validateName(s.toString()));
                }
            });
        }
    });

    return dialog;
}

From source file:com.iutiao.sdk.views.PasswordEditText.java

public void initFields(AttributeSet attrs, int defStyleAttr) {
    if (attrs != null) {
        // ??//  ww w .  j  ava  2 s  . c o  m
        TypedArray styles = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.PasswordEditText,
                defStyleAttr, 0);
        try {
            // ??, Icon
            mShowPwdIcon = styles.getResourceId(R.styleable.PasswordEditText_pet_iconShow, mShowPwdIcon);
            mHidePwdIcon = styles.getResourceId(R.styleable.PasswordEditText_pet_iconHide, mHidePwdIcon);
        } finally {
            styles.recycle();
        }
    }

    // ??
    setInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);

    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) {
            if (s.length() > 0) {
                // 
                showPasswordVisibilityIndicator(true);
            } else {
                mIsShowPwdIcon = false;
                restorePasswordIconVisibility(mIsShowPwdIcon);
                showPasswordVisibilityIndicator(false); // ??
            }
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });
}

From source file:ch.dissem.apps.abit.SubscriptionDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_subscription_detail, container, false);

    // Show the dummy content as text in a TextView.
    if (item != null) {
        ((ImageView) rootView.findViewById(R.id.avatar)).setImageDrawable(new Identicon(item));
        TextView name = (TextView) rootView.findViewById(R.id.name);
        name.setText(item.toString());//ww  w. j  a  v  a2  s  .c o  m
        name.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                // Nothing to do
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // Nothing to do
            }

            @Override
            public void afterTextChanged(Editable s) {
                item.setAlias(s.toString());
            }
        });
        TextView address = (TextView) rootView.findViewById(R.id.address);
        address.setText(item.getAddress());
        address.setSelected(true);
        ((TextView) rootView.findViewById(R.id.stream_number))
                .setText(getActivity().getString(R.string.stream_number, item.getStream()));
        Switch active = (Switch) rootView.findViewById(R.id.active);
        active.setChecked(item.isSubscribed());
        active.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                item.setSubscribed(isChecked);
            }
        });
    }

    return rootView;
}

From source file:cn.tycoon.lighttrans.fileManager.NewItemFragment.java

@NonNull
@Override/*from  w  w w .j a v  a  2 s .c o m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(R.layout.dialog_folder_name).setTitle(R.string.new_folder)
            .setNegativeButton(android.R.string.cancel, null).setPositiveButton(android.R.string.ok, null);

    final AlertDialog dialog = builder.create();

    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog1) {
            final AlertDialog dialog = (AlertDialog) dialog1;
            final EditText editText = (EditText) dialog.findViewById(R.id.edit_text);

            Button cancel = dialog.getButton(AlertDialog.BUTTON_NEGATIVE);
            cancel.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    dialog.cancel();
                }
            });

            final Button ok = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
            // Start disabled
            ok.setEnabled(false);
            ok.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    String itemName = editText.getText().toString();
                    if (validateName(itemName)) {
                        if (listener != null) {
                            listener.onNewFolder(itemName);
                        }
                        dialog.dismiss();
                    }
                }
            });

            editText.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(final CharSequence s, final int start, final int count,
                        final int after) {
                }

                @Override
                public void onTextChanged(final CharSequence s, final int start, final int before,
                        final int count) {
                }

                @Override
                public void afterTextChanged(final Editable s) {
                    ok.setEnabled(validateName(s.toString()));
                }
            });
        }
    });

    return dialog;
}

From source file:com.oasis.sdk.activity.OasisSdkPayEpinActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(BaseUtils.getResourceValue("layout", "oasisgames_sdk_pay_epin"));

    initHead(true, null, true,//from w  ww  .  j  a  va 2 s. com
            getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pcenter_notice_12")));

    et_code = (EditText) findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_epin_edittext"));
    et_code.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) {
            if (s.length() > 0)
                ll_clean.setVisibility(View.VISIBLE);
            else
                ll_clean.setVisibility(View.GONE);
        }
    });
    ll_clean = (LinearLayout) findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_epin_clean"));
    ll_clean.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            onClickToClean(v);
        }
    });

    ll_images = (LinearLayout) findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_epin_img"));
    mHandler = new MyHandler(this);
    mHandler.sendEmptyMessageDelayed(100, 2000);

}

From source file:com.jaymullen.TrailJournal.wizard.ui.TitleFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mTitleView.addTextChangedListener(new TextWatcher() {
        @Override//  ww  w . j  av  a 2 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(TitlePage.TITLE_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
        }
    });
}

From source file:com.bt.heliniumstudentapp.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    loginContext = this;

    getWindow().getDecorView().setBackgroundResource(R.color.indigo);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().setStatusBarColor(Color.TRANSPARENT);
        getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.indigo));
        setTaskDescription(new ActivityManager.TaskDescription(getString(R.string.app_name),
                BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher),
                ContextCompat.getColor(this, R.color.indigo)));
    }/*from w  w  w  . j a  va 2s  .  c  o m*/

    usernameET = (EditText) findViewById(R.id.et_username_la);
    passwordET = (EditText) findViewById(R.id.et_password_la);
    final Button loginBtn = (Button) findViewById(R.id.btn_login_la);

    usernameET.setText(PreferenceManager.getDefaultSharedPreferences(this).getString("username", ""));

    usernameET.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            loginBtn.setEnabled((usernameET.length() != 0 && passwordET.length() != 0));
        }

        public void afterTextChanged(Editable s) {
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }
    });

    passwordET.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            loginBtn.setEnabled((usernameET.length() != 0 && passwordET.length() != 0));
        }

        public void afterTextChanged(Editable s) {
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }
    });

    View.OnClickListener login = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            refresh();
        }
    };

    loginBtn.setOnClickListener(login);
}

From source file:com.acceleratedio.pac_n_zoom.SaveAnmActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_save_anm);
    EventBus.getDefault().register(this);
    crt_ctx = this;
    tagText = (EditText) findViewById(R.id.sav_tags);

    tagText.addTextChangedListener(new TextWatcher() {

        @Override//from  www. j a  v  a 2 s . c  o m
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void onTextChanged(CharSequence key_sqnc, int start, int before, int count) {

            final StringBuilder strBldr = new StringBuilder(key_sqnc.length());
            strBldr.append(key_sqnc);
            srch_str = strBldr.toString();
            dsply_tags();
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    tagText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

            boolean handled = false;
            tags_str = tagText.getText().toString();

            if (actionId == EditorInfo.IME_ACTION_SEND) {

                progress = ProgressDialog.show(crt_ctx, "Saving the animation", "dialog message", true);
                MakePostRequest savAnimation = new MakePostRequest();
                savAnimation.execute();
                handled = true;
            }

            return handled;
        }
    });

    fil_tags = PickAnmActivity.orgnl_tags.split("(\\s*,\\s*)|(\\s* \\s*)");
    Arrays.sort(fil_tags, String.CASE_INSENSITIVE_ORDER);
    dsply_tags();
}