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