车辆行驶证新增编辑添加查看大图,以及优化更换图片功能

This commit is contained in:
lijia 2024-06-26 09:42:30 +08:00
parent ec0a0c2902
commit 69e803d48b
4 changed files with 228 additions and 59 deletions

View File

@ -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<ActivityAuthDrivingBinding>() {
}
}
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<ActivityAuthDrivingBinding>() {
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<ActivityAuthDrivingBinding>() {
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<ActivityAuthDrivingBinding>() {
}
}
// 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() ||

View File

@ -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<ActivityAuthDrivingBinding>() {
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<ActivityAuthDrivingBinding>() {
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<ActivityAuthDrivingBinding>() {
}
}
tvCarColor.setOnClickListener {
DicUtils.getInstance()
.getCarColor(mContext, this@EditDrivingActivity) { position, item ->
@ -146,10 +154,10 @@ class EditDrivingActivity : BaseActivity<ActivityAuthDrivingBinding>() {
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<ActivityAuthDrivingBinding>() {
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<ActivityAuthDrivingBinding>() {
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<ActivityAuthDrivingBinding>() {
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<ActivityAuthDrivingBinding>() {
//车长
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<ActivityAuthDrivingBinding>() {
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<ActivityAuthDrivingBinding>() {
owner = binding.etOwner.text.trim().toString()
useNature = binding.etUseNature.text.trim().toString()
}
if(upDrivingInfoBean.vehicleNum.contains("")){
if (upDrivingInfoBean.vehicleNum.contains("")) {
showToast("车牌号码不合规")
return
}

View File

@ -37,7 +37,7 @@
<androidx.cardview.widget.CardView
android:id="@+id/cdPerson"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_174"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_30"
@ -47,10 +47,12 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal">
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingBottom="@dimen/dp_18">
<TextView
android:id="@+id/tvDriverTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_14"
@ -59,32 +61,57 @@
android:textColor="@color/black"
android:textSize="@dimen/sp_16"></TextView>
<ImageView
android:id="@+id/ivFront"
android:layout_width="@dimen/dp_155"
android:layout_height="@dimen/dp_97"
android:layout_alignParentBottom="true"
android:layout_below="@+id/tvDriverTitle"
android:layout_marginLeft="@dimen/dp_8"
android:layout_marginBottom="@dimen/dp_22"
android:layout_marginTop="@dimen/dp_20"
android:background="@drawable/driving_front"></ImageView>
<TextView
android:id="@+id/tvChangeFront"
android:layout_width="@dimen/dp_155"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="right"
android:paddingBottom="@dimen/dp_4"
android:text="@string/change_pic"
android:textColor="@color/main_red"
android:textStyle="bold"
android:visibility="gone" />
<ImageView
android:id="@+id/ivBack"
android:layout_width="@dimen/dp_155"
android:layout_height="@dimen/dp_97"
android:layout_alignTop="@+id/ivFront"
android:layout_alignParentRight="true"
android:layout_marginRight="@dimen/dp_8"
android:background="@drawable/driving_back"></ImageView>
<TextView
android:id="@+id/tvChangeBack"
android:layout_width="@dimen/dp_155"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="@dimen/dp_8"
android:layout_marginBottom="@dimen/dp_22"
android:background="@drawable/driving_back"></ImageView>
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" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="@dimen/dp_174"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_12"
@ -95,9 +122,11 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal">
android:layout_gravity="center_horizontal"
android:paddingBottom="@dimen/dp_18">
<TextView
android:id="@+id/tvCarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_14"
@ -111,12 +140,26 @@
android:id="@+id/ivCar"
android:layout_width="@dimen/dp_155"
android:layout_height="@dimen/dp_97"
android:layout_alignParentBottom="true"
android:layout_below="@+id/tvCarTitle"
android:layout_centerHorizontal="true"
android:layout_marginLeft="@dimen/dp_12"
android:layout_marginBottom="@dimen/dp_22"
android:layout_marginTop="@dimen/dp_20"
android:background="@drawable/car_photo"></ImageView>
<TextView
android:id="@+id/tvChangeCar"
android:layout_width="@dimen/dp_155"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_12"
android:gravity="right"
android:paddingRight="@dimen/dp_4"
android:paddingBottom="@dimen/dp_4"
android:text="@string/change_pic"
android:textColor="@color/main_red"
android:textSize="@dimen/dp_16"
android:visibility="gone" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
@ -218,8 +261,8 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="@dimen/dp_100"
android:drawableLeft="@drawable/start"
android:maxWidth="@dimen/dp_100"
android:text="车辆所有人"
android:textColor="@color/black"
android:textSize="@dimen/sp_15"></TextView>
@ -238,6 +281,7 @@
android:textSize="@dimen/sp_15"
tools:text="王海生"></EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -247,9 +291,9 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/start"
android:maxWidth="@dimen/dp_100"
android:text="使用性质"
android:drawableLeft="@drawable/start"
android:textColor="@color/black"
android:textSize="@dimen/sp_15"></TextView>
@ -307,9 +351,9 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="有效期至"
android:drawableLeft="@drawable/start"
android:drawablePadding="@dimen/dp_2"
android:text="有效期至"
android:textColor="@color/black"
android:textSize="@dimen/sp_15"></TextView>
@ -325,16 +369,15 @@
android:hint="请选择有效期至"
android:paddingLeft="@dimen/dp_10"
android:textColor="@color/black"
android:textSize="@dimen/sp_15"
></TextView>
android:textSize="@dimen/sp_15"></TextView>
</LinearLayout>
<LinearLayout
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_14"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
@ -358,12 +401,13 @@
android:textSize="@dimen/sp_15"
tools:text="王海生"></EditText>
</LinearLayout>
<LinearLayout
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_14"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
@ -393,10 +437,9 @@
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="@dimen/dp_174"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_12"
@ -407,9 +450,11 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal">
android:layout_gravity="center_horizontal"
android:paddingBottom="@dimen/dp_18">
<TextView
android:id="@+id/tvRoadTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_14"
@ -423,23 +468,37 @@
android:id="@+id/ivRoadFront"
android:layout_width="@dimen/dp_155"
android:layout_height="@dimen/dp_97"
android:layout_alignParentBottom="true"
android:layout_below="@+id/tvRoadTitle"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/dp_22"
android:layout_marginTop="@dimen/dp_20"
android:background="@drawable/road" />
<TextView
android:id="@+id/tvChangeRoad"
android:layout_width="@dimen/dp_155"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_12"
android:gravity="right"
android:paddingRight="@dimen/dp_4"
android:paddingBottom="@dimen/dp_4"
android:text="@string/change_pic"
android:textColor="@color/main_red"
android:textSize="@dimen/dp_16"
android:visibility="gone" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_15"
android:visibility="gone"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="@dimen/dp_8">

View File

@ -9,4 +9,5 @@
<string name="invalid_username">Not a valid username</string>
<string name="invalid_password">Password must be >5 characters</string>
<string name="login_failed">"Login failed"</string>
<string name="change_pic">更换图片</string>
</resources>