Search in sources :

Example 76 with TextWatcher

use of android.text.TextWatcher in project WordPress-Android by wordpress-mobile.

the class PeopleInviteFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mUsernamesContainer = (ViewGroup) view.findViewById(R.id.usernames);
    mUsernamesContainer.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            EditTextUtils.showSoftInput(mUsernameEditText);
        }
    });
    Role role = mRole;
    if (role == null) {
        role = getDefaultRole();
    }
    mUsernameEditText = (MultiUsernameEditText) view.findViewById(R.id.invite_usernames);
    //handle key preses from hardware keyboard
    mUsernameEditText.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View view, int i, KeyEvent keyEvent) {
            return keyEvent.getKeyCode() == KeyEvent.KEYCODE_DEL && keyEvent.getAction() == KeyEvent.ACTION_DOWN && removeLastEnteredUsername();
        }
    });
    mUsernameEditText.setOnBackspacePressedListener(new MultiUsernameEditText.OnBackspacePressedListener() {

        @Override
        public boolean onBackspacePressed() {
            return removeLastEnteredUsername();
        }
    });
    mUsernameEditText.addTextChangedListener(new TextWatcher() {

        private boolean shouldIgnoreChanges = false;

        @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 (shouldIgnoreChanges) {
                //used to avoid double call after calling setText from this method
                return;
            }
            shouldIgnoreChanges = true;
            if (mUsernameButtons.size() >= MAX_NUMBER_OF_INVITEES && !TextUtils.isEmpty(s)) {
                resetEditTextContent(mUsernameEditText);
            } else if (endsWithDelimiter(mUsernameEditText.getText().toString())) {
                addUsername(mUsernameEditText, null);
            }
            shouldIgnoreChanges = false;
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    mUsernameEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                addUsername(mUsernameEditText, null);
                return true;
            } else {
                return false;
            }
        }
    });
    mUsernameEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus && mUsernameEditText.getText().toString().length() > 0) {
                addUsername(mUsernameEditText, null);
            }
        }
    });
    if (mUsernameButtons.size() > 0) {
        ArrayList<String> usernames = new ArrayList<>(mUsernameButtons.keySet());
        populateUsernameButtons(usernames);
    }
    mRoleTextView = (TextView) view.findViewById(R.id.role);
    setRole(role);
    ImageView imgRoleInfo = (ImageView) view.findViewById(R.id.imgRoleInfo);
    imgRoleInfo.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ActivityLauncher.openUrlExternal(v.getContext(), URL_USER_ROLES_DOCUMENTATION);
        }
    });
    if (Role.inviteRoles(mSite).length > 1) {
        view.findViewById(R.id.role_container).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                RoleSelectDialogFragment.show(PeopleInviteFragment.this, 0, mSite);
            }
        });
    } else {
        // Don't show drop-down arrow or role selector if there's only one role available
        mRoleTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
    }
    final int MAX_CHARS = getResources().getInteger(R.integer.invite_message_char_limit);
    final TextView remainingCharsTextView = (TextView) view.findViewById(R.id.message_remaining);
    mCustomMessageEditText = (EditText) view.findViewById(R.id.message);
    mCustomMessageEditText.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) {
            mCustomMessage = mCustomMessageEditText.getText().toString();
            updateRemainingCharsView(remainingCharsTextView, mCustomMessage, MAX_CHARS);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    updateRemainingCharsView(remainingCharsTextView, mCustomMessage, MAX_CHARS);
}
Also used : ArrayList(java.util.ArrayList) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Role(org.wordpress.android.models.Role) KeyEvent(android.view.KeyEvent) MultiUsernameEditText(org.wordpress.android.widgets.MultiUsernameEditText) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 77 with TextWatcher

use of android.text.TextWatcher in project Remindy by abicelis.

the class EditRepeatingReminderFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_edit_repeating_reminder, container, false);
    mDate = (EditText) rootView.findViewById(R.id.fragment_edit_repeating_reminder_date);
    mTime = (EditText) rootView.findViewById(R.id.fragment_edit_repeating_reminder_time);
    mRepeatType = (Spinner) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_type);
    mTransitionsContainer = (LinearLayout) rootView.findViewById(R.id.fragment_edit_repeating_reminder_transitions_container);
    mRepeatContainer = (LinearLayout) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_container);
    mRepeatInterval = (EditText) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_interval);
    mRepeatTypeTitle = (TextView) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_type_title);
    mRepeatEndForEventsContainer = (LinearLayout) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_end_for_events_container);
    mRepeatEndUntilContainer = (LinearLayout) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_end_until_container);
    mRepeatEndForXEvents = (EditText) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_for_x_events);
    mRepeatEndType = (Spinner) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_end_type);
    mRepeatUntilDate = (EditText) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_until);
    mRepeatInterval.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) {
            try {
                mReminder.setRepeatInterval(Integer.parseInt(mRepeatInterval.getText().toString()));
            } catch (NumberFormatException e) {
                mReminder.setRepeatInterval(-1);
            }
        }
    });
    mDatePicker = new CalendarDatePickerDialogFragment();
    mRepeatUntilDatePicker = new CalendarDatePickerDialogFragment();
    mTimePicker = new RadialTimePickerDialogFragment();
    setupSpinners();
    setupDateAndTimePickers();
    setReminderValues();
    return rootView;
}
Also used : CalendarDatePickerDialogFragment(com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) RadialTimePickerDialogFragment(com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) Nullable(android.support.annotation.Nullable)

Example 78 with TextWatcher

use of android.text.TextWatcher in project android-app by spark.

the class SmartConfigFragment method setUpTextInputFieldWatchers.

private void setUpTextInputFieldWatchers() {
    for (final Integer viewId : list(R.id.custom_aes_key_text, R.id.wifi_credentials_text)) {
        EditText field = Ui.findView(this, viewId);
        field.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            // NO-OP
            }

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

            @Override
            public void afterTextChanged(Editable s) {
                validateForm(viewId);
            }
        });
    }
}
Also used : EditText(com.danh32.fontify.EditText) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

Example 79 with TextWatcher

use of android.text.TextWatcher in project android_frameworks_base by crdroidandroid.

the class TextView method sendAfterTextChanged.

/**
     * Not private so it can be called from an inner class without going
     * through a thunk.
     */
void sendAfterTextChanged(Editable text) {
    if (mListeners != null) {
        TextWatcher[] list = mListeners;
        int count = mListeners.length;
        for (int i = 0; i < count; i++) {
            list[i].afterTextChanged(text);
        }
    }
    hideErrorIfUnchanged();
}
Also used : TextWatcher(android.text.TextWatcher) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Example 80 with TextWatcher

use of android.text.TextWatcher in project android_frameworks_base by crdroidandroid.

the class TextView method sendOnTextChanged.

/**
     * Not private so it can be called from an inner class without going
     * through a thunk.
     */
void sendOnTextChanged(CharSequence text, int start, int before, int after) {
    if (mListeners != null) {
        TextWatcher[] list = mListeners;
        int count = mListeners.length;
        for (int i = 0; i < count; i++) {
            list[i].onTextChanged(text, start, before, after);
        }
    }
    if (mEditor != null)
        mEditor.sendOnTextChanged(start, after);
}
Also used : TextWatcher(android.text.TextWatcher) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Aggregations

TextWatcher (android.text.TextWatcher)192 Editable (android.text.Editable)158 View (android.view.View)96 TextView (android.widget.TextView)75 Paint (android.graphics.Paint)37 ImageView (android.widget.ImageView)30 TextPaint (android.text.TextPaint)28 EditText (android.widget.EditText)28 Intent (android.content.Intent)25 KeyEvent (android.view.KeyEvent)24 AdapterView (android.widget.AdapterView)21 ListView (android.widget.ListView)17 RecyclerView (android.support.v7.widget.RecyclerView)15 DialogInterface (android.content.DialogInterface)13 SuppressLint (android.annotation.SuppressLint)12 OnClickListener (android.view.View.OnClickListener)12 Button (android.widget.Button)12 InputMethodManager (android.view.inputmethod.InputMethodManager)11 AlertDialog (android.app.AlertDialog)10 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9