Java Code Examples for android.widget.EditText#getTag()

The following examples show how to use android.widget.EditText#getTag() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValidationEngine.java    From argus-android with Apache License 2.0 6 votes vote down vote up
public static boolean validateEditText(final EditText editText, final ValidationEngine validationEngine) {
    if(editText.getTag() == null) {
        ArgusLogger.w(TAG, "Not performing validations for this EditText");
    }

    boolean allWell = true;

    // get validations for tag
    List<Validation> validations = validationEngine.getValidationsByKey(editText.getTag().toString());
    if(validations != null && !validations.isEmpty()) {
        String errors = ValidationEngine.validate(editText.getText().toString(), validations);
        if(!TextUtils.isEmpty(errors)) {
            editText.setError(errors);
            allWell = false;
        }
    }

    return allWell;
}
 
Example 2
Source File: ListItemExtensions.java    From Android-WYSIWYG-Editor with Apache License 2.0 6 votes vote down vote up
@Override
public Node getContent(View view) {
    Node node = getNodeInstance(view);
    node.childs = new ArrayList<>();
    TableLayout table = (TableLayout) view;
    int _rowCount = table.getChildCount();
    for (int j = 0; j < _rowCount; j++) {
        View row = table.getChildAt(j);
        Node node1 = getNodeInstance(row);
        EditText li = row.findViewById(R.id.txtText);
        EditorControl liTag = (EditorControl) li.getTag();
        node1.contentStyles = liTag.editorTextStyles;
        node1.content.add(Html.toHtml(li.getText()));
        node1.textSettings = liTag.textSettings;
        node1.content.add(Html.toHtml(li.getText()));
        node.childs.add(node1);
    }
    return node;
}
 
Example 3
Source File: ProjectAdapter.java    From microbit with Apache License 2.0 5 votes vote down vote up
/**
 * Allows to hide keyboard and rename a project file by given view
 * from the list of projects.
 *
 * @param v    View that represents a project from the list.
 * @param hide If true - hides the keyboard.
 * @param done If true - renames given project file.
 */
private void dismissKeyBoard(View v, boolean hide, boolean done) {
    logi("dismissKeyBoard() :: ");

    int pos = (Integer) v.getTag(R.id.positionId);

    logi("dismissKeyBoard() :: pos = " + pos + " currentEditableRow=" + currentEditableRow);

    InputMethodManager imm = (InputMethodManager) mProjectActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);

    if(hide) {
        hideEditTextView(v);
    }

    if(done) {
        EditText ed = (EditText) v;
        pos = (int) ed.getTag(R.id.positionId);
        String newName = ed.getText().toString();
        Project p = mProjects.get(pos);
        if(newName.length() > 0) {
            if(p.name.compareToIgnoreCase(newName) != 0) {
                mProjectActivity.renameFile(p.filePath, newName);
            }
        }
    }
}
 
Example 4
Source File: CustomKeyboard.java    From Bluefruit_LE_Connect_Android with MIT License 5 votes vote down vote up
public void showCustomKeyboard(View view) {
    EditText editText = (EditText) view;
    final int keyboardId = (Integer) editText.getTag();
    if (mCurrentKeyboardId != keyboardId) {
        Keyboard keyboard = new Keyboard(mActivity, keyboardId);
        mKeyboardView.setKeyboard(keyboard);
        mCurrentKeyboardId = keyboardId;
    }
    mKeyboardView.setVisibility(View.VISIBLE);
    mKeyboardView.setEnabled(true);
    ((InputMethodManager) mActivity.getSystemService(Activity.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(view.getWindowToken(), 0);
}
 
Example 5
Source File: MyDialog.java    From ExpandableRecyclerView with Apache License 2.0 4 votes vote down vote up
private ArrayList<String> checkInput(View table) {
    if (!(table instanceof TableLayout)) return null;
    ArrayList<String> result = new ArrayList<>();
    TableLayout tableLayout = (TableLayout) table;
    final int childCount = tableLayout.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View tableChild = tableLayout.getChildAt(i);
        if (tableChild instanceof TableRow) {
            TableRow tableRow = (TableRow) tableChild;
            final int count = tableRow.getChildCount();
            for (int j = 0; j < count; j++) {
                View childView = tableRow.getChildAt(j);
                if (!(childView instanceof EditText)) continue;
                EditText editText = (EditText) childView;
                String type = editText.getHint().toString();
                String method = (String) editText.getTag();
                String input = editText.getText().toString().trim();
                if (TextUtils.isEmpty(input)) continue;
                String[] methods = input.split("\n");
                for (String m : methods) {
                    String methodType = "";
                    String[] args = m.split(",");
                    if (type.equals(PARENT_TYPE)) {
                        if (args.length == 1) {
                            methodType = ITEM_OPERATE_TYPE;
                        } else if (args.length == 2) {
                            methodType = ITEM_RANGE_OPERATE_TYPE;
                        }
                    } else if (type.equals(CHILD_TYPE)) {
                        if (args.length == 2) {
                            methodType = ITEM_OPERATE_TYPE;
                        } else if (args.length == 3) {
                            methodType = ITEM_RANGE_OPERATE_TYPE;
                        }
                    } else if (type.equals(MOVE_PARENT_TYPE)) {
                        if (args.length == 2) {
                            methodType = ITEM_OPERATE_TYPE;
                        }
                    } else if (type.equals(MOVE_CHILD_TYPE)) {
                        if (args.length == 4) {
                            methodType = ITEM_OPERATE_TYPE;
                        }
                    }
                    String methodName = String.format(method, methodType);
                    String ma = String.format(getString(R.string.methodAndArgs), methodName, m);
                    result.add(ma);
                }
            }
        }
    }
    Logger.e(TAG, "requestList=" + result.toString());
    return result;
}
 
Example 6
Source File: AuthFragment.java    From userapp-android with MIT License 4 votes vote down vote up
/** Method to signup from a layout */
public void onSignup(View view) {
	if (this.signupViews == null) {
		onSignupCompleted(null, false, new Exception("The signup form doesn't contains any views."));
	} else {
		// Create a new user object
		User newUser = new User();			
					
		for (EditText field : this.signupViews) {
			String tag = (String)field.getTag();
			
			// Fill the user object
			if (tag.equals("login")) {
				newUser.login = field.getText().toString();
			} else if (tag.equals("email")) {
				newUser.email = field.getText().toString();
			} else if (tag.equals("first_name")) {
				newUser.first_name = field.getText().toString();
			} else if (tag.equals("last_name")) {
				newUser.last_name = field.getText().toString();
			} else if (tag.equals("password")) {
				newUser.password = field.getText().toString();
				this.password = newUser.password;
				
				// Clear the field
				field.setText("");
			}
		}
		
		newUser = onSignupStart(newUser);
		
		if (newUser != null) {
			// Save the new user
			session.saveUser(newUser, new UserApp.Session.UserCallback() {
			    @Override
			    public void call(User user, Exception exception) {
			    	user.password = password;
			    	password = "";
			    	onSignupCompleted(user, (user.locks.size() == 0), exception);
			    }
			});
		}
	}
}