package com.huntersun.vkyes.etcopencard.project.api.bean; | package com.huntersun.vkyes.etcopencard.project.api.bean; | ||||
import android.util.Log; | |||||
import java.util.ArrayList; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.List; | |||||
import java.util.Map; | import java.util.Map; | ||||
/** | /** |
/** | /** | ||||
* Date :2023-03-25 | * Date :2023-03-25 | ||||
* Description:证件类型dialog | |||||
* Description:证件类型、车辆用户类型 dialog | |||||
*/ | */ | ||||
public class IDTypeDialog { | public class IDTypeDialog { | ||||
import com.huntersun.vkyes.etcopencard.project.api.bean.ResultBean; | import com.huntersun.vkyes.etcopencard.project.api.bean.ResultBean; | ||||
import com.huntersun.vkyes.etcopencard.project.api.bean.SendTheVerificationCodeBean; | import com.huntersun.vkyes.etcopencard.project.api.bean.SendTheVerificationCodeBean; | ||||
import com.huntersun.vkyes.etcopencard.project.ui.adapter.DataTypeAdaptor; | import com.huntersun.vkyes.etcopencard.project.ui.adapter.DataTypeAdaptor; | ||||
import com.huntersun.vkyes.etcopencard.project.utils.FileUtils; | |||||
import com.huntersun.vkyes.etcopencard.src.ui.activity.ImageSelectActivity; | import com.huntersun.vkyes.etcopencard.src.ui.activity.ImageSelectActivity; | ||||
import java.io.File; | import java.io.File; | ||||
import java.util.HashMap; | |||||
import java.util.Map; | import java.util.Map; | ||||
import top.zibin.luban.Luban; | import top.zibin.luban.Luban; |
import com.huntersun.vkyes.etcopencard.project.tool.QRCode; | import com.huntersun.vkyes.etcopencard.project.tool.QRCode; | ||||
import com.huntersun.vkyes.etcopencard.project.tool.ReaderUtils; | import com.huntersun.vkyes.etcopencard.project.tool.ReaderUtils; | ||||
import com.huntersun.vkyes.etcopencard.project.tool.Utils; | import com.huntersun.vkyes.etcopencard.project.tool.Utils; | ||||
import com.huntersun.vkyes.etcopencard.project.utils.FileUtils; | |||||
import com.huntersun.vkyes.etcopencard.project.utils.FunHelper; | |||||
import com.huntersun.vkyes.etcopencard.src.aop.Permissions; | import com.huntersun.vkyes.etcopencard.src.aop.Permissions; | ||||
import com.huntersun.vkyes.etcopencard.src.aop.SingleClick; | import com.huntersun.vkyes.etcopencard.src.aop.SingleClick; | ||||
import com.huntersun.vkyes.etcopencard.src.app.AppActivity; | import com.huntersun.vkyes.etcopencard.src.app.AppActivity; | ||||
import java.net.URI; | import java.net.URI; | ||||
import java.net.URISyntaxException; | import java.net.URISyntaxException; | ||||
import java.time.format.DateTimeFormatter; | import java.time.format.DateTimeFormatter; | ||||
import java.util.HashMap; | |||||
import retrofit2.Response; | import retrofit2.Response; | ||||
import top.zibin.luban.Luban; | import top.zibin.luban.Luban; | ||||
@SuppressLint({"NewApi", "LogNotTimber"}) | @SuppressLint({"NewApi", "LogNotTimber"}) | ||||
@SingleClick | @SingleClick | ||||
public void onImage(View view) { | public void onImage(View view) { | ||||
ImageSelectActivity.start(this, data -> { | |||||
if (view == binding.image5){//委托书 | |||||
FileUtils.getInstance(this).uploadGeneralImage(true, null, new FileUtils.OnUploadCallback() { | |||||
@Override | |||||
public void onSuccess(ResultBean.ProductInfo bizContent) { | |||||
String url = bizContent.data.getUrl(); | |||||
if (!FunHelper.isEmpty(url)){ | |||||
GlideApp.with(getActivity()).load(url).into((ImageView) view); | |||||
imgUrl5 = url; | |||||
} | |||||
} | |||||
}); | |||||
}else{//身份证件照 | |||||
String str = ""; | |||||
if (view == binding.image1 || view == binding.image3) { | |||||
str = "1"; | |||||
} else if (view == binding.image2 || view == binding.image4) { | |||||
str = "2"; | |||||
} | |||||
HashMap<String,String> params = new HashMap<>(); | |||||
params.put("source","1"); | |||||
params.put("agencyId","52010106004"); | |||||
params.put("fileName",System.currentTimeMillis() + ".png"); | |||||
params.put("imageType",str);//1正,2反 | |||||
String finalStr = str; | |||||
FileUtils.getInstance(this).uploadOcrIDCard(true, params, new FileUtils.OnOcrUploadCallback() { | |||||
@Override | |||||
public void onSuccess(ResultBean.BizContent bizContent) { | |||||
if("1".equals(finalStr)){ | |||||
identifyIdCard = bizContent.getIdno(); | |||||
} | |||||
hideDialog(); | |||||
if (view == binding.image1) { | |||||
setText(binding.text1, bizContent.getName()); | |||||
setText(binding.text3, bizContent.getIdno()); | |||||
setText(binding.text4, bizContent.getAddress()); | |||||
if (!TextUtils.isEmpty(bizContent.getImageUrl())) { | |||||
imgUrl1 = bizContent.getImageUrl(); | |||||
GlideApp.with(getActivity()).load(bizContent.getImageUrl()).into(binding.image1); | |||||
} | |||||
} else if (view == binding.image3) { | |||||
setText(binding.text6, bizContent.getName()); | |||||
setText(binding.text7, bizContent.getIdno()); | |||||
if (!TextUtils.isEmpty(bizContent.getImageUrl())) { | |||||
imgUrl3 = bizContent.getImageUrl(); | |||||
GlideApp.with(getActivity()).load(bizContent.getImageUrl()).into(binding.image3); | |||||
} | |||||
} else if (view == binding.image2) { | |||||
//过期时间 | |||||
if (bizContent.getEnddate().length() == 8) { | |||||
setText(binding.text5, bizContent.getEnddate().substring(0, 4) + "-" + bizContent.getEnddate().substring(4, 6) | |||||
+ "-" + bizContent.getEnddate().substring(6, 8)); | |||||
} | |||||
if (!TextUtils.isEmpty(bizContent.getImageUrl())) { | |||||
imgUrl2 = bizContent.getImageUrl(); | |||||
GlideApp.with(getActivity()).load(bizContent.getImageUrl()).into(binding.image2); | |||||
} | |||||
} else if (view == binding.image4) { | |||||
//过期时间 | |||||
if (bizContent.getEnddate().length() == 8) { | |||||
setText(binding.text8, bizContent.getEnddate().substring(0, 4) + "-" + bizContent.getEnddate().substring(4, 6) | |||||
+ "-" + bizContent.getEnddate().substring(6, 8)); | |||||
} | |||||
if (!TextUtils.isEmpty(bizContent.getImageUrl())) { | |||||
imgUrl4 = bizContent.getImageUrl(); | |||||
GlideApp.with(getActivity()).load(bizContent.getImageUrl()).into(binding.image4); | |||||
} | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
//旧版本 | |||||
/*ImageSelectActivity.start(this, data -> { | |||||
file = new File(data.get(0)); | file = new File(data.get(0)); | ||||
if (view != binding.image5) { | if (view != binding.image5) { | ||||
//cropImageFile(new File(data.get(0)), (ImageView) view); //裁剪功能 | //cropImageFile(new File(data.get(0)), (ImageView) view); //裁剪功能 | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
}); | |||||
});*/ | |||||
} | } | ||||
@Override | @Override | ||||
* 裁剪图片 | * 裁剪图片 | ||||
*/ | */ | ||||
private void cropImageFile(File sourceFile, ImageView imageView) { | private void cropImageFile(File sourceFile, ImageView imageView) { | ||||
ImageCropActivity.start(this, sourceFile, 158, 100, new ImageCropActivity.OnCropListener() { | |||||
/* ImageCropActivity.start(this, sourceFile, 158, 100, new ImageCropActivity.OnCropListener() { | |||||
@SuppressLint({"LogNotTimber", "NewApi"}) | @SuppressLint({"LogNotTimber", "NewApi"}) | ||||
@Override | @Override | ||||
public void onSucceed(Uri fileUri, String fileName) { | public void onSucceed(Uri fileUri, String fileName) { | ||||
// 没有的话就不裁剪,直接上传原图片 | // 没有的话就不裁剪,直接上传原图片 | ||||
// 但是这种情况极其少见,可以忽略不计 | // 但是这种情况极其少见,可以忽略不计 | ||||
} | } | ||||
}); | |||||
});*/ | |||||
} | } | ||||
//旧版本 | |||||
@SuppressLint({"LogNotTimber", "NewApi"}) | @SuppressLint({"LogNotTimber", "NewApi"}) | ||||
public void OCRspot(String base64, ImageView imageView, String mAvatarUrl, File outputFile) { | public void OCRspot(String base64, ImageView imageView, String mAvatarUrl, File outputFile) { | ||||
String str = ""; | |||||
/* String str = ""; | |||||
if (imageView == binding.image1 || imageView == binding.image3) { | if (imageView == binding.image1 || imageView == binding.image3) { | ||||
str = "1"; | str = "1"; | ||||
} else if (imageView == binding.image2 || imageView == binding.image4) { | } else if (imageView == binding.image2 || imageView == binding.image4) { | ||||
}, 500); | }, 500); | ||||
} | } | ||||
} | } | ||||
}); | |||||
});*/ | |||||
} | } | ||||
public void setText(TextView text, String str) { | public void setText(TextView text, String str) { |
import android.annotation.SuppressLint; | import android.annotation.SuppressLint; | ||||
import android.content.Intent; | import android.content.Intent; | ||||
import android.net.Uri; | |||||
import android.os.Build; | |||||
import android.os.Bundle; | |||||
import android.text.TextUtils; | import android.text.TextUtils; | ||||
import android.util.Log; | import android.util.Log; | ||||
import android.view.Gravity; | import android.view.Gravity; | ||||
import android.widget.ImageView; | import android.widget.ImageView; | ||||
import android.widget.TextView; | import android.widget.TextView; | ||||
import com.alibaba.fastjson.JSON; | |||||
import com.blankj.utilcode.util.LogUtils; | |||||
import com.google.gson.Gson; | import com.google.gson.Gson; | ||||
import com.hjq.http.model.FileContentResolver; | |||||
import com.huntersun.vkyes.etcopencard.R; | import com.huntersun.vkyes.etcopencard.R; | ||||
import com.huntersun.vkyes.etcopencard.databinding.ActivityVehicleInformationBinding; | import com.huntersun.vkyes.etcopencard.databinding.ActivityVehicleInformationBinding; | ||||
import com.huntersun.vkyes.etcopencard.project.api.Api; | import com.huntersun.vkyes.etcopencard.project.api.Api; | ||||
import com.huntersun.vkyes.etcopencard.project.api.bean.IFCode; | import com.huntersun.vkyes.etcopencard.project.api.bean.IFCode; | ||||
import com.huntersun.vkyes.etcopencard.project.api.bean.ResultBean; | import com.huntersun.vkyes.etcopencard.project.api.bean.ResultBean; | ||||
import com.huntersun.vkyes.etcopencard.project.api.bean.SendTheVerificationCodeBean; | import com.huntersun.vkyes.etcopencard.project.api.bean.SendTheVerificationCodeBean; | ||||
import com.huntersun.vkyes.etcopencard.project.dialog.ConfirmDialog; | |||||
import com.huntersun.vkyes.etcopencard.project.dialog.OrderCardListDialog; | import com.huntersun.vkyes.etcopencard.project.dialog.OrderCardListDialog; | ||||
import com.huntersun.vkyes.etcopencard.project.dialog.RechargeConfirmDialog; | |||||
import com.huntersun.vkyes.etcopencard.project.tool.FileSizeUtil; | |||||
import com.huntersun.vkyes.etcopencard.project.tool.MyShared; | |||||
import com.huntersun.vkyes.etcopencard.project.tool.QRCode; | |||||
import com.huntersun.vkyes.etcopencard.project.tool.ReaderUtils; | |||||
import com.huntersun.vkyes.etcopencard.project.ui.activity.after.CommonDealSuccessActivity; | |||||
import com.huntersun.vkyes.etcopencard.project.ui.activity.after.TopEntrapmentActivity; | |||||
import com.huntersun.vkyes.etcopencard.project.ui.activity.after.TransferOwnershipStep3Activity; | |||||
import com.huntersun.vkyes.etcopencard.project.utils.Constants; | |||||
import com.huntersun.vkyes.etcopencard.project.utils.FileUtils; | import com.huntersun.vkyes.etcopencard.project.utils.FileUtils; | ||||
import com.huntersun.vkyes.etcopencard.project.utils.FunHelper; | import com.huntersun.vkyes.etcopencard.project.utils.FunHelper; | ||||
import com.huntersun.vkyes.etcopencard.src.aop.SingleClick; | import com.huntersun.vkyes.etcopencard.src.aop.SingleClick; | ||||
import com.huntersun.vkyes.etcopencard.src.app.AppActivity; | import com.huntersun.vkyes.etcopencard.src.app.AppActivity; | ||||
import com.huntersun.vkyes.etcopencard.src.http.glide.GlideApp; | import com.huntersun.vkyes.etcopencard.src.http.glide.GlideApp; | ||||
import com.huntersun.vkyes.etcopencard.src.ui.activity.ImageCropActivity; | |||||
import com.huntersun.vkyes.etcopencard.src.ui.activity.ImageSelectActivity; | |||||
import com.huntersun.vkyes.etcopencard.src.ui.dialog.DateDialog; | import com.huntersun.vkyes.etcopencard.src.ui.dialog.DateDialog; | ||||
import com.huntersun.vkyes.etcopencard.src.ui.dialog.MenuDialog; | import com.huntersun.vkyes.etcopencard.src.ui.dialog.MenuDialog; | ||||
import com.huntersun.vkyes.etcopencard.src.ui.dialog.SelectDialog; | import com.huntersun.vkyes.etcopencard.src.ui.dialog.SelectDialog; | ||||
import com.jeremyliao.liveeventbus.LiveEventBus; | import com.jeremyliao.liveeventbus.LiveEventBus; | ||||
import java.io.File; | import java.io.File; | ||||
import java.net.URI; | |||||
import java.net.URISyntaxException; | |||||
import java.time.format.DateTimeFormatter; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Map; | import java.util.Map; | ||||
import retrofit2.Response; | import retrofit2.Response; | ||||
import top.zibin.luban.Luban; | |||||
import top.zibin.luban.OnCompressListener; | |||||
/** | /** | ||||
* 车辆信息上传 | * 车辆信息上传 | ||||
@SuppressLint({"NewApi", "LogNotTimber"}) | @SuppressLint({"NewApi", "LogNotTimber"}) | ||||
@SingleClick | @SingleClick | ||||
public void onImage(View view) { | public void onImage(View view) { | ||||
/*if (view != binding.image3){//车头照 | |||||
if (view == binding.image3){//车头照 | |||||
FileUtils.getInstance(this).uploadGeneralImage(true, null, new FileUtils.OnUploadCallback() { | |||||
@Override | |||||
public void onSuccess(ResultBean.ProductInfo bizContent) { | |||||
String url = bizContent.data.getUrl(); | |||||
if (!TextUtils.isEmpty(url)) { | |||||
imgUrl3 = url; | |||||
GlideApp.with(getActivity()).load(url).into((ImageView) view); | |||||
} | |||||
} | |||||
}); | |||||
}else{//行驶证识别 | |||||
HashMap<String,String> params = new HashMap<>(); | HashMap<String,String> params = new HashMap<>(); | ||||
params.put("filename","CSMSN_OCR_VEHICLE_REQ_"); | params.put("filename","CSMSN_OCR_VEHICLE_REQ_"); | ||||
params.put("source","1"); | params.put("source","1"); | ||||
params.put("agencyId","52010106004"); | params.put("agencyId","52010106004"); | ||||
params.put("imageType", view == binding.image1 ? "1" : "2");//1正,2反 | params.put("imageType", view == binding.image1 ? "1" : "2");//1正,2反 | ||||
params.put("fileName", System.currentTimeMillis() + ".png"); | params.put("fileName", System.currentTimeMillis() + ".png"); | ||||
FileUtils.uploadOcrDrivingLicense(this, true, params, new FileUtils.OnOcrUploadCallback() { | |||||
FileUtils.getInstance(this).uploadOcrDrivingLicense(true, params, new FileUtils.OnOcrUploadCallback() { | |||||
@Override | @Override | ||||
public void onSuccess(ResultBean.BizContent bizContent) { | |||||
public void onSuccess(ResultBean.BizContent bizContent1) { | |||||
if(!TextUtils.isEmpty(bizContent1.getPlate_a())){ | |||||
inputVehiclePlate = bizContent1.getPlate_a(); | |||||
} | |||||
//行驶证主页 | |||||
if (view == binding.image1) { | |||||
if (!TextUtils.isEmpty(bizContent1.getPlate_a())) { | |||||
binding.text1.setText(bizContent1.getPlate_a()); //车牌号 | |||||
} | |||||
if (!TextUtils.isEmpty(bizContent1.getVehicle())) { | |||||
binding.text2.setText(bizContent1.getVehicle()); //车辆类型 | |||||
} | |||||
if (!TextUtils.isEmpty(bizContent1.getMan())) { | |||||
binding.text3.setText(bizContent1.getMan()); //所有人 | |||||
} | |||||
if (!TextUtils.isEmpty(bizContent1.getModel())) { | |||||
binding.text8.setText(bizContent1.getModel()); //品牌型号 | |||||
} | |||||
if (!TextUtils.isEmpty(bizContent1.getVin())) { | |||||
binding.text9.setText(bizContent1.getVin()); //车辆识别代码 | |||||
} | |||||
if (!TextUtils.isEmpty(bizContent1.getEngine())) { | |||||
binding.text10.setText(bizContent1.getEngine()); //发动机号码 | |||||
} | |||||
if (!TextUtils.isEmpty(bizContent1.getRegister())) { | |||||
binding.text14.setText(bizContent1.getRegister()); //发证日期 | |||||
} | |||||
imgUrl1 = bizContent1.getImageUrl(); | |||||
GlideApp.with(getActivity()).load(imgUrl1).into(binding.image1); | |||||
} | |||||
//行驶证副页面 | |||||
if (view == binding.image2) { | |||||
if (!TextUtils.isEmpty(bizContent1.getApc())) { | |||||
binding.text4.setText(bizContent1.getApc().replaceAll("人", "")); //核定载人数 | |||||
} | |||||
if (!TextUtils.isEmpty(bizContent1.getGross())) { | |||||
binding.text5.setText(bizContent1.getGross().replaceAll("kg", "")); //总质量 | |||||
} | |||||
if (!TextUtils.isEmpty(bizContent1.getUnladen())) { | |||||
binding.text6.setText(bizContent1.getUnladen().replaceAll("kg", "")); //整备质量 | |||||
} | |||||
if (!TextUtils.isEmpty(bizContent1.getOverall())) { | |||||
binding.text7.setText(bizContent1.getOverall().replaceAll("mm", "")); //尺寸 | |||||
} | |||||
//大车专属 | |||||
if (!TextUtils.isEmpty(bizContent1.getAlc())) { | |||||
binding.text11.setText(bizContent1.getAlc().replaceAll("kg", "")); //核定载质量 | |||||
} | |||||
if (!TextUtils.isEmpty(bizContent1.getTowing())) { | |||||
binding.text12.setText(bizContent1.getTowing().replaceAll("kg", "")); //准牵引总质量 | |||||
} | |||||
imgUrl2 = bizContent1.getImageUrl(); | |||||
GlideApp.with(getActivity()).load(imgUrl2).into(binding.image2); | |||||
} | |||||
} | } | ||||
}); | }); | ||||
}*/ | |||||
ImageSelectActivity.start(this, data -> { | |||||
} | |||||
//旧版本 | |||||
/*ImageSelectActivity.start(this, data -> { | |||||
file = new File(data.get(0)); | file = new File(data.get(0)); | ||||
if (view != binding.image3) { | if (view != binding.image3) { | ||||
//cropImageFile(new File(data.get(0)), (ImageView) view); 裁剪图片 | //cropImageFile(new File(data.get(0)), (ImageView) view); 裁剪图片 | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
}); | |||||
});*/ | |||||
} | } | ||||
/** | /** | ||||
* 裁剪图片 | * 裁剪图片 | ||||
*/ | */ | ||||
private void cropImageFile(File sourceFile, ImageView imageView) { | private void cropImageFile(File sourceFile, ImageView imageView) { | ||||
ImageCropActivity.start(this, sourceFile, 158, 100, new ImageCropActivity.OnCropListener() { | |||||
/*ImageCropActivity.start(this, sourceFile, 158, 100, new ImageCropActivity.OnCropListener() { | |||||
@SuppressLint({"LogNotTimber", "NewApi"}) | @SuppressLint({"LogNotTimber", "NewApi"}) | ||||
@Override | @Override | ||||
// 没有的话就不裁剪,直接上传原图片 | // 没有的话就不裁剪,直接上传原图片 | ||||
// 但是这种情况极其少见,可以忽略不计 | // 但是这种情况极其少见,可以忽略不计 | ||||
} | } | ||||
}); | |||||
});*/ | |||||
} | } | ||||
//旧版本 | |||||
@SuppressLint({"LogNotTimber", "NewApi"}) | @SuppressLint({"LogNotTimber", "NewApi"}) | ||||
public void OCRspot(String base64, ImageView imageView, String mAvatarUrl, File outputFile) { | public void OCRspot(String base64, ImageView imageView, String mAvatarUrl, File outputFile) { | ||||
FatherBean<SendTheVerificationCodeBean> fatherBean = new FatherBean<>(); | |||||
/*FatherBean<SendTheVerificationCodeBean> fatherBean = new FatherBean<>(); | |||||
fatherBean.bizContent = new SendTheVerificationCodeBean(); | fatherBean.bizContent = new SendTheVerificationCodeBean(); | ||||
fatherBean.setFilename("CSMSN_OCR_VEHICLE_REQ_"); | fatherBean.setFilename("CSMSN_OCR_VEHICLE_REQ_"); | ||||
fatherBean.bizContent.setSource("1"); | fatherBean.bizContent.setSource("1"); | ||||
}, 500); | }, 500); | ||||
} | } | ||||
} | } | ||||
}); | |||||
});*/ | |||||
} | } | ||||
} | } |
if (!FunHelper.isEmpty(bizContent.ossFilePath)){ | if (!FunHelper.isEmpty(bizContent.ossFilePath)){ | ||||
String downLoadUrl = MyRetrofit.URL_DOWNLOAD_FILE + bizContent.ossFilePath; | String downLoadUrl = MyRetrofit.URL_DOWNLOAD_FILE + bizContent.ossFilePath; | ||||
String fileName = "通行流水_" + FunHelper.getText(binding.tvStartTime) + "_" + FunHelper.getText(binding.tvEndTime) + "_" + bizContent.originalFileName; | String fileName = "通行流水_" + FunHelper.getText(binding.tvStartTime) + "_" + FunHelper.getText(binding.tvEndTime) + "_" + bizContent.originalFileName; | ||||
FileUtils.downLoadFile(CheckRunningWaterStep3Activity.this,downLoadUrl,fileName); | |||||
FileUtils.getInstance(CheckRunningWaterStep3Activity.this).downLoadFile(downLoadUrl,fileName); | |||||
LogUtils.i(">>>>>下载链接",downLoadUrl); | |||||
//LogUtils.i(">>>>>下载链接",downLoadUrl); | |||||
}else{ | }else{ | ||||
toast("下载链接不存在"); | toast("下载链接不存在"); | ||||
} | } |
params.put("agencyId","52010106004"); | params.put("agencyId","52010106004"); | ||||
params.put("imageType",String.valueOf(type));//1正,2反 | params.put("imageType",String.valueOf(type));//1正,2反 | ||||
params.put("fileName",System.currentTimeMillis() + ".png");//1正,2反 | params.put("fileName",System.currentTimeMillis() + ".png");//1正,2反 | ||||
FileUtils.uploadOcrIDCard(this, false, params, new FileUtils.OnOcrUploadCallback() { | |||||
FileUtils.getInstance(this).uploadOcrIDCard(false, params, new FileUtils.OnOcrUploadCallback() { | |||||
@Override | @Override | ||||
public void onSuccess(ResultBean.BizContent bizContent) { | public void onSuccess(ResultBean.BizContent bizContent) { | ||||
GlideApp.with(getActivity()).load(bizContent.getImageUrl()).into(imageView); | GlideApp.with(getActivity()).load(bizContent.getImageUrl()).into(imageView); |
curUserType = userTypeValue; | curUserType = userTypeValue; | ||||
} | } | ||||
}); | }); | ||||
} else if (view == binding.ivUser1) {//用户正面照 | |||||
} else if (view == binding.ivUser1) {//个人用户-用户正面照 | |||||
onOCRImg(1, binding.ivUser1); | onOCRImg(1, binding.ivUser1); | ||||
} else if (view == binding.ivUser2) {//用户反面照 | |||||
} else if (view == binding.ivUser2) {//个人用户-用户反面照 | |||||
onOCRImg(2, binding.ivUser2); | onOCRImg(2, binding.ivUser2); | ||||
} else if (view == binding.ivUnit1) {//营业执照 | |||||
} else if (view == binding.ivUnit1) {//单位用户-营业执照 | |||||
//onImage(3, binding.ivUnit1); | //onImage(3, binding.ivUnit1); | ||||
onOCRImg(3, binding.ivUnit1); | onOCRImg(3, binding.ivUnit1); | ||||
} else if (view == binding.ivUnit2) {//用户证件照 | |||||
} else if (view == binding.ivUnit2) {//单位用户-用户证件照 | |||||
onOCRImg(4, binding.ivUnit2); | onOCRImg(4, binding.ivUnit2); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* 图片上传 | |||||
* 图片上传(暂时不用-接口没有上传营业执照,而是用户正面照) | |||||
* | * | ||||
* @param type 3-营业执照 | * @param type 3-营业执照 | ||||
*/ | */ | ||||
public void onImage(int type, ImageView imageView) { | public void onImage(int type, ImageView imageView) { | ||||
FileUtils.uploadGeneralImage(this, false, null, new FileUtils.OnUploadCallback() { | |||||
FileUtils.getInstance(this).uploadGeneralImage( false, null, new FileUtils.OnUploadCallback() { | |||||
@Override | @Override | ||||
public void onSuccess(ResultBean.ProductInfo bizContent) { | public void onSuccess(ResultBean.ProductInfo bizContent) { | ||||
if (!TextUtils.isEmpty(bizContent.data.getUrl())) { | if (!TextUtils.isEmpty(bizContent.data.getUrl())) { | ||||
}else{ | }else{ | ||||
params.put("imageType",String.valueOf(type));//1正,2反 | params.put("imageType",String.valueOf(type));//1正,2反 | ||||
} | } | ||||
FileUtils.uploadOcrIDCard(this, false, params, new FileUtils.OnOcrUploadCallback() { | |||||
FileUtils.getInstance(this).uploadOcrIDCard(false, params, new FileUtils.OnOcrUploadCallback() { | |||||
@Override | @Override | ||||
public void onSuccess(ResultBean.BizContent bizContent1) { | public void onSuccess(ResultBean.BizContent bizContent1) { | ||||
GlideApp.with(getActivity()).load(bizContent1.getImageUrl()).into(imageView); | GlideApp.with(getActivity()).load(bizContent1.getImageUrl()).into(imageView); |
* 选择上传剪裁图片 | * 选择上传剪裁图片 | ||||
*/ | */ | ||||
public void onImage() { | public void onImage() { | ||||
FileUtils.uploadGeneralImage(this, true, null, new FileUtils.OnUploadCallback() { | |||||
FileUtils.getInstance(this).uploadGeneralImage( true, null, new FileUtils.OnUploadCallback() { | |||||
@Override | @Override | ||||
public void onSuccess(ResultBean.ProductInfo bizContent) { | public void onSuccess(ResultBean.ProductInfo bizContent) { | ||||
String url = bizContent.data.getUrl(); | String url = bizContent.data.getUrl(); |
* @param type 1-车头照 2-车身45° 3-安装照 | * @param type 1-车头照 2-车身45° 3-安装照 | ||||
*/ | */ | ||||
public void onImage(ImageView imageView,int type) { | public void onImage(ImageView imageView,int type) { | ||||
FileUtils.uploadGeneralImage(ObuActivationUploadActivity.this, false,null,new FileUtils.OnUploadCallback() { | |||||
FileUtils.getInstance(this).uploadGeneralImage( false,null,new FileUtils.OnUploadCallback() { | |||||
@Override | @Override | ||||
public void onSuccess(ResultBean.ProductInfo productInfo) { | public void onSuccess(ResultBean.ProductInfo productInfo) { | ||||
if (!TextUtils.isEmpty(productInfo.data.getUrl())) { | if (!TextUtils.isEmpty(productInfo.data.getUrl())) { |
import com.huntersun.vkyes.etcopencard.project.api.bean.ResultBean; | import com.huntersun.vkyes.etcopencard.project.api.bean.ResultBean; | ||||
import com.huntersun.vkyes.etcopencard.project.dialog.ConfirmDialog; | import com.huntersun.vkyes.etcopencard.project.dialog.ConfirmDialog; | ||||
import com.huntersun.vkyes.etcopencard.project.tool.FileSizeUtil; | import com.huntersun.vkyes.etcopencard.project.tool.FileSizeUtil; | ||||
import com.huntersun.vkyes.etcopencard.project.tool.OCRDistinguish; | |||||
import com.huntersun.vkyes.etcopencard.project.tool.QRCode; | import com.huntersun.vkyes.etcopencard.project.tool.QRCode; | ||||
import com.huntersun.vkyes.etcopencard.src.aop.CheckNet; | import com.huntersun.vkyes.etcopencard.src.aop.CheckNet; | ||||
import com.huntersun.vkyes.etcopencard.src.aop.Permissions; | import com.huntersun.vkyes.etcopencard.src.aop.Permissions; | ||||
* Description:文件上传、下载 工具类 | * Description:文件上传、下载 工具类 | ||||
*/ | */ | ||||
public class FileUtils { | public class FileUtils { | ||||
private final BaseActivity mContext; | |||||
public FileUtils(BaseActivity mContext) { | |||||
this.mContext = mContext; | |||||
} | |||||
public static FileUtils getInstance(BaseActivity mContext) { | |||||
return new FileUtils(mContext); | |||||
} | |||||
//************************************图片上传***************************************// | //************************************图片上传***************************************// | ||||
* @param callback 回调 | * @param callback 回调 | ||||
*/ | */ | ||||
@CheckNet | @CheckNet | ||||
public static void uploadGeneralImage(BaseActivity mContext, boolean isCompress, Map<String, String> params, OnUploadCallback callback) { | |||||
if (params == null) {params = new HashMap<>(); } | |||||
public void uploadGeneralImage(boolean isCompress, Map<String, String> params, OnUploadCallback callback) { | |||||
if (params == null) { | |||||
params = new HashMap<>(); | |||||
} | |||||
Map<String, String> finalParams = params; | Map<String, String> finalParams = params; | ||||
selectImgAndCompress(mContext, isCompress, new OnCompressCallback() { | |||||
selectImgAndCompress(isCompress, new OnCompressCallback() { | |||||
@Override | @Override | ||||
public void onCompressResult(String fileBase64, File file) { | public void onCompressResult(String fileBase64, File file) { | ||||
BaseDialog mDialog = new WaitDialog.Builder(mContext).setCancelable(false).setMessage("图片文件上传中...").create(); | BaseDialog mDialog = new WaitDialog.Builder(mContext).setCancelable(false).setMessage("图片文件上传中...").create(); | ||||
* @param callback 回调 | * @param callback 回调 | ||||
*/ | */ | ||||
@CheckNet | @CheckNet | ||||
public static void uploadOcrIDCard(BaseActivity mContext,boolean isCompress,Map<String, String> params, OnOcrUploadCallback callback){ | |||||
if (params == null) {params = new HashMap<>(); } | |||||
public void uploadOcrIDCard( boolean isCompress, Map<String, String> params, OnOcrUploadCallback callback) { | |||||
if (params == null) { | |||||
params = new HashMap<>(); | |||||
} | |||||
Map<String, String> finalParams = params; | Map<String, String> finalParams = params; | ||||
selectImgAndCompress(mContext, isCompress, new OnCompressCallback() { | |||||
selectImgAndCompress(isCompress, new OnCompressCallback() { | |||||
@Override | @Override | ||||
public void onCompressResult(String fileBase64, File file) { | public void onCompressResult(String fileBase64, File file) { | ||||
BaseDialog mDialog = new WaitDialog.Builder(mContext).setCancelable(false).setMessage("证件信息识别中...").create(); | BaseDialog mDialog = new WaitDialog.Builder(mContext).setCancelable(false).setMessage("证件信息识别中...").create(); | ||||
@Override | @Override | ||||
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { | public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { | ||||
if (mDialog != null) mDialog.dismiss(); | if (mDialog != null) mDialog.dismiss(); | ||||
if (callback != null){ | |||||
if (callback != null) { | |||||
callback.onSuccess(bizContent); | callback.onSuccess(bizContent); | ||||
} | } | ||||
if (file != null && file.exists()) { | if (file != null && file.exists()) { | ||||
* @param callback 回调 | * @param callback 回调 | ||||
*/ | */ | ||||
@CheckNet | @CheckNet | ||||
public static void uploadOcrDrivingLicense(BaseActivity mContext,boolean isCompress,Map<String, String> params, OnOcrUploadCallback callback){ | |||||
if (params == null) {params = new HashMap<>(); } | |||||
public void uploadOcrDrivingLicense(boolean isCompress, Map<String, String> params, OnOcrUploadCallback callback) { | |||||
if (params == null) { | |||||
params = new HashMap<>(); | |||||
} | |||||
Map<String, String> finalParams = params; | Map<String, String> finalParams = params; | ||||
selectImgAndCompress(mContext, isCompress, new OnCompressCallback() { | |||||
selectImgAndCompress(isCompress, new OnCompressCallback() { | |||||
@Override | @Override | ||||
public void onCompressResult(String fileBase64, File file) { | public void onCompressResult(String fileBase64, File file) { | ||||
BaseDialog mDialog = new WaitDialog.Builder(mContext).setCancelable(false).setMessage("证件信息识别中...").create(); | BaseDialog mDialog = new WaitDialog.Builder(mContext).setCancelable(false).setMessage("证件信息识别中...").create(); | ||||
@Override | @Override | ||||
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { | public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { | ||||
if (mDialog != null) mDialog.dismiss(); | if (mDialog != null) mDialog.dismiss(); | ||||
if (callback != null){ | |||||
if (callback != null) { | |||||
callback.onSuccess(bizContent); | callback.onSuccess(bizContent); | ||||
} | } | ||||
if (file != null && file.exists()) { | if (file != null && file.exists()) { | ||||
* @param callback | * @param callback | ||||
*/ | */ | ||||
@CheckNet | @CheckNet | ||||
public static void uploadOcrBusinessLicense(BaseActivity mContext,boolean isCompress,Map<String, String> params, OnOcrUploadCallback callback){ | |||||
if (params == null) {params = new HashMap<>(); } | |||||
public void uploadOcrBusinessLicense(boolean isCompress, Map<String, String> params, OnOcrUploadCallback callback) { | |||||
if (params == null) { | |||||
params = new HashMap<>(); | |||||
} | |||||
Map<String, String> finalParams = params; | Map<String, String> finalParams = params; | ||||
selectImgAndCompress(mContext, isCompress, new OnCompressCallback() { | |||||
selectImgAndCompress(isCompress, new OnCompressCallback() { | |||||
@Override | @Override | ||||
public void onCompressResult(String fileBase64, File file) { | public void onCompressResult(String fileBase64, File file) { | ||||
BaseDialog mDialog = new WaitDialog.Builder(mContext).setCancelable(false).setMessage("证件信息识别中...").create(); | BaseDialog mDialog = new WaitDialog.Builder(mContext).setCancelable(false).setMessage("证件信息识别中...").create(); | ||||
@Override | @Override | ||||
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { | public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { | ||||
if (mDialog != null) mDialog.dismiss(); | if (mDialog != null) mDialog.dismiss(); | ||||
if (callback != null){ | |||||
if (callback != null) { | |||||
callback.onSuccess(bizContent); | callback.onSuccess(bizContent); | ||||
} | } | ||||
if (file != null && file.exists()) { | if (file != null && file.exists()) { | ||||
* @param callback | * @param callback | ||||
*/ | */ | ||||
@CheckNet | @CheckNet | ||||
private static void selectImgAndCompress(BaseActivity mContext, boolean comPress,OnCompressCallback callback) { | |||||
private void selectImgAndCompress(boolean comPress, OnCompressCallback callback) { | |||||
ImageSelectActivity.start(mContext, data -> { | ImageSelectActivity.start(mContext, data -> { | ||||
File file = new File(data.get(0)); | File file = new File(data.get(0)); | ||||
if (!comPress){//不压缩 | |||||
if (!comPress) {//不压缩 | |||||
if (callback != null) { | if (callback != null) { | ||||
mContext.postDelayed(() -> callback.onCompressResult(QRCode.imageToBase64(file.getPath()), file), 200); | mContext.postDelayed(() -> callback.onCompressResult(QRCode.imageToBase64(file.getPath()), file), 200); | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* 上传回调 | |||||
* 上传普通图片回调 | |||||
*/ | */ | ||||
public interface OnUploadCallback { | public interface OnUploadCallback { | ||||
void onSuccess(ResultBean.ProductInfo bizContent); | void onSuccess(ResultBean.ProductInfo bizContent); | ||||
} | } | ||||
/* | /* | ||||
* OCR识别成功 | |||||
* OCR识别成功回调 | |||||
*/ | */ | ||||
public interface OnOcrUploadCallback { | public interface OnOcrUploadCallback { | ||||
void onSuccess(ResultBean.BizContent bizContent); | void onSuccess(ResultBean.BizContent bizContent); | ||||
} | } | ||||
/* | /* | ||||
* 压缩回调 | |||||
* 图片选取、压缩回调 | |||||
*/ | */ | ||||
public interface OnCompressCallback { | public interface OnCompressCallback { | ||||
void onCompressResult(String fileBase64, File file); | void onCompressResult(String fileBase64, File file); | ||||
@RequiresApi(api = Build.VERSION_CODES.M) | @RequiresApi(api = Build.VERSION_CODES.M) | ||||
@CheckNet | @CheckNet | ||||
@Permissions({Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE}) | @Permissions({Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE}) | ||||
public static void downLoadFile(AppActivity activity, String downLoadUrl, String fileName) { | |||||
activity.showDialog("文件下载中..."); | |||||
public void downLoadFile(String downLoadUrl, String fileName) { | |||||
BaseDialog mDialog = new WaitDialog.Builder(mContext).setCancelable(false).setMessage("文件下载中...").create(); | |||||
mDialog.show(); | |||||
// 创建要下载的文件对象 | // 创建要下载的文件对象 | ||||
File file = new File(activity.getContext().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), fileName); | |||||
EasyHttp.download(activity).method(HttpMethod.GET).file(file).url(downLoadUrl).listener(new OnDownloadListener() { | |||||
File file = new File(mContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), fileName); | |||||
EasyHttp.download(mContext).method(HttpMethod.GET).file(file).url(downLoadUrl).listener(new OnDownloadListener() { | |||||
@Override | @Override | ||||
public void onStart(File file) { | public void onStart(File file) { | ||||
// 标记为下载中 | // 标记为下载中 | ||||
@SuppressLint("StringFormatInvalid") | @SuppressLint("StringFormatInvalid") | ||||
@Override | @Override | ||||
public void onComplete(File file) { | public void onComplete(File file) { | ||||
activity.hideDialog(); | |||||
if (mDialog != null) mDialog.dismiss(); | |||||
LogUtils.e("下载完成>>>>>>", file.getAbsolutePath()); | LogUtils.e("下载完成>>>>>>", file.getAbsolutePath()); | ||||
mDownloadComplete = true; | mDownloadComplete = true; | ||||
new ConfirmDialog.Builder(activity).setMsg("文件所在路径:" + file.getAbsolutePath(), "下载完成", "知道了", "", R.mipmap.icon_finish_order, 0, true) | |||||
new ConfirmDialog.Builder(mContext).setMsg("文件所在路径:" + file.getAbsolutePath(), "下载完成", "知道了", "", R.mipmap.icon_finish_order, 0, true) | |||||
.onClick(new ConfirmDialog.Result() { | .onClick(new ConfirmDialog.Result() { | ||||
@Override | @Override | ||||
public void confirm() { | public void confirm() { | ||||
@SuppressWarnings("ResultOfMethodCallIgnored") | @SuppressWarnings("ResultOfMethodCallIgnored") | ||||
@Override | @Override | ||||
public void onError(File file, Exception e) { | public void onError(File file, Exception e) { | ||||
activity.hideDialog(); | |||||
if (mDialog != null) mDialog.dismiss(); | |||||
// 删除下载的文件 | // 删除下载的文件 | ||||
file.delete(); | |||||
if (file != null && file.exists()){ | |||||
file.delete(); | |||||
} | |||||
} | } | ||||
@Override | @Override | ||||
public void onEnd(File file) { | public void onEnd(File file) { | ||||
activity.hideDialog(); | |||||
if (mDialog != null) mDialog.dismiss(); | |||||
// 标记当前不是下载中 | // 标记当前不是下载中 | ||||
mDownloading = false; | mDownloading = false; | ||||
} | } | ||||
@RequiresApi(api = Build.VERSION_CODES.M) | @RequiresApi(api = Build.VERSION_CODES.M) | ||||
@CheckNet | @CheckNet | ||||
@Permissions({Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE}) | @Permissions({Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE}) | ||||
public static void downLoadFileWithNotice(AppActivity activity, String downLoadUrl) { | |||||
activity.showDialog("文件下载中..."); | |||||
NotificationManager notificationManager = activity.getSystemService(NotificationManager.class); | |||||
int notificationId = activity.getContext().getApplicationInfo().uid; | |||||
public void downLoadFileWithNotice(String downLoadUrl) { | |||||
BaseDialog mDialog = new WaitDialog.Builder(mContext).setCancelable(false).setMessage("文件下载中...").create(); | |||||
mDialog.show(); | |||||
NotificationManager notificationManager = mContext.getSystemService(NotificationManager.class); | |||||
int notificationId = mContext.getApplicationInfo().uid; | |||||
String channelId = ""; | String channelId = ""; | ||||
// 适配 Android 8.0 通知渠道新特性 | // 适配 Android 8.0 通知渠道新特性 | ||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { | ||||
NotificationChannel channel = new NotificationChannel(activity.getString(R.string.update_notification_channel_id), activity.getString(R.string.update_notification_channel_name), NotificationManager.IMPORTANCE_LOW); | |||||
NotificationChannel channel = new NotificationChannel(mContext.getString(R.string.update_notification_channel_id), mContext.getString(R.string.update_notification_channel_name), NotificationManager.IMPORTANCE_LOW); | |||||
channel.enableLights(false); | channel.enableLights(false); | ||||
channel.enableVibration(false); | channel.enableVibration(false); | ||||
channel.setVibrationPattern(new long[]{0}); | channel.setVibrationPattern(new long[]{0}); | ||||
notificationManager.createNotificationChannel(channel); | notificationManager.createNotificationChannel(channel); | ||||
channelId = channel.getId(); | channelId = channel.getId(); | ||||
} | } | ||||
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(activity.getContext(), channelId) | |||||
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mContext.getContext(), channelId) | |||||
.setWhen(System.currentTimeMillis()) | .setWhen(System.currentTimeMillis()) | ||||
.setContentTitle(activity.getString(R.string.app_name)) | |||||
.setContentTitle(mContext.getString(R.string.app_name)) | |||||
.setSmallIcon(R.mipmap.launcher_ic) | .setSmallIcon(R.mipmap.launcher_ic) | ||||
.setLargeIcon(BitmapFactory.decodeResource(activity.getResources(), R.mipmap.icon_entrapment)) | |||||
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), R.mipmap.icon_entrapment)) | |||||
.setDefaults(NotificationCompat.FLAG_ONLY_ALERT_ONCE) | .setDefaults(NotificationCompat.FLAG_ONLY_ALERT_ONCE) | ||||
.setVibrate(new long[]{0}) | .setVibrate(new long[]{0}) | ||||
.setSound(null) | .setSound(null) | ||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT); | .setPriority(NotificationCompat.PRIORITY_DEFAULT); | ||||
// 创建要下载的文件对象 | // 创建要下载的文件对象 | ||||
File file = new File(activity.getContext().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), "通行流水记录" + ".excel"); | |||||
EasyHttp.download(activity).method(HttpMethod.GET).file(file).url(downLoadUrl).listener(new OnDownloadListener() { | |||||
File file = new File(mContext.getContext().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), "通行流水记录" + ".excel"); | |||||
EasyHttp.download(mContext).method(HttpMethod.GET).file(file).url(downLoadUrl).listener(new OnDownloadListener() { | |||||
@Override | @Override | ||||
public void onStart(File file) { | public void onStart(File file) { | ||||
// 标记为下载中 | // 标记为下载中 | ||||
public void onProgress(File file, int progress) { | public void onProgress(File file, int progress) { | ||||
// 更新下载通知 | // 更新下载通知 | ||||
notificationManager.notify(notificationId, notificationBuilder | notificationManager.notify(notificationId, notificationBuilder | ||||
.setContentText(String.format(activity.getString(R.string.update_status_running), progress)) | |||||
.setContentText(String.format(mContext.getString(R.string.update_status_running), progress)) | |||||
.setProgress(100, progress, false) | .setProgress(100, progress, false) | ||||
.setAutoCancel(false) | .setAutoCancel(false) | ||||
.setOngoing(true) | .setOngoing(true) | ||||
@SuppressLint("StringFormatInvalid") | @SuppressLint("StringFormatInvalid") | ||||
@Override | @Override | ||||
public void onComplete(File file) { | public void onComplete(File file) { | ||||
activity.hideDialog(); | |||||
if (mDialog != null) mDialog.dismiss(); | |||||
LogUtils.e("下载完成>>>>>>", file.getAbsolutePath()); | LogUtils.e("下载完成>>>>>>", file.getAbsolutePath()); | ||||
notificationManager.notify(notificationId, notificationBuilder | notificationManager.notify(notificationId, notificationBuilder | ||||
.setContentText(String.format(activity.getString(R.string.down_status_successful), 100)) | |||||
.setContentText(String.format(mContext.getString(R.string.down_status_successful), 100)) | |||||
.setProgress(100, 100, false) | .setProgress(100, 100, false) | ||||
//.setContentIntent(PendingIntent.getActivity(getContext(), 1,FunHelper.getExcelFileIntent(file), Intent.FILL_IN_ACTION)) | //.setContentIntent(PendingIntent.getActivity(getContext(), 1,FunHelper.getExcelFileIntent(file), Intent.FILL_IN_ACTION)) | ||||
.setAutoCancel(false) | .setAutoCancel(false) | ||||
.setOngoing(false) | .setOngoing(false) | ||||
.build()); | .build()); | ||||
mDownloadComplete = true; | mDownloadComplete = true; | ||||
new ConfirmDialog.Builder(activity).setMsg("文件所在路径:" + file.getAbsolutePath(), "下载完成", "立即查看", "知道了", R.mipmap.icon_finish_order, 0, false) | |||||
new ConfirmDialog.Builder(mContext).setMsg("文件所在路径:" + file.getAbsolutePath(), "下载完成", "立即查看", "知道了", R.mipmap.icon_finish_order, 0, false) | |||||
.onClick(new ConfirmDialog.Result() { | .onClick(new ConfirmDialog.Result() { | ||||
@Override | @Override | ||||
public void confirm() { | public void confirm() { | ||||
@SuppressWarnings("ResultOfMethodCallIgnored") | @SuppressWarnings("ResultOfMethodCallIgnored") | ||||
@Override | @Override | ||||
public void onError(File file, Exception e) { | public void onError(File file, Exception e) { | ||||
activity.hideDialog(); | |||||
if (mDialog != null) mDialog.dismiss(); | |||||
// 清除通知 | // 清除通知 | ||||
notificationManager.cancel(notificationId); | notificationManager.cancel(notificationId); | ||||
// 删除下载的文件 | // 删除下载的文件 | ||||
file.delete(); | |||||
if (file != null && file.exists()){ | |||||
file.delete(); | |||||
} | |||||
} | } | ||||
@Override | @Override | ||||
public void onEnd(File file) { | public void onEnd(File file) { | ||||
activity.hideDialog(); | |||||
if (mDialog != null) mDialog.dismiss(); | |||||
// 标记当前不是下载中 | // 标记当前不是下载中 | ||||
mDownloading = false; | mDownloading = false; | ||||
} | } |