Android PhoneNumberFormattingTextWatcher - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android PhoneNumberFormattingTextWatcher class.

This code example shows how to use the following methods:afterTextChanged, beforeTextChanged
    } 
     
    @SmallTest 
    public void testHyphenDeletion() throws Exception { 
        SpannableStringBuilder number = new SpannableStringBuilder();
        TextWatcher tw = new PhoneNumberFormattingTextWatcher();
        number.append("555-1212");
        // Move the cursor to after the hyphen 
        Selection.setSelection(number, 4);
        // Delete the hyphen 
        tw.beforeTextChanged(number, 3, 1, 0);
        number.delete(3, 4);
        tw.afterTextChanged(number);
        // Make sure that it deleted the character before the hyphen  
        assertEquals("551-212", number.toString());
         
        // Make sure it deals with left edge boundary case 
        number.insert(0, "-");
        Selection.setSelection(number, 1);
        tw.beforeTextChanged(number, 0, 1, 0);

6
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
This code example shows how to use the following methods:
            mTextView = textView;
        } 
 
        @Override 
        protected PhoneNumberFormattingTextWatcher doInBackground(Void... params) {
            return new PhoneNumberFormattingTextWatcher(mCountryCode);
        } 
 
        @Override 
        protected void onPostExecute(PhoneNumberFormattingTextWatcher watcher) {
            if (watcher == null || isCancelled()) {
                return; // May happen if we cancel the task. 
            } 
            // Setting a text changed listener is safe even after the view is detached. 
            mTextView.addTextChangedListener(watcher);
 
            // Note changes the user made before onPostExecute() will not be formatted, but 
            // once they type the next letter we format the entire text, so it's not a big deal. 
            // (And loading PhoneNumberFormattingTextWatcher is usually fast enough.) 
            // We could use watcher.afterTextChanged(mTextView.getEditableText()) to force format 
4
CodeRank
This code example shows how to use the following methods:
            mTextView = textView;
        } 
 
        @Override 
        protected PhoneNumberFormattingTextWatcher doInBackground(Void... params) {
            return new PhoneNumberFormattingTextWatcher(mCountryCode);
        } 
 
        @Override 
        protected void onPostExecute(PhoneNumberFormattingTextWatcher watcher) {
            if (watcher == null || isCancelled()) {
                return; // May happen if we cancel the task. 
            } 
            // Setting a text changed listener is safe even after the view is detached. 
            mTextView.addTextChangedListener(watcher);
 
            // Note changes the user made before onPostExecute() will not be formatted, but 
            // once they type the next letter we format the entire text, so it's not a big deal. 
            // (And loading PhoneNumberFormattingTextWatcher is usually fast enough.) 
            // We could use watcher.afterTextChanged(mTextView.getEditableText()) to force format 
4
CodeRank
This code example shows how to use the following methods:
    	return etext;
    } 
    private void setupEditText() 
    { 
    	EditText etext = this.getEditText();
    	etext.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
    } 
     
    protected void onActivityResult(int requestCode
    	,int resultCode
    	,Intent outputIntent)
    { 
    	super.onActivityResult(requestCode, resultCode, outputIntent);
    	IntentsUtils.parseResult(this, requestCode, resultCode, outputIntent);
    } 
}//eof-class 
4
CodeRank
This code example shows how to use the following methods:
      this.filterPreviewMatch = filterPreviewMatch;
       
      this.filterMatchListeners = new LinkedList<FilterPreviewMatchListener>();
       
      // Format anything in the preview as a phone number in the current locale. 
      filterPreview.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
       
      // When the preview text changes, update. 
      filterPreview.addTextChangedListener(this);     
   } 
 
   public void clearFilterPreviewPattern() { 
      filterPreviewPattern = null;
      toggleFilterPreviewMatchVisibility(false); 
      updateListeners(false);  
   } 
    
   public void addFilterPreviewMatchListener(FilterPreviewMatchListener l) {
      filterMatchListeners.add(l);
   } 
4
CodeRank
This code example shows how to use the following methods:
            mTextView = textView;
        } 
 
        @Override 
        protected PhoneNumberFormattingTextWatcher doInBackground(Void... params) {
            return new PhoneNumberFormattingTextWatcher(mCountryCode);
        } 
 
        @Override 
        protected void onPostExecute(PhoneNumberFormattingTextWatcher watcher) {
            if (watcher == null || isCancelled()) {
                return; // May happen if we cancel the task. 
            } 
            // Setting a text changed listener is safe even after the view is detached. 
            mTextView.addTextChangedListener(watcher);
 
            // Note changes the user made before onPostExecute() will not be formatted, but 
            // once they type the next letter we format the entire text, so it's not a big deal. 
            // (And loading PhoneNumberFormattingTextWatcher is usually fast enough.) 
            // We could use watcher.afterTextChanged(mTextView.getEditableText()) to force format 
4
CodeRank
This code example shows how to use the following methods:
    	return etext;
    } 
    private void setupEditText() 
    { 
    	EditText etext = this.getEditText();
    	etext.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
    } 
     
    protected void onActivityResult(int requestCode
    	,int resultCode
    	,Intent outputIntent)
    { 
    	super.onActivityResult(requestCode, resultCode, outputIntent);
    	IntentsUtils.parseResult(this, requestCode, resultCode, outputIntent);
    } 
}//eof-class 
4
CodeRank
See Code Examples for Android PhoneNumberFormattingTextWatcher Methods: