/** @Description: 瓷砖特效 */ private void initMaterialRipple() { alimonyET.setPaddings(DensityUtils.sp2px(this, 32), 0, 0, 0); // 设置验证信息 alimonyET.addValidator( new METValidator("请输入整数~") { @Override public boolean isValid(@NonNull CharSequence text, boolean isEmpty) { String number = text.toString(); if ("".equals(number) || VerifyUtils.isDigit(number)) { return true; } return false; } }); // 动态特效 MaterialRippleLayout.on(commitBtn) .rippleColor(Color.parseColor(CommonConstant.RIPPLE_COLOR_DARK)) .rippleAlpha(CommonConstant.RIPPLE_ALPHA) .rippleHover(true) .create(); }
/** @Description: 瓷砖特效 */ private void initMaterialRipple() { // 设置Spinner的Adapter String[] types = getResources().getStringArray(R.array.second_hand_type); List<String> typeList = Arrays.asList(types); MyArrayAdapter typeAdapter = new MyArrayAdapter(this, typeList); typeSp.setAdapter(typeAdapter); String[] bargains = getResources().getStringArray(R.array.second_hand_bargain); List<String> bargainList = Arrays.asList(bargains); MyArrayAdapter bargainAdapter = new MyArrayAdapter(this, bargainList); bargainSp.setAdapter(bargainAdapter); // 设置Padding titleET.setPaddings(DensityUtils.sp2px(this, 32), 0, 0, 0); typeSp.setPaddings(DensityUtils.sp2px(this, 32), 0, 0, 0); priceET.setPaddings(DensityUtils.sp2px(this, 32), 0, 0, 0); describeET.setPaddings(DensityUtils.sp2px(this, 32), 0, 0, 0); bargainSp.setPaddings(DensityUtils.sp2px(this, 32), 0, 0, 0); qqET.setPaddings(DensityUtils.sp2px(this, 32), 0, 0, 0); phoneET.setPaddings(DensityUtils.sp2px(this, 32), 0, 0, 0); // 设置验证信息 priceET.addValidator( new METValidator("只能输入整数~") { @Override public boolean isValid(@NonNull CharSequence text, boolean isEmpty) { String number = text.toString(); if ("".equals(number) || VerifyUtils.isDigit(number)) { return true; } return false; } }); qqET.addValidator( new METValidator("请输入正确的QQ格式~") { @Override public boolean isValid(@NonNull CharSequence text, boolean isEmpty) { String number = text.toString(); if ("".equals(number) || VerifyUtils.isDigit(number)) { return true; } return false; } }); phoneET.addValidator( new METValidator("请输入正确的联系号码格式~") { @Override public boolean isValid(@NonNull CharSequence text, boolean isEmpty) { String number = text.toString(); if ("".equals(number) || VerifyUtils.checkPhone(number)) { return true; } return false; } }); // 动态特效 MaterialRippleLayout.on(itemTitleRL) .rippleColor(Color.parseColor(CommonConstant.RIPPLE_COLOR_LITHT)) .rippleAlpha(CommonConstant.RIPPLE_ALPHA) .rippleHover(true) .create(); MaterialRippleLayout.on(contactTitleRL) .rippleColor(Color.parseColor(CommonConstant.RIPPLE_COLOR_LITHT)) .rippleAlpha(CommonConstant.RIPPLE_ALPHA) .rippleHover(true) .create(); }
private void initview() { RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radgrup_type); int id = radioGroup.getCheckedRadioButtonId(); if (id == R.id.radio_stuent) { type = 1; } else { type = 0; } final MaterialEditText usernameEdt = (MaterialEditText) findViewById(R.id.edt_username); usernameEdt.addValidator( new METValidator("请输入正确的用户名") { @Override public boolean isValid(@NonNull CharSequence text, boolean isEmpty) { if (RegexUtil.isIDCode(text.toString()) && !isEmpty) { username = text.toString(); return true; } else { return false; } } }); final MaterialEditText pwEdt = (MaterialEditText) findViewById(R.id.edt_password); pwEdt.addValidator( new METValidator("密码要大于六位") { @Override public boolean isValid(@NonNull CharSequence text, boolean isEmpty) { if ((text != null) && (text.length() >= 6)) { password = text.toString(); Log.d("pw", password); return true; } else { return false; } } }); final MaterialEditText nameEdt = (MaterialEditText) findViewById(R.id.edt_name); nameEdt.addValidator( new METValidator("要真实姓名哦") { @Override public boolean isValid(@NonNull CharSequence text, boolean isEmpty) { Pattern pattern = Pattern.compile("^[\u4e00-\u9fa5]+$"); if (pattern.matcher(text).matches()) { name = text.toString(); Log.d("name", name); return true; } else { return false; } } }); final MaterialEditText emailEdt = (MaterialEditText) findViewById(R.id.edt_email); emailEdt.addValidator( new METValidator("邮箱地址不正确") { @Override public boolean isValid(@NonNull CharSequence text, boolean isEmpty) { if (RegexUtil.isEmail(text.toString())) { email = text.toString(); Log.d("email", email); return true; } else { return false; } } }); Button registerBtn = (Button) findViewById(btn_register); registerBtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (usernameEdt.validate() && pwEdt.validate() && nameEdt.validate() && emailEdt.validate()) { User user = new User(); user.setName(name); user.setUsername(username); user.setPassword(password); user.setType(type); user.setEmail(email); UserManager.getInstance(getApplicationContext()).registerUser(user); } else { toast("请核对注册信息"); } } }); }