| | |
| | | |
| | | import android.content.Intent; |
| | | import android.os.Bundle; |
| | | import android.text.Editable; |
| | | import android.text.InputFilter; |
| | | import android.text.Spanned; |
| | | import android.text.TextUtils; |
| | | import android.text.TextWatcher; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.widget.EditText; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | |
| | |
| | | } |
| | | |
| | | private void initView() { |
| | | newCardBinding.newCardName.setFilters(new InputFilter[]{new ChineseInputFilter()}); |
| | | setPricePoint(newCardBinding.newCardMorny); |
| | | // newCardBinding.newCardName.setFilters(new InputFilter[]{new ChineseInputFilter()}); |
| | | newCardBinding.newCardId.setFilters(new InputFilter[]{new AlphaNumericXFilter(), new InputFilter.LengthFilter(18)}); |
| | | //身份证识别 |
| | | newCardBinding.newCardScanBtn.setOnClickListener(new View.OnClickListener() { |
| | |
| | | if (!TextUtils.isEmpty(userName) |
| | | && !TextUtils.isEmpty(phone) && !TextUtils.isEmpty(userID) |
| | | ) { |
| | | if (userName.length() <= 1 || !validateName(userName)) { |
| | | if (userName.length() <= 1) { |
| | | TipUtil.show(NewCardActivity.this, "请输入正确姓名"); |
| | | } else if (phone.length() < 11 || !isValidPhoneNumber(phone)) { |
| | | TipUtil.show(NewCardActivity.this, "请输入正确手机号"); |
| | |
| | | data.put("peasantIdNumber", peasantIdNumber); |
| | | data.put("current", 1); |
| | | data.put("pageSize", 10); |
| | | ApiManager.getInstance().requestPostLoading(this, "api/sjgg/base/peasant/pagePeasantVo", UserListResult.class, data, new SubscriberListener<BaseResponse<UserListResult>>() { |
| | | ApiManager.getInstance().requestPostLoading(this, "base/peasant/pagePeasantVo", UserListResult.class, data, new SubscriberListener<BaseResponse<UserListResult>>() { |
| | | @Override |
| | | public void onNext(BaseResponse<UserListResult> t) { |
| | | if (t.isSuccess()) { |
| | |
| | | addUser(peasantIdNumber, peasantPhone, peasantName, QHOnLineApplication.getInstance().planId, morny); |
| | | } |
| | | } else { |
| | | startNFCWreatActivity(peasantIdNumber, peasantPhone, peasantName, t.getData().getRecords().get(0).getPeasantId(), morny); |
| | | startNFCWreatActivity(peasantIdNumber, t.getData().getRecords().get(0).getPeasantPhone(), t.getData().getRecords().get(0).getPeasantName(), t.getData().getRecords().get(0).getPeasantId(), morny); |
| | | } |
| | | }else { |
| | | } else { |
| | | ToastUtil.show(t.getMsg()); |
| | | } |
| | | } |
| | |
| | | userCard.setSurplusElecticity(0); |
| | | userCard.setTotalMorny(0); |
| | | userCard.setRechargeDate(Calendar.getInstance()); |
| | | |
| | | userCard.setElectricPrice(Float.valueOf(QHOnLineApplication.getInstance().electriclePriceStr)); |
| | | UserCardBean userCardBean = new UserCardBean(); |
| | | |
| | | userCardBean.setUserName(peasantName); |
| | |
| | | data.put("peasantCode", ""); |
| | | data.put("peasantName", peasantName); |
| | | data.put("peasantPhone", peasantPhone); |
| | | ApiManager.getInstance().requestPostLoading(this, "api/sjgg/base/peasant/savePeasant", AddUserResult.class, data, new SubscriberListener<BaseResponse<AddUserResult>>() { |
| | | ApiManager.getInstance().requestPostLoading(this, "base/peasant/savePeasant", AddUserResult.class, data, new SubscriberListener<BaseResponse<AddUserResult>>() { |
| | | @Override |
| | | public void onNext(BaseResponse<AddUserResult> t) { |
| | | if (t.isSuccess()) { |
| | | startNFCWreatActivity(peasantIdNumber, peasantPhone, peasantName, t.getData().getPeasantId(), morny); |
| | | }else { |
| | | startNFCWreatActivity(peasantIdNumber, t.getData().getPeasantPhone(), t.getData().getPeasantName(), t.getData().getPeasantId(), morny); |
| | | } else { |
| | | ToastUtil.show(t.getMsg()); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | //校验金额 |
| | | public void setPricePoint(final EditText editText) { |
| | | editText.addTextChangedListener(new TextWatcher() { |
| | | @Override |
| | | public void onTextChanged(CharSequence s, int start, int before, |
| | | int count) { |
| | | if (s.toString().contains(".")) { |
| | | if (s.length() - 1 - s.toString().indexOf(".") > 2) { |
| | | s = s.toString().subSequence(0, |
| | | s.toString().indexOf(".") + 3); |
| | | editText.setText(s); |
| | | editText.setSelection(s.length()); |
| | | } |
| | | } |
| | | if (s.toString().trim().substring(0).equals(".")) { |
| | | s = "0" + s; |
| | | editText.setText(s); |
| | | editText.setSelection(2); |
| | | } |
| | | |
| | | if (s.toString().startsWith("0") |
| | | && s.toString().trim().length() > 1) { |
| | | if (!s.toString().substring(1, 2).equals(".")) { |
| | | editText.setText(s.subSequence(0, 1)); |
| | | editText.setSelection(1); |
| | | } |
| | | } |
| | | String morny = editText.getText().toString(); |
| | | if (!TextUtils.isEmpty(morny)) { |
| | | // rechageWater = MornyUtil.intDiv(MornyUtil.changeY2F(editText.getText().toString()), waterPrice); |
| | | // binding.redRechargeWater.setText("充值水量:" + rechageWater + " 立方米(吨)"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void beforeTextChanged(CharSequence s, int start, int count, |
| | | int after) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | // TODO Auto-generated method stub |
| | | |
| | | } |
| | | |
| | | }); |
| | | |
| | | } |
| | | } |