| | |
| | | |
| | | import com.dayu.recharge.utils.DeviceNumberUtils; |
| | | import com.dayu.recharge.view.ProgressDialog; |
| | | import com.msd.ocr.idcard.LibraryInitOCR; |
| | | |
| | | import com.dayu.recharge.MyApplication; |
| | | import com.dayu.recharge.card.UserCard; |
| | | import com.dayu.recharge.databinding.ActivityNewCardBinding; |
| | |
| | | } |
| | | }); |
| | | |
| | | newCardBinding.newCardRegistBtn.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | newCardBinding.newCardRegistBtn.setOnClickListener(v -> { |
| | | |
| | | String userName = newCardBinding.newCardName.getText().toString(); |
| | | long date = System.currentTimeMillis(); |
| | | String phone = newCardBinding.newCardPhone.getText().toString(); |
| | | String userID = newCardBinding.newCardId.getText().toString().toUpperCase(); |
| | | String userName = newCardBinding.newCardName.getText().toString(); |
| | | long date = System.currentTimeMillis(); |
| | | String phone = newCardBinding.newCardPhone.getText().toString(); |
| | | String userID = newCardBinding.newCardId.getText().toString().toUpperCase(); |
| | | |
| | | |
| | | if (!TextUtils.isEmpty(userName) |
| | | && !TextUtils.isEmpty(phone) && !TextUtils.isEmpty(userID) |
| | | ) { |
| | | if (userName.length() <= 1 || !validateName(userName)) { |
| | | TipUtil.show(NewCardActivity.this, "请输入正确姓名"); |
| | | return; |
| | | } else if (phone.length() < 11 || !isValidPhoneNumber(phone)) { |
| | | TipUtil.show(NewCardActivity.this, "请输入正确手机号"); |
| | | return; |
| | | } else if (!Utils.check(userID)) { |
| | | TipUtil.show(NewCardActivity.this, "请输入正确身份证号"); |
| | | return; |
| | | } else { |
| | | userCardBean = new UserCardBean(); |
| | | userCardBean.setUserName(userName); |
| | | userCardBean.setDate(date); |
| | | userCardBean.setSerial(adminData.getSerial()); |
| | | userCardBean.setPhone(phone); |
| | | userCardBean.setUserID(userID); |
| | | initCard(); |
| | | } |
| | | |
| | | if (!TextUtils.isEmpty(userName) |
| | | && !TextUtils.isEmpty(phone) && !TextUtils.isEmpty(userID) |
| | | ) { |
| | | if (userName.length() <= 1 || !validateName(userName)) { |
| | | TipUtil.show(NewCardActivity.this, "请输入正确姓名"); |
| | | return; |
| | | } else if (phone.length() < 11 || !isValidPhoneNumber(phone)) { |
| | | TipUtil.show(NewCardActivity.this, "请输入正确手机号"); |
| | | return; |
| | | } else if (!Utils.check(userID)) { |
| | | TipUtil.show(NewCardActivity.this, "请输入正确身份证号"); |
| | | return; |
| | | } else { |
| | | TipUtil.show(NewCardActivity.this, "请输入完整内容"); |
| | | userCardBean = new UserCardBean(); |
| | | userCardBean.setUserName(userName); |
| | | userCardBean.setDate(date); |
| | | userCardBean.setSerial(adminData.getSerial()); |
| | | userCardBean.setPhone(phone); |
| | | userCardBean.setUserID(userID); |
| | | initCard(); |
| | | } |
| | | |
| | | } else { |
| | | TipUtil.show(NewCardActivity.this, "请输入完整内容"); |
| | | } |
| | | }); |
| | | } |
| | |
| | | }) |
| | | .request((allGranted, grantedList, deniedList) -> { |
| | | if (allGranted) {//所有申请的权限都已通过 |
| | | startCamera(); |
| | | // startCamera(); |
| | | } else {//您拒绝了如下权限:$deniedList |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | private void startCamera() { |
| | | |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putBoolean("saveImage", false); |
| | | bundle.putInt("requestCode", SCAN_IDCARD_REQUEST); |
| | | bundle.putInt("type", 0); //0身份证, 1驾驶证 |
| | | LibraryInitOCR.startScan(NewCardActivity.this, bundle); |
| | | } |
| | | |
| | | @Override |
| | | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |