From 69e803d48b23f8465750f65ab93e3958405c5fb6 Mon Sep 17 00:00:00 2001 From: lijia Date: Wed, 26 Jun 2024 09:42:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E8=BE=86=E8=A1=8C=E9=A9=B6=E8=AF=81?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BC=96=E8=BE=91=E6=B7=BB=E5=8A=A0=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E5=A4=A7=E5=9B=BE=EF=BC=8C=E4=BB=A5=E5=8F=8A=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=9B=B4=E6=8D=A2=E5=9B=BE=E7=89=87=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/authperson/AuthDrivingActivity.kt | 63 +++++++++- .../account/authperson/EditDrivingActivity.kt | 110 ++++++++++++----- .../main/res/layout/activity_auth_driving.xml | 113 +++++++++++++----- app/src/main/res/values/strings.xml | 1 + 4 files changed, 228 insertions(+), 59 deletions(-) diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/account/authperson/AuthDrivingActivity.kt b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/account/authperson/AuthDrivingActivity.kt index 4a0bef8..d393b7f 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/account/authperson/AuthDrivingActivity.kt +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/account/authperson/AuthDrivingActivity.kt @@ -2,6 +2,7 @@ package com.arpa.hndahesudintocctmsdriver.ui.account.authperson import android.os.Bundle import android.view.View +import android.widget.ImageView import com.arpa.hndahesudintocctmsdriver.R import com.arpa.hndahesudintocctmsdriver.base.AppConfig import com.arpa.hndahesudintocctmsdriver.bean.CarBean @@ -82,6 +83,27 @@ class AuthDrivingActivity : BaseActivity() { } } + tvChangeFront.setOnClickListener { + if (showPic(upDrivingInfoBean.licenseFaceUrl, ivFront)) + return@setOnClickListener + selFrontPic() + } + tvChangeBack.setOnClickListener { + if (showPic(upDrivingInfoBean.licenseBackUrl, ivBack)) + return@setOnClickListener + selBackPic() + } + tvChangeCar.setOnClickListener { + if (showPic(upDrivingInfoBean.carUrl, ivCar)) + return@setOnClickListener + selCarPic() + } + tvChangeRoad.setOnClickListener { + if (showPic(upDrivingInfoBean.roadLicensePhotoUrl, ivRoadFront)) + return@setOnClickListener + selRoadPic() + } + tvDate.setOnClickListener { PickerUtils.getInstance().showDateSim(this@AuthDrivingActivity) { tvDate.text = it @@ -147,7 +169,7 @@ class AuthDrivingActivity : BaseActivity() { upDrivingInfoBean.licenseFaceUrl = picPath.picPath//行驶证照片(正面) result?.data?.face?.data?.let { var isHave = false - getCarInfoByCarNum(it.licensePlateNumber) { upDrivingInfoBean-> + getCarInfoByCarNum(it.licensePlateNumber) { upDrivingInfoBean -> initViewByData(upDrivingInfoBean) isHave = true return@getCarInfoByCarNum @@ -188,13 +210,13 @@ class AuthDrivingActivity : BaseActivity() { etUseNature.setText(it.useNature) etCurbWeight.setText(it.curbWeight) etPermittedWeight.setText(it.permittedWeight) + tvChangeFront.visibility = View.VISIBLE } } } } private fun selBackPic() { - OcrUtils.getInstance().ocrDriveing(mContext, this) { picPath, result -> if (result?.data?.back == null) { ToastUtils.showToast(mContext, "请选择正确证件照片") @@ -255,15 +277,48 @@ class AuthDrivingActivity : BaseActivity() { } } -// binding.run { + binding.run { + tvChangeBack.visibility = View.VISIBLE // etCurbWeight.setText(it.curbWeight)//整备质量 // etPermittedWeight.setText(it.permittedWeight)// -// } + } } } } + private fun selCarPic() { + OcrUtils.getInstance() + .noOcrUpPic(mContext, this@AuthDrivingActivity) { picPath, ocrResult -> + ImageLoader.getInstance() + .loadRoundImage(mContext, picPath.locPic, 12, binding.ivCar) + upDrivingInfoBean.carUrl = picPath.picPath + binding.tvChangeCar.visibility = View.VISIBLE + } + } + + private fun selRoadPic() { + OcrUtils.getInstance() + .noOcrUpPic(mContext, this@AuthDrivingActivity) { picPath, ocrResult -> + ImageLoader.getInstance() + .loadRoundImage(mContext, picPath.locPic, 12, binding.ivRoadFront) + upDrivingInfoBean.roadLicensePhotoUrl = picPath.picPath + binding.tvChangeRoad.visibility = View.VISIBLE + } + } + + private fun showPic(url: String, image: ImageView): Boolean { + if (!url.isNullOrEmpty()) { + CommonPopUtils.getInstance().showOnePic( + mContext, + image, url + ) + return true + } + + return false + } + private fun subMit() { binding.run { if (etCarNum.text.isNullOrEmpty() || diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/account/authperson/EditDrivingActivity.kt b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/account/authperson/EditDrivingActivity.kt index 2231e45..7fc4ce1 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/account/authperson/EditDrivingActivity.kt +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/account/authperson/EditDrivingActivity.kt @@ -2,6 +2,7 @@ package com.arpa.hndahesudintocctmsdriver.ui.account.authperson import android.os.Bundle import android.view.View +import android.widget.ImageView import com.arpa.hndahesudintocctmsdriver.R import com.arpa.hndahesudintocctmsdriver.base.AppConfig import com.arpa.hndahesudintocctmsdriver.bean.DiCarColor @@ -49,29 +50,37 @@ class EditDrivingActivity : BaseActivity() { plateColor = "黄色" } ivFront.setOnClickListener { + if (showPic(upDrivingInfoBean.licenseFaceUrl, ivFront)) + return@setOnClickListener selFrontPic() } - ivBack.setOnClickListener { + if (showPic(upDrivingInfoBean.licenseBackUrl, ivBack)) + return@setOnClickListener selBackPic() } ivRoadFront.setOnClickListener { - OcrUtils.getInstance() - .noOcrUpPic(mContext, this@EditDrivingActivity) { picPath, ocrResult -> - ImageLoader.getInstance() - .loadRoundImage(mContext, picPath.locPic, 12, ivRoadFront) - upDrivingInfoBean.roadLicensePhotoUrl = picPath.picPath - } + if (showPic(upDrivingInfoBean.roadLicensePhotoUrl, ivRoadFront)) + return@setOnClickListener + + selRoadPic() } ivCar.setOnClickListener { - OcrUtils.getInstance() - .noOcrUpPic(mContext, this@EditDrivingActivity) { picPath, ocrResult -> - ImageLoader.getInstance() - .loadRoundImage(mContext, picPath.locPic, 12, ivCar) - upDrivingInfoBean.carUrl = picPath.picPath - } + if (showPic(upDrivingInfoBean.carUrl, ivCar)) + return@setOnClickListener + selCarPic() } + tvChangeFront.setOnClickListener { selFrontPic() } + tvChangeBack.setOnClickListener { selBackPic() } + tvChangeCar.setOnClickListener { + selCarPic() + } + tvChangeRoad.setOnClickListener { + selRoadPic() + } + + tvDate.setOnClickListener { PickerUtils.getInstance().showDateSim(this@EditDrivingActivity) { tvDate.text = it @@ -92,7 +101,8 @@ class EditDrivingActivity : BaseActivity() { upDrivingInfoBean.run { vehicleTypeCode = data.dictValue vehicleType = data.dictLabel - isTrailer = if (data.dictLabel.contains("牵引车")) "1" else "0"//是否有挂车(0否 1是) + isTrailer = + if (data.dictLabel.contains("牵引车")) "1" else "0"//是否有挂车(0否 1是) } } } @@ -102,8 +112,6 @@ class EditDrivingActivity : BaseActivity() { } } - - tvCarColor.setOnClickListener { DicUtils.getInstance() .getCarColor(mContext, this@EditDrivingActivity) { position, item -> @@ -146,10 +154,10 @@ class EditDrivingActivity : BaseActivity() { tvEnd.isEnabled = false tvDate.isEnabled = false tvCarColor.isEnabled = false - ivRoadFront.isEnabled = false - ivCar.isEnabled = false - ivFront.isEnabled = false - ivBack.isEnabled = false +// ivRoadFront.isEnabled = false +// ivCar.isEnabled = false +// ivFront.isEnabled = false +// ivBack.isEnabled = false } } binding.run { @@ -162,6 +170,18 @@ class EditDrivingActivity : BaseActivity() { ImageLoader.getInstance() .loadRoundImage(mContext, data.roadLicensePhotoUrl, 12, ivRoadFront) + tvChangeFront.visibility = + if (data.licenseFaceUrl.isNullOrEmpty() || isOnlyShow) View.GONE else View.VISIBLE + tvChangeBack.visibility = + if (data.licenseBackUrl.isNullOrEmpty() || isOnlyShow) View.GONE else View.VISIBLE + + tvChangeCar.visibility = + if (data.carUrl.isNullOrEmpty() || isOnlyShow) View.GONE else View.VISIBLE + + tvChangeRoad.visibility = + if (data.roadLicensePhotoUrl.isNullOrEmpty() || isOnlyShow) View.GONE else View.VISIBLE + + etCarNum.setText(data.vehicleNum) backLicCarNum = data.vehicleNum tvCarType.text = data.vehicleType @@ -200,15 +220,16 @@ class EditDrivingActivity : BaseActivity() { engineNo = it.engineNumber vinCode = it.vinCode model = it.model - licenseRegisterDate = TimeUtil.changeDateNoneFormat(it.registrationDate,"yyyy-MM-dd") - licenseIssueDate = TimeUtil.changeDateNoneFormat(it.issueDate,"yyyy-MM-dd") + licenseRegisterDate = + TimeUtil.changeDateNoneFormat(it.registrationDate, "yyyy-MM-dd") + licenseIssueDate = TimeUtil.changeDateNoneFormat(it.issueDate, "yyyy-MM-dd") address = it.address } //识别车辆类型后,调用接口匹配code值!!!??? DicUtils.getInstance() - .getCarTypeByValue(mContext, it.vehicleType,"0") { position, item -> + .getCarTypeByValue(mContext, it.vehicleType, "0") { position, item -> if (item != null) { var data = item as DiCarColor upDrivingInfoBean.run { @@ -225,13 +246,13 @@ class EditDrivingActivity : BaseActivity() { etUseNature.setText(it.useNature) etCurbWeight.setText(it.curbWeight) etPermittedWeight.setText(it.permittedWeight) + tvChangeFront.visibility = View.VISIBLE } } } } private fun selBackPic() { - OcrUtils.getInstance().ocrDriveing(mContext, this) { picPath, result -> if (result?.data?.back == null) { ToastUtils.showToast(mContext, "请选择正确证件照片") @@ -273,7 +294,7 @@ class EditDrivingActivity : BaseActivity() { //车长 if (it.overallDimension.contains("mm")) { var overall = it.overallDimension.replace("mm", "") - var splits = overall.split("×","x","X") + var splits = overall.split("×", "x", "X") if (splits.size == 3) { upDrivingInfoBean.carLong = if (splits[0].toIntOrNull() != null) splits[0] else "" @@ -290,14 +311,47 @@ class EditDrivingActivity : BaseActivity() { overallDimension = it.overallDimension } -// binding.run { + binding.run { + tvChangeBack.visibility = View.VISIBLE // etCurbWeight.setText(it.curbWeight)//整备质量 // etPermittedWeight.setText(it.permittedWeight)//核定载质量 -// } + } } } } + private fun showPic(url: String, image: ImageView): Boolean { + if (!url.isNullOrEmpty()) { + CommonPopUtils.getInstance().showOnePic( + mContext, + image, url + ) + return true + } + + return false + } + + private fun selRoadPic() { + OcrUtils.getInstance() + .noOcrUpPic(mContext, this@EditDrivingActivity) { picPath, ocrResult -> + ImageLoader.getInstance() + .loadRoundImage(mContext, picPath.locPic, 12, binding.ivRoadFront) + upDrivingInfoBean.roadLicensePhotoUrl = picPath.picPath + binding.tvChangeRoad.visibility = View.VISIBLE + } + } + + private fun selCarPic() { + OcrUtils.getInstance() + .noOcrUpPic(mContext, this@EditDrivingActivity) { picPath, ocrResult -> + ImageLoader.getInstance() + .loadRoundImage(mContext, picPath.locPic, 12, binding.ivCar) + upDrivingInfoBean.carUrl = picPath.picPath + binding.tvChangeCar.visibility = View.VISIBLE + } + } + private fun subMit() { binding.run { if (etCarNum.text.isNullOrEmpty() || @@ -322,7 +376,7 @@ class EditDrivingActivity : BaseActivity() { owner = binding.etOwner.text.trim().toString() useNature = binding.etUseNature.text.trim().toString() } - if(upDrivingInfoBean.vehicleNum.contains("挂")){ + if (upDrivingInfoBean.vehicleNum.contains("挂")) { showToast("车牌号码不合规") return } diff --git a/app/src/main/res/layout/activity_auth_driving.xml b/app/src/main/res/layout/activity_auth_driving.xml index ed6cefe..41fcec4 100644 --- a/app/src/main/res/layout/activity_auth_driving.xml +++ b/app/src/main/res/layout/activity_auth_driving.xml @@ -37,7 +37,7 @@ + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:paddingBottom="@dimen/dp_18"> - + + + + + android:gravity="right" + android:paddingRight="@dimen/dp_4" + android:paddingBottom="@dimen/dp_4" + android:text="@string/change_pic" + android:textColor="@color/main_red" + android:textStyle="bold" + android:visibility="gone" /> + android:layout_gravity="center_horizontal" + android:paddingBottom="@dimen/dp_18"> + @@ -218,8 +261,8 @@ @@ -238,6 +281,7 @@ android:textSize="@dimen/sp_15" tools:text="王海生"> + @@ -307,9 +351,9 @@ @@ -325,16 +369,15 @@ android:hint="请选择有效期至" android:paddingLeft="@dimen/dp_10" android:textColor="@color/black" - android:textSize="@dimen/sp_15" - > + android:textSize="@dimen/sp_15"> + android:orientation="horizontal" + android:visibility="gone"> + + android:orientation="horizontal" + android:visibility="gone"> - + android:layout_gravity="center_horizontal" + android:paddingBottom="@dimen/dp_18"> + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fbeb744..2e0f929 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -9,4 +9,5 @@ Not a valid username Password must be >5 characters "Login failed" + 更换图片 \ No newline at end of file