选择地址添加新增模式
This commit is contained in:
parent
fe4c8a2beb
commit
2b8f38dd2f
@ -122,6 +122,12 @@
|
|||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:windowSoftInputMode="adjustPan|stateHidden" />
|
android:windowSoftInputMode="adjustPan|stateHidden" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".ui.address.AddressOnlyEditActivity"
|
||||||
|
android:configChanges="keyboardHidden|orientation|locale"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:windowSoftInputMode="adjustPan|stateHidden" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.home.activtiy.GoodsInfoActivity"
|
android:name=".ui.home.activtiy.GoodsInfoActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|locale"
|
android:configChanges="keyboardHidden|orientation|locale"
|
||||||
|
@ -67,35 +67,35 @@ data class PostAddressBean(
|
|||||||
}
|
}
|
||||||
|
|
||||||
data class AddressBean(
|
data class AddressBean(
|
||||||
val addressDetail: String,
|
var addressDetail: String,
|
||||||
var address: String,
|
var address: String,
|
||||||
val addressId: String,
|
var addressId: String,
|
||||||
val addressType: String,
|
var addressType: String,
|
||||||
val area: String,
|
var area: String,
|
||||||
val areaCode: String,
|
var areaCode: String,
|
||||||
val city: String,
|
var city: String,
|
||||||
val cityCode: String,
|
var cityCode: String,
|
||||||
val companyCode: String,
|
var companyCode: String,
|
||||||
val companyName: String,
|
var companyName: String,
|
||||||
var isPassingPoints: String,
|
var isPassingPoints: String,
|
||||||
val contactNumber: String,
|
var contactNumber: String,
|
||||||
val contactPerson: String,
|
var contactPerson: String,
|
||||||
val createBy: String,
|
var createBy: String,
|
||||||
val createTime: String,
|
var createTime: String,
|
||||||
val idCard: String,
|
var idCard: String,
|
||||||
val idDefault: String,
|
var idDefault: String,
|
||||||
val isDeleted: String,
|
var isDeleted: String,
|
||||||
val latitude: String,
|
var latitude: String,
|
||||||
val longitude: String,
|
var longitude: String,
|
||||||
val province: String,
|
var province: String,
|
||||||
val provinceCode: String,
|
var provinceCode: String,
|
||||||
val remark: String,
|
var remark: String,
|
||||||
val shipperId: String,
|
var shipperId: String,
|
||||||
val sortValue: String,
|
var sortValue: String,
|
||||||
val tagContent: String,
|
var tagContent: String,
|
||||||
val updateBy: String,
|
var updateBy: String,
|
||||||
val updateTime: String,
|
var updateTime: String,
|
||||||
val userType: String,
|
var userType: String,
|
||||||
var name: String,
|
var name: String,
|
||||||
var phone: String,
|
var phone: String,
|
||||||
var type: String //1装2卸
|
var type: String //1装2卸
|
||||||
|
@ -93,25 +93,6 @@ class AddressEditOrAddActivity : BaseActivity<ActivityAddressEditBinding>(),
|
|||||||
addressId = it.getString(AppConfig.ID,"")
|
addressId = it.getString(AppConfig.ID,"")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// var datas = mutableListOf<WayBillBean>(
|
|
||||||
// AddressBean(),
|
|
||||||
// AddressBean(),
|
|
||||||
// AddressBean()
|
|
||||||
// )
|
|
||||||
// binding.recycler.run {
|
|
||||||
// layoutManager = LinearLayoutManager(mContext, RecyclerView.VERTICAL, false)
|
|
||||||
// addItemDecoration(
|
|
||||||
// RecycleViewDivider(
|
|
||||||
// LinearLayout.VERTICAL,
|
|
||||||
// ConvertUtils.dp2px(14.0f),
|
|
||||||
// Color.TRANSPARENT
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
// adapter = SendGoodsAdapter()
|
|
||||||
// adapter as SendGoodsAdapter
|
|
||||||
// }.submitList(datas)
|
|
||||||
|
|
||||||
binding.run {
|
binding.run {
|
||||||
tvSSQ.setOnClickListener(OnLimitClickHelper(this@AddressEditOrAddActivity))
|
tvSSQ.setOnClickListener(OnLimitClickHelper(this@AddressEditOrAddActivity))
|
||||||
tvClear.setOnClickListener {
|
tvClear.setOnClickListener {
|
||||||
|
@ -0,0 +1,218 @@
|
|||||||
|
package com.dhsd.glowner.ui.address
|
||||||
|
|
||||||
|
import BaseObserver
|
||||||
|
import DataManager
|
||||||
|
import RxHttpCallBack
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Intent
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.text.TextUtils
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.widget.addTextChangedListener
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.dahe.gldriver.base.AppConfig
|
||||||
|
import com.dahe.glex.bean.WayBillBean
|
||||||
|
import com.dahe.mylibrary.base.BaseActivity
|
||||||
|
import com.dahe.mylibrary.net.CommonResponseBean
|
||||||
|
import com.dahe.mylibrary.recycleviewswipe.RecycleViewDivider
|
||||||
|
import com.dahe.mylibrary.utils.ActivityUtils
|
||||||
|
import com.dahe.mylibrary.utils.ConvertUtils
|
||||||
|
import com.dahe.mylibrary.utils.PickerUtils
|
||||||
|
import com.dahe.mylibrary.utils.ToastUtils
|
||||||
|
import com.dahe.mylibrary.weight.SwitchView
|
||||||
|
import com.dhsd.glowner.R
|
||||||
|
import com.dhsd.glowner.adapter.SendGoodsAdapter
|
||||||
|
import com.dhsd.glowner.bean.AddressBean
|
||||||
|
import com.dhsd.glowner.bean.PostAddressBean
|
||||||
|
import com.dhsd.glowner.databinding.ActivityAddressEditBinding
|
||||||
|
import com.dhsd.glowner.ui.mine.activity.ChoiceCarActivity
|
||||||
|
import com.dhsd.glowner.utils.OnLimitClickHelper
|
||||||
|
import com.dhsd.glowner.utils.OnLimitClickListener
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||||
|
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName AddresEditActivity
|
||||||
|
* @Author john
|
||||||
|
* @Date 2024/2/4 10:44
|
||||||
|
* @Description 新增装卸货地址或编辑->不保存数据库
|
||||||
|
*/
|
||||||
|
class AddressOnlyEditActivity : BaseActivity<ActivityAddressEditBinding>(),
|
||||||
|
OnLimitClickListener {
|
||||||
|
private lateinit var addressBean: AddressBean
|
||||||
|
|
||||||
|
private val launcher =
|
||||||
|
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||||
|
if (result.resultCode == AppCompatActivity.RESULT_OK) {
|
||||||
|
result.data?.extras?.let {
|
||||||
|
val postBean = it.getString(AppConfig.BEAN)
|
||||||
|
if (postBean != null) {
|
||||||
|
val inAddressBean = Gson().fromJson(postBean, PostAddressBean::class.java)
|
||||||
|
val inAreaCode = inAddressBean.areaCode
|
||||||
|
inAddressBean.run {
|
||||||
|
provinceCode = inAreaCode.subSequence(0, 3).toString().plus("000")
|
||||||
|
cityCode = inAreaCode.subSequence(0, 4).toString().plus("00")
|
||||||
|
}
|
||||||
|
|
||||||
|
addressBean?.run {
|
||||||
|
addressDetail = inAddressBean.addressDetail
|
||||||
|
areaCode = inAddressBean.areaCode
|
||||||
|
area = inAddressBean.area
|
||||||
|
city = inAddressBean.city
|
||||||
|
province = inAddressBean.province
|
||||||
|
provinceCode = inAddressBean.provinceCode
|
||||||
|
cityCode = inAddressBean.cityCode
|
||||||
|
contactPerson = inAddressBean.contactPerson
|
||||||
|
contactNumber = inAddressBean.contactNumber
|
||||||
|
idCard = inAddressBean.idCard
|
||||||
|
}
|
||||||
|
|
||||||
|
initViewByData(addressBean)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun initView(savedInstanceState: Bundle?) {
|
||||||
|
setStatusBarColor(R.color.white)
|
||||||
|
setTitleBar("地址信息", { finish() }, true, "地图选点") {
|
||||||
|
launcher.launch(Intent(mContext, ChoiceAddressByMapActivity::class.java))
|
||||||
|
}
|
||||||
|
|
||||||
|
intent.extras?.let {
|
||||||
|
val string = it.getString(AppConfig.BEAN, "")
|
||||||
|
addressBean = Gson().fromJson(string, AddressBean::class.java)
|
||||||
|
if (::addressBean.isInitialized&&!TextUtils.isEmpty(addressBean.addressDetail)){
|
||||||
|
initViewByData(addressBean)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.run {
|
||||||
|
tvSSQ.setOnClickListener(OnLimitClickHelper(this@AddressOnlyEditActivity))
|
||||||
|
tvClear.setOnClickListener {
|
||||||
|
etAddressDetail.setText("")
|
||||||
|
if (::addressBean.isInitialized && addressBean.addressDetail.isNotEmpty()) {
|
||||||
|
addressBean.addressDetail = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
btnOk.setOnClickListener(OnLimitClickHelper(this@AddressOnlyEditActivity))
|
||||||
|
|
||||||
|
etAddressDetail.addTextChangedListener { text ->
|
||||||
|
// if (text?.length != 0) {
|
||||||
|
// val inputquery = InputtipsQuery(text, "")
|
||||||
|
// val inputTips = Inputtips(this, inputquery)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
mySwitch.setOnStateChangedListener2 {
|
||||||
|
changeAddressType(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onClick(view: View?) {
|
||||||
|
super.onClick(view)
|
||||||
|
when (view?.id) {
|
||||||
|
R.id.tvSSQ -> {
|
||||||
|
PickerUtils.getInstance().showAddress(
|
||||||
|
this
|
||||||
|
) { province, city, county ->
|
||||||
|
binding.tvSSQ.text = """${province.name}-${city.name}-${county.name}"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
R.id.btnOk -> {
|
||||||
|
submit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun initDate() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增或编辑地址信息
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private fun submit() {
|
||||||
|
|
||||||
|
if (!::addressBean.isInitialized || addressBean.province.isEmpty()) {
|
||||||
|
showToast("请选择省市区")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (addressBean.addressDetail.isEmpty()) {
|
||||||
|
showToast("请输入详细地址")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (binding.etName.text.isEmpty() || binding.etPhone.text.isEmpty() || binding.etCom.text.isEmpty() || binding.etComNum.text.isEmpty()) {
|
||||||
|
showToast("请完善联系人信息")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
addressBean.run {
|
||||||
|
binding.run {
|
||||||
|
contactPerson = etName.text.toString()
|
||||||
|
contactNumber = etPhone.text.toString()
|
||||||
|
userType = if (mySwitch.isOpened) "1" else "0"
|
||||||
|
companyName = etCom.text.toString()
|
||||||
|
companyCode = etComNum.text.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setResult(Activity.RESULT_OK,Intent().apply {
|
||||||
|
putExtras(Bundle().apply {
|
||||||
|
putString(AppConfig.BEAN, Gson().toJson(addressBean))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun changeAddressType(isCom: Boolean) {
|
||||||
|
if (isCom) {
|
||||||
|
binding.run {
|
||||||
|
etCom.hint = "公司名称"
|
||||||
|
etComNum.hint = "社会统一代码"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
binding.run {
|
||||||
|
etCom.hint = "货主名称"
|
||||||
|
etComNum.hint = "身份证号"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渲染页面
|
||||||
|
* @param data PostAddressBean
|
||||||
|
*/
|
||||||
|
private fun initViewByData(data: AddressBean?) {
|
||||||
|
data?.run {
|
||||||
|
binding.run {
|
||||||
|
binding.run {
|
||||||
|
tvSSQ.text =
|
||||||
|
"""${data.province}-${data.city}-${data.area}"""
|
||||||
|
etAddressDetail.setText(data.addressDetail)
|
||||||
|
etName.setText(data.contactPerson)
|
||||||
|
etPhone.setText(data.contactNumber)
|
||||||
|
etCom.setText(data.companyName)
|
||||||
|
etComNum.setText(if (data.userType == "1") data.companyCode else data.idCard)
|
||||||
|
etComNum.hint = if (data.userType == "1") "社会统一代码" else "身份证号"
|
||||||
|
mySwitch.isOpened = data.userType == "1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ package com.dhsd.glowner.ui.address
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.text.TextUtils
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.widget.addTextChangedListener
|
import androidx.core.widget.addTextChangedListener
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
@ -68,9 +69,11 @@ class ChoiceAddressByMapActivity : BaseActivity<ActivityChoiceAddressByMapBindin
|
|||||||
) {
|
) {
|
||||||
super.onRegeocodeSearched(result, rCode)
|
super.onRegeocodeSearched(result, rCode)
|
||||||
result?.let {
|
result?.let {
|
||||||
|
|
||||||
|
|
||||||
val postAddressBean = PostAddressBean(
|
val postAddressBean = PostAddressBean(
|
||||||
it.regeocodeAddress.province,
|
it.regeocodeAddress.province,
|
||||||
it.regeocodeAddress.city,
|
if (TextUtils.isEmpty(it.regeocodeAddress.city)) it.regeocodeAddress.district else it.regeocodeAddress.city,
|
||||||
it.regeocodeAddress.district,
|
it.regeocodeAddress.district,
|
||||||
it.regeocodeAddress.adCode,
|
it.regeocodeAddress.adCode,
|
||||||
it.regeocodeQuery.point.latitude.toString(),
|
it.regeocodeQuery.point.latitude.toString(),
|
||||||
|
@ -27,7 +27,9 @@ import com.dhsd.glowner.adapter.SendGoodsAdapter
|
|||||||
import com.dhsd.glowner.bean.AddressBean
|
import com.dhsd.glowner.bean.AddressBean
|
||||||
import com.dhsd.glowner.bean.GoodBean
|
import com.dhsd.glowner.bean.GoodBean
|
||||||
import com.dhsd.glowner.databinding.ActivitySendGoodsBinding
|
import com.dhsd.glowner.databinding.ActivitySendGoodsBinding
|
||||||
|
import com.dhsd.glowner.ui.address.AddressEditOrAddActivity
|
||||||
import com.dhsd.glowner.ui.address.AddressListActivity
|
import com.dhsd.glowner.ui.address.AddressListActivity
|
||||||
|
import com.dhsd.glowner.ui.address.AddressOnlyEditActivity
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||||
@ -55,7 +57,7 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
|||||||
isMul = it.getBoolean(AppConfig.IS_MUL, false)
|
isMul = it.getBoolean(AppConfig.IS_MUL, false)
|
||||||
}
|
}
|
||||||
setStatusBarColor(R.color.white)
|
setStatusBarColor(R.color.white)
|
||||||
setTitleBar( if (isMul) "一装多卸" else "普通装货", true)
|
setTitleBar(if (isMul) "一装多卸" else "普通装货", true)
|
||||||
|
|
||||||
binding.run {
|
binding.run {
|
||||||
llAdd.visibility = if (isMul) View.VISIBLE else View.GONE
|
llAdd.visibility = if (isMul) View.VISIBLE else View.GONE
|
||||||
@ -264,7 +266,19 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
|||||||
adapter as SendGoodsAdapter
|
adapter as SendGoodsAdapter
|
||||||
}.apply {
|
}.apply {
|
||||||
isStateViewEnable = true
|
isStateViewEnable = true
|
||||||
setOnItemClickListener { adapter, view, position ->
|
|
||||||
|
addOnItemChildClickListener(R.id.llContent) { adapter, _, position ->
|
||||||
|
ActivityUtils.startActivityForResult(
|
||||||
|
this@SendGoodsActivity,
|
||||||
|
AddressOnlyEditActivity::class.java,
|
||||||
|
Bundle().apply {
|
||||||
|
putString(AppConfig.BEAN, Gson().toJson(adapter.items[position]))
|
||||||
|
},
|
||||||
|
position
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
addOnItemChildClickListener(R.id.tvSelAddress) { _, _, position ->
|
||||||
ActivityUtils.startActivityForResult(
|
ActivityUtils.startActivityForResult(
|
||||||
this@SendGoodsActivity,
|
this@SendGoodsActivity,
|
||||||
AddressListActivity::class.java,
|
AddressListActivity::class.java,
|
||||||
@ -275,6 +289,8 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
|||||||
addOnItemChildClickListener(R.id.tvDel) { adapter, _, position ->
|
addOnItemChildClickListener(R.id.tvDel) { adapter, _, position ->
|
||||||
adapter.removeAt(position)
|
adapter.removeAt(position)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
adapter.submitList(datas)
|
adapter.submitList(datas)
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
android:padding="@dimen/dp_11">
|
android:padding="@dimen/dp_11">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/llContent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
@ -35,7 +36,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:hint="请选择详细地址"
|
android:hint="请填写详细地址"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/sp_16" />
|
android:textSize="@dimen/sp_16" />
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user