上传银行卡防抖处理

This commit is contained in:
lijia 2024-04-22 15:33:55 +08:00
parent 2842812fb0
commit 4e38376f74
3 changed files with 111 additions and 47 deletions

View File

@ -5,6 +5,7 @@ import android.os.Bundle;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
@ -12,6 +13,8 @@ import android.widget.Toast;
import androidx.annotation.Nullable;
import com.arpa.hndahesudintocctmsdriver.weight.OnLimitClickHelper;
import com.arpa.hndahesudintocctmsdriver.weight.OnLimitClickListener;
import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.arpa.hndahesudintocctmsdriver.R;
@ -40,13 +43,13 @@ import java.util.List;
* @date 2021/8/26 19:06
* @description:
*/
public class UpBankActivity extends BaseAppCompatActivity {
public class UpBankActivity extends BaseAppCompatActivity implements OnLimitClickListener {
private ImageView up_bank_img;
private EditText bank_name,bank_number;
private EditText bank_name, bank_number;
private TextView submit;
private ImageView return_btn;
public GetImageAlert gia=new GetImageAlert();
public GetImageAlert gia = new GetImageAlert();
String path;
private OCRBankBean ib;
private WalletRequest qr;
@ -55,35 +58,35 @@ public class UpBankActivity extends BaseAppCompatActivity {
@Override
public void msgMethod(Message m) {
super.msgMethod(m);
switch (m.what){
switch (m.what) {
case RequsetCodeConstants.SUCCESS:
if (CacheGroup.cacheList.get("OCR_BANK")!=null) {
ib=new Gson().fromJson(CacheGroup.cacheList.get("OCR_BANK"),OCRBankBean.class);
if(ib.getCode()==200){
if (CacheGroup.cacheList.get("OCR_BANK") != null) {
ib = new Gson().fromJson(CacheGroup.cacheList.get("OCR_BANK"), OCRBankBean.class);
if (ib.getCode() == 200) {
initView(null);
customDialog.dismiss();
WalletFragment.isInsBank=true;
}else{
Toast.makeText(con,ib.getMsg(),Toast.LENGTH_SHORT).show();
WalletFragment.isInsBank = true;
} else {
Toast.makeText(con, ib.getMsg(), Toast.LENGTH_SHORT).show();
}
CacheGroup.cacheList.remove("OCR_BANK");
}
if(CacheGroup.cacheList.get("insBank")!=null){
BaseBean bb=new Gson().fromJson(CacheGroup.cacheList.get("insBank"),BaseBean.class);
if(bb.getCode()==200){
Toast.makeText(con,"绑定成功",Toast.LENGTH_SHORT).show();
if (CacheGroup.cacheList.get("insBank") != null) {
BaseBean bb = new Gson().fromJson(CacheGroup.cacheList.get("insBank"), BaseBean.class);
if (bb.getCode() == 200) {
Toast.makeText(con, "绑定成功", Toast.LENGTH_SHORT).show();
finish();
}else{
Toast.makeText(con,bb.getMsg(),Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(con, bb.getMsg(), Toast.LENGTH_SHORT).show();
}
CacheGroup.cacheList.remove("insBank");
}
break;
case ImageFileCompressUtil.COMPRESS_SUCCESS:
customDialog=new CustomDialog(con, "上传识别中...");
customDialog = new CustomDialog(con, "上传识别中...");
customDialog.show();
path = (String) m.obj;
new OCRRequest().ORCBank(con,hd,new File(path));
new OCRRequest().ORCBank(con, hd, new File(path));
break;
}
}
@ -95,24 +98,18 @@ public class UpBankActivity extends BaseAppCompatActivity {
super.onCreate(savedInstanceState);
StateStyleUtil.stateTextColor(this);
setContentView(R.layout.activity_bank_auth);
act=this;
con=this;
up_bank_img=findViewById(R.id.up_bank_img);
bank_name=findViewById(R.id.bank_name);
bank_number=findViewById(R.id.bank_number);
submit=findViewById(R.id.submit);
return_btn=findViewById(R.id.return_btn);
qr=new WalletRequest(con,hd);
act = this;
con = this;
up_bank_img = findViewById(R.id.up_bank_img);
bank_name = findViewById(R.id.bank_name);
bank_number = findViewById(R.id.bank_number);
submit = findViewById(R.id.submit);
return_btn = findViewById(R.id.return_btn);
qr = new WalletRequest(con, hd);
up_bank_img.setOnClickListener(v -> {
gia.showPopueWindow(this);
});
submit.setOnClickListener(v -> {
if(ib!=null){
submit();
}else{
Toast.makeText(con,"请先上传图片",Toast.LENGTH_SHORT).show();
}
});
submit.setOnClickListener(new OnLimitClickHelper(this));
return_btn.setOnClickListener(v -> {
finish();
});
@ -129,11 +126,11 @@ public class UpBankActivity extends BaseAppCompatActivity {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 12 && resultCode == RESULT_OK) {
path=gia.getFile().getPath();
Log.e("图片地址:",path);
if (requestCode == 12 && resultCode == RESULT_OK) {
path = gia.getFile().getPath();
Log.e("图片地址:", path);
gia.dis();
ImageFileCompressUtil.imageFileCompress(con,new File(path),hd);
ImageFileCompressUtil.imageFileCompress(con, new File(path), hd);
} else if (requestCode == PictureConfig.CHOOSE_REQUEST && resultCode == RESULT_OK) {
List<LocalMedia> imgs = PictureSelector.obtainMultipleResult(data);
if (imgs != null && imgs.size() > 0) {
@ -143,29 +140,41 @@ public class UpBankActivity extends BaseAppCompatActivity {
if (TextUtils.isEmpty(paths)) {
paths = image.getPath();
}
path=paths;
Log.e("图片地址:",path);
path = paths;
Log.e("图片地址:", path);
gia.dis();
ImageFileCompressUtil.imageFileCompress(con,new File(path),hd);
ImageFileCompressUtil.imageFileCompress(con, new File(path), hd);
}
}
}
public void submit(){
String bankName=bank_name.getText().toString().trim();
String bankNumber=bank_number.getText().toString().trim();
if("".equals(bankName) || "".equals(bankNumber)){
Toast.makeText(con,"请先补充完整的银行卡信息",Toast.LENGTH_LONG).show();
public void submit() {
String bankName = bank_name.getText().toString().trim();
String bankNumber = bank_number.getText().toString().trim();
if ("".equals(bankName) || "".equals(bankNumber)) {
Toast.makeText(con, "请先补充完整的银行卡信息", Toast.LENGTH_LONG).show();
return;
}
InsBankInputBean ibib =new InsBankInputBean();
InsBankInputBean ibib = new InsBankInputBean();
ibib.setCardNo(bankNumber);
ibib.setCardType(Integer.parseInt(ib.getData().getBankCardType()));
ibib.setBankName(bankName);
ibib.setCardUserType(1);
ibib.setImageId(ib.getData().getId());
Log.e("-res-",new Gson().toJson(ibib));
Log.e("-res-", new Gson().toJson(ibib));
qr.insBankCard(ibib);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.submit:
if (ib != null) {
submit();
} else {
Toast.makeText(con, "请先上传图片", Toast.LENGTH_SHORT).show();
}
break;
}
}
}

View File

@ -0,0 +1,38 @@
package com.arpa.hndahesudintocctmsdriver.weight;
import android.view.View;
import android.widget.Toast;
import com.arpa.hndahesudintocctmsdriver.util.alert.ToastUtil;
import com.dahe.mylibrary.utils.ToastUtils;
import java.util.Calendar;
/**
* @ClassName OnLimitClickHelper
* @Author john
* @Date 2024/4/22 14:28
* @Description TODO
*/
public class OnLimitClickHelper implements View.OnClickListener {
public static final int LIMIT_TIME = 1000;
private long lastClickTime = 0;
private OnLimitClickListener onLimitClickListener = null;
public OnLimitClickHelper(OnLimitClickListener onLimitClickListener){
this.onLimitClickListener = onLimitClickListener;
}
@Override
public void onClick(View v) {
long curTime = Calendar.getInstance().getTimeInMillis();
if (curTime - lastClickTime > LIMIT_TIME) {
lastClickTime = curTime;
if(onLimitClickListener != null){
onLimitClickListener.onClick(v);
}
}else{
ToastUtils.showToast(v.getContext(),"点击速度过快,请稍后重试");
}
}
}

View File

@ -0,0 +1,17 @@
package com.arpa.hndahesudintocctmsdriver.weight;
import android.view.View;
/**
* @ClassName OnLimitClickListener
* @Author john
* @Date 2024/4/22 14:28
* @Description TODO
*/
public interface OnLimitClickListener {
/**
* 按钮点击事件
* @param view
*/
void onClick(View view);
}