货主地址新增以及编辑
This commit is contained in:
parent
9642fe44f0
commit
9ab96216c3
@ -10,6 +10,7 @@ object AppConfig {
|
|||||||
const val BUGLY_APP_ID = "a5b894cef7"
|
const val BUGLY_APP_ID = "a5b894cef7"
|
||||||
const val TIME = "DA_HE_TIME"
|
const val TIME = "DA_HE_TIME"
|
||||||
const val ID = "DA_HE_ID"
|
const val ID = "DA_HE_ID"
|
||||||
|
const val BEAN = "DA_HE_BEAN"
|
||||||
const val IS_ADD = "DA_HE_IS_ADD"
|
const val IS_ADD = "DA_HE_IS_ADD"
|
||||||
const val CAPTAIN_ID = "CAPTAIN_ID"
|
const val CAPTAIN_ID = "CAPTAIN_ID"
|
||||||
const val PWD = "DA_HE_PHONE"
|
const val PWD = "DA_HE_PHONE"
|
||||||
|
@ -6,27 +6,72 @@ package com.dhsd.glowner.bean
|
|||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
data class PostAddressBean(
|
data class PostAddressBean(
|
||||||
val addressDetail: String,
|
var province: String = "",
|
||||||
val addressType: String,
|
var city: String = "",
|
||||||
val area: String,
|
var area: String = "",
|
||||||
val areaCode: String,
|
var areaCode: String = "",
|
||||||
val city: String,
|
var latitude: String = "",
|
||||||
val cityCode: String,
|
var longitude: String = "",
|
||||||
val companyCode: String,
|
var addressDetail: String = ""
|
||||||
val companyName: String,
|
) {
|
||||||
val contactNumber: String,
|
var addressType: String = ""
|
||||||
val contactPerson: String,
|
var cityCode: String = ""
|
||||||
val idCard: Any,
|
var companyCode: String = ""
|
||||||
val idDefault: String,
|
var companyName: String = ""
|
||||||
val isDeleted: String,
|
var contactNumber: String = ""
|
||||||
val latitude: String,
|
var contactPerson: String = ""
|
||||||
val longitude: String,
|
var idCard: String = ""
|
||||||
val province: String,
|
var idDefault: String = ""
|
||||||
val provinceCode: String,
|
var isDeleted: String = ""
|
||||||
val sortValue: String,
|
var provinceCode: String = ""
|
||||||
val tagContent: String,
|
var sortValue: String = ""
|
||||||
val userType: String
|
var tagContent: String = ""
|
||||||
)
|
var userType: String = ""
|
||||||
|
var addressId: String = ""
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
province: String,
|
||||||
|
city: String,
|
||||||
|
area: String,
|
||||||
|
areaCode: String,
|
||||||
|
latitude: String,
|
||||||
|
longitude: String,
|
||||||
|
addressDetail: String,
|
||||||
|
addressType: String,
|
||||||
|
cityCode: String,
|
||||||
|
companyCode: String,
|
||||||
|
companyName: String,
|
||||||
|
contactNumber: String,
|
||||||
|
contactPerson: String,
|
||||||
|
idCard: String,
|
||||||
|
idDefault: String,
|
||||||
|
isDeleted: String,
|
||||||
|
provinceCode: String,
|
||||||
|
sortValue: String,
|
||||||
|
tagContent: String,
|
||||||
|
userType: String,
|
||||||
|
addressId: String
|
||||||
|
) : this(province, city, area, areaCode, latitude, longitude, addressDetail) {
|
||||||
|
this.addressType = addressType
|
||||||
|
this.cityCode = cityCode
|
||||||
|
this.companyCode = companyCode
|
||||||
|
this.companyName = companyName
|
||||||
|
this.contactNumber = contactNumber
|
||||||
|
this.contactPerson = contactPerson
|
||||||
|
this.idCard = idCard
|
||||||
|
this.idDefault = idDefault
|
||||||
|
this.isDeleted = isDeleted
|
||||||
|
this.provinceCode = provinceCode
|
||||||
|
this.sortValue = sortValue
|
||||||
|
this.tagContent = tagContent
|
||||||
|
this.userType = userType
|
||||||
|
this.addressId = addressId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data class Texfff(val name: String, val age: Int) {
|
||||||
|
constructor(name: String, age: Int, id: String) : this(name, age) {}
|
||||||
|
}
|
||||||
|
|
||||||
data class AddressBean(
|
data class AddressBean(
|
||||||
val addressDetail: String,
|
val addressDetail: String,
|
||||||
|
@ -11,6 +11,7 @@ import retrofit2.http.Body
|
|||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
import retrofit2.http.POST
|
import retrofit2.http.POST
|
||||||
import retrofit2.http.PUT
|
import retrofit2.http.PUT
|
||||||
|
import retrofit2.http.Path
|
||||||
import retrofit2.http.Query
|
import retrofit2.http.Query
|
||||||
|
|
||||||
|
|
||||||
@ -101,6 +102,28 @@ interface Api {
|
|||||||
@POST(BASE_URL+"devApi/business/shipper/common/address")
|
@POST(BASE_URL+"devApi/business/shipper/common/address")
|
||||||
fun postAddress(@Body bean: PostAddressBean): Observable<CommonResponseBean<Any>>
|
fun postAddress(@Body bean: PostAddressBean): Observable<CommonResponseBean<Any>>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取地址详情
|
||||||
|
* @param addressId String
|
||||||
|
* @return Observable<CommonResponseBean<PostAddressBean>>
|
||||||
|
*/
|
||||||
|
@GET(BASE_URL+"devApi/business/shipper/common/address/{addressId}")
|
||||||
|
fun getAddressDetail(@Path("addressId") addressId:String) : Observable<CommonResponseBean<PostAddressBean>>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改货主常用地址
|
||||||
|
* @param bean PostAddressBean
|
||||||
|
* @return Observable<CommonResponseBean<Any>>
|
||||||
|
*/
|
||||||
|
@PUT(BASE_URL+"devApi/business/shipper/common/address")
|
||||||
|
fun updateAddress(@Body bean: PostAddressBean): Observable<CommonResponseBean<Any>>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取地址列表
|
||||||
|
* @return Observable<CommonResponseBean<OrderListBean<AddressBean>>>
|
||||||
|
*/
|
||||||
@GET(BASE_URL+"devApi/business/shipper/common/address/list")
|
@GET(BASE_URL+"devApi/business/shipper/common/address/list")
|
||||||
fun getAddressList(): Observable<CommonResponseBean<OrderListBean<AddressBean>>>
|
fun getAddressList(): Observable<CommonResponseBean<OrderListBean<AddressBean>>>
|
||||||
}
|
}
|
@ -1,25 +1,39 @@
|
|||||||
package com.dhsd.glowner.ui.address
|
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.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
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
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.dahe.gldriver.base.AppConfig
|
import com.dahe.gldriver.base.AppConfig
|
||||||
import com.dahe.glex.bean.WayBillBean
|
import com.dahe.glex.bean.WayBillBean
|
||||||
import com.dahe.mylibrary.base.BaseActivity
|
import com.dahe.mylibrary.base.BaseActivity
|
||||||
|
import com.dahe.mylibrary.net.CommonResponseBean
|
||||||
import com.dahe.mylibrary.recycleviewswipe.RecycleViewDivider
|
import com.dahe.mylibrary.recycleviewswipe.RecycleViewDivider
|
||||||
import com.dahe.mylibrary.utils.ActivityUtils
|
import com.dahe.mylibrary.utils.ActivityUtils
|
||||||
import com.dahe.mylibrary.utils.ConvertUtils
|
import com.dahe.mylibrary.utils.ConvertUtils
|
||||||
import com.dahe.mylibrary.utils.PickerUtils
|
import com.dahe.mylibrary.utils.PickerUtils
|
||||||
import com.dahe.mylibrary.utils.ToastUtils
|
import com.dahe.mylibrary.utils.ToastUtils
|
||||||
|
import com.dahe.mylibrary.weight.SwitchView
|
||||||
import com.dhsd.glowner.R
|
import com.dhsd.glowner.R
|
||||||
import com.dhsd.glowner.adapter.SendGoodsAdapter
|
import com.dhsd.glowner.adapter.SendGoodsAdapter
|
||||||
|
import com.dhsd.glowner.bean.PostAddressBean
|
||||||
import com.dhsd.glowner.databinding.ActivityAddressEditBinding
|
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.OnLimitClickHelper
|
||||||
import com.dhsd.glowner.utils.OnLimitClickListener
|
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
|
* @ClassName AddresEditActivity
|
||||||
@ -29,14 +43,51 @@ import com.dhsd.glowner.utils.OnLimitClickListener
|
|||||||
*/
|
*/
|
||||||
class AddressEditOrAddActivity : BaseActivity<ActivityAddressEditBinding>(),
|
class AddressEditOrAddActivity : BaseActivity<ActivityAddressEditBinding>(),
|
||||||
OnLimitClickListener {
|
OnLimitClickListener {
|
||||||
private var isAdd:Boolean = true
|
|
||||||
|
private lateinit var postAddressBean: PostAddressBean
|
||||||
|
private var addressId: String = ""
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
if (addressId.isEmpty()){
|
||||||
|
postAddressBean = inAddressBean
|
||||||
|
}else{
|
||||||
|
postAddressBean?.run {
|
||||||
|
addressDetail = inAddressBean.addressDetail
|
||||||
|
areaCode = inAddressBean.areaCode
|
||||||
|
area = inAddressBean.area
|
||||||
|
city = inAddressBean.city
|
||||||
|
province = inAddressBean.province
|
||||||
|
contactPerson = inAddressBean.contactPerson
|
||||||
|
contactNumber = inAddressBean.contactNumber
|
||||||
|
idCard = inAddressBean.idCard
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
initViewByData(postAddressBean)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun initView(savedInstanceState: Bundle?) {
|
override fun initView(savedInstanceState: Bundle?) {
|
||||||
setStatusBarColor(R.color.white)
|
setStatusBarColor(R.color.white)
|
||||||
setTitleBar("地址信息", { finish() }, true, "地图选点") {
|
setTitleBar("地址信息", { finish() }, true, "地图选点") {
|
||||||
ActivityUtils.startActivity(mContext,ChoiceAddressByMapActivity::class.java)
|
launcher.launch(Intent(mContext, ChoiceAddressByMapActivity::class.java))
|
||||||
}
|
}
|
||||||
|
addressId = intent.extras?.getString(AppConfig.ID, "").toString()
|
||||||
|
|
||||||
isAdd = intent.extras?.getBoolean(AppConfig.IS_ADD,true) == true
|
|
||||||
|
|
||||||
var datas = mutableListOf<WayBillBean>(
|
var datas = mutableListOf<WayBillBean>(
|
||||||
WayBillBean(),
|
WayBillBean(),
|
||||||
@ -44,7 +95,7 @@ class AddressEditOrAddActivity : BaseActivity<ActivityAddressEditBinding>(),
|
|||||||
WayBillBean()
|
WayBillBean()
|
||||||
)
|
)
|
||||||
binding.recycler.run {
|
binding.recycler.run {
|
||||||
layoutManager = LinearLayoutManager(mContext,RecyclerView.VERTICAL,false)
|
layoutManager = LinearLayoutManager(mContext, RecyclerView.VERTICAL, false)
|
||||||
addItemDecoration(
|
addItemDecoration(
|
||||||
RecycleViewDivider(
|
RecycleViewDivider(
|
||||||
LinearLayout.VERTICAL,
|
LinearLayout.VERTICAL,
|
||||||
@ -58,7 +109,12 @@ class AddressEditOrAddActivity : BaseActivity<ActivityAddressEditBinding>(),
|
|||||||
|
|
||||||
binding.run {
|
binding.run {
|
||||||
tvSSQ.setOnClickListener(OnLimitClickHelper(this@AddressEditOrAddActivity))
|
tvSSQ.setOnClickListener(OnLimitClickHelper(this@AddressEditOrAddActivity))
|
||||||
tvClear.setOnClickListener { etAddressDetail.setText("") }
|
tvClear.setOnClickListener {
|
||||||
|
etAddressDetail.setText("")
|
||||||
|
if (::postAddressBean.isInitialized && postAddressBean.addressDetail.isNotEmpty()) {
|
||||||
|
postAddressBean.addressDetail = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
btnOk.setOnClickListener(OnLimitClickHelper(this@AddressEditOrAddActivity))
|
btnOk.setOnClickListener(OnLimitClickHelper(this@AddressEditOrAddActivity))
|
||||||
|
|
||||||
etAddressDetail.addTextChangedListener { text ->
|
etAddressDetail.addTextChangedListener { text ->
|
||||||
@ -67,6 +123,11 @@ class AddressEditOrAddActivity : BaseActivity<ActivityAddressEditBinding>(),
|
|||||||
// val inputTips = Inputtips(this, inputquery)
|
// val inputTips = Inputtips(this, inputquery)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mySwitch.setOnStateChangedListener2 {
|
||||||
|
changeAddressType(it)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -76,17 +137,124 @@ class AddressEditOrAddActivity : BaseActivity<ActivityAddressEditBinding>(),
|
|||||||
super.onClick(view)
|
super.onClick(view)
|
||||||
when (view?.id) {
|
when (view?.id) {
|
||||||
R.id.tvSSQ -> {
|
R.id.tvSSQ -> {
|
||||||
PickerUtils.getInstance().showAddress(this
|
PickerUtils.getInstance().showAddress(
|
||||||
|
this
|
||||||
) { province, city, county ->
|
) { province, city, county ->
|
||||||
binding.tvSSQ.text = """${province.name}-${city.name}-${county.name}"""
|
binding.tvSSQ.text = """${province.name}-${city.name}-${county.name}"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
R.id.btnOk->{
|
|
||||||
|
R.id.btnOk -> {
|
||||||
|
submit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initDate() {
|
override fun initDate() {
|
||||||
|
if (addressId.isNotEmpty()) {
|
||||||
|
DataManager.getInstance().getAddressDetail(addressId)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(BaseObserver(mContext, object : RxHttpCallBack<PostAddressBean>() {
|
||||||
|
override fun onSuccess(t: CommonResponseBean<PostAddressBean>) {
|
||||||
|
super.onSuccess(t)
|
||||||
|
initViewByData(t.data)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增或编辑地址信息
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private fun submit() {
|
||||||
|
|
||||||
|
if (!::postAddressBean.isInitialized || postAddressBean.province.isEmpty()) {
|
||||||
|
showToast("请选择省市区")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (postAddressBean.addressDetail.isEmpty()) {
|
||||||
|
showToast("请输入详细地址")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (binding.etName.text.isEmpty() || binding.etPhone.text.isEmpty() || binding.etCom.text.isEmpty() || binding.etComNum.text.isEmpty()) {
|
||||||
|
showToast("请完善联系人信息")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
postAddressBean.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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addressId.isNotEmpty()) {
|
||||||
|
DataManager.getInstance().updateAddress(postAddressBean)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(BaseObserver(mContext, object : RxHttpCallBack<Any>() {
|
||||||
|
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||||
|
super.onSuccess(t)
|
||||||
|
showToast(t.msg)
|
||||||
|
setResult(Activity.RESULT_OK)
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
} else {
|
||||||
|
DataManager.getInstance().postAddress(postAddressBean)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(BaseObserver(mContext, object : RxHttpCallBack<Any>() {
|
||||||
|
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||||
|
super.onSuccess(t)
|
||||||
|
showToast(t.msg)
|
||||||
|
setResult(Activity.RESULT_OK)
|
||||||
|
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: PostAddressBean) {
|
||||||
|
postAddressBean = data
|
||||||
|
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(data.companyCode)
|
||||||
|
mySwitch.isOpened = data.userType == "1"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,15 +3,19 @@ package com.dhsd.glowner.ui.address
|
|||||||
import BaseObserver
|
import BaseObserver
|
||||||
import DataManager
|
import DataManager
|
||||||
import RxHttpCallBack
|
import RxHttpCallBack
|
||||||
|
import android.content.Intent
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.dahe.gldriver.base.AppConfig
|
import com.dahe.gldriver.base.AppConfig
|
||||||
import com.dahe.glex.bean.OrderListBean
|
import com.dahe.glex.bean.OrderListBean
|
||||||
import com.dahe.mylibrary.base.BaseActivity
|
import com.dahe.mylibrary.base.BaseActivity
|
||||||
|
import com.dahe.mylibrary.callback.RefreshCallBack
|
||||||
import com.dahe.mylibrary.net.CommonResponseBean
|
import com.dahe.mylibrary.net.CommonResponseBean
|
||||||
import com.dahe.mylibrary.recycleviewswipe.RecycleViewDivider
|
import com.dahe.mylibrary.recycleviewswipe.RecycleViewDivider
|
||||||
import com.dahe.mylibrary.utils.ActivityUtils
|
import com.dahe.mylibrary.utils.ActivityUtils
|
||||||
@ -20,6 +24,7 @@ import com.dhsd.glowner.R
|
|||||||
import com.dhsd.glowner.adapter.AddressAdapter
|
import com.dhsd.glowner.adapter.AddressAdapter
|
||||||
import com.dhsd.glowner.bean.AddressBean
|
import com.dhsd.glowner.bean.AddressBean
|
||||||
import com.dhsd.glowner.databinding.ActivityAddressListBinding
|
import com.dhsd.glowner.databinding.ActivityAddressListBinding
|
||||||
|
import com.dhsd.glowner.ui.mine.activity.ChoiceCarActivity
|
||||||
import com.dhsd.glowner.utils.OnLimitClickHelper
|
import com.dhsd.glowner.utils.OnLimitClickHelper
|
||||||
import com.dhsd.glowner.utils.OnLimitClickListener
|
import com.dhsd.glowner.utils.OnLimitClickListener
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||||
@ -32,13 +37,21 @@ import io.reactivex.rxjava3.schedulers.Schedulers
|
|||||||
* @Description 地址列表
|
* @Description 地址列表
|
||||||
*/
|
*/
|
||||||
class AddressListActivity : BaseActivity<ActivityAddressListBinding>(),
|
class AddressListActivity : BaseActivity<ActivityAddressListBinding>(),
|
||||||
OnLimitClickListener {
|
OnLimitClickListener , RefreshCallBack {
|
||||||
|
|
||||||
|
private val launcher =
|
||||||
|
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||||
|
if (result.resultCode == AppCompatActivity.RESULT_OK) {
|
||||||
|
initDate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lateinit var adapter: AddressAdapter
|
lateinit var adapter: AddressAdapter
|
||||||
override fun initView(savedInstanceState: Bundle?) {
|
override fun initView(savedInstanceState: Bundle?) {
|
||||||
setStatusBarColor(R.color.white)
|
setStatusBarColor(R.color.white)
|
||||||
setTitleBar("地址", true)
|
setTitleBar("地址", true)
|
||||||
binding.run {
|
binding.run {
|
||||||
|
setRefresh(smartRefresh, this@AddressListActivity)
|
||||||
adapter = recycler.run {
|
adapter = recycler.run {
|
||||||
layoutManager = LinearLayoutManager(mContext, RecyclerView.VERTICAL, false)
|
layoutManager = LinearLayoutManager(mContext, RecyclerView.VERTICAL, false)
|
||||||
addItemDecoration(
|
addItemDecoration(
|
||||||
@ -59,6 +72,14 @@ class AddressListActivity : BaseActivity<ActivityAddressListBinding>(),
|
|||||||
// adapter.getItem(position)?.isSelect = true
|
// adapter.getItem(position)?.isSelect = true
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addOnItemChildClickListener(R.id.tvEdit){ adapter,_, position ->
|
||||||
|
val addressBean = adapter.items[position]
|
||||||
|
|
||||||
|
launcher.launch(Intent(mContext, AddressEditOrAddActivity::class.java).apply {
|
||||||
|
putExtras(Bundle().apply { putString(AppConfig.ID, addressBean.addressId) })
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
btnOk.setOnClickListener(OnLimitClickHelper(this@AddressListActivity))
|
btnOk.setOnClickListener(OnLimitClickHelper(this@AddressListActivity))
|
||||||
}
|
}
|
||||||
@ -70,7 +91,7 @@ class AddressListActivity : BaseActivity<ActivityAddressListBinding>(),
|
|||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(BaseObserver(mContext,
|
.subscribe(BaseObserver(mContext,
|
||||||
object : RxHttpCallBack<OrderListBean<AddressBean>>() {
|
object : RxHttpCallBack<OrderListBean<AddressBean>>(binding.smartRefresh) {
|
||||||
override fun onSuccess(t: CommonResponseBean<OrderListBean<AddressBean>>) {
|
override fun onSuccess(t: CommonResponseBean<OrderListBean<AddressBean>>) {
|
||||||
super.onSuccess(t)
|
super.onSuccess(t)
|
||||||
initList(t.data.rows)
|
initList(t.data.rows)
|
||||||
@ -82,9 +103,10 @@ class AddressListActivity : BaseActivity<ActivityAddressListBinding>(),
|
|||||||
super.onClick(view)
|
super.onClick(view)
|
||||||
when (view?.id) {
|
when (view?.id) {
|
||||||
R.id.btnOk -> {
|
R.id.btnOk -> {
|
||||||
ActivityUtils.startActivity(mContext,AddressEditOrAddActivity::class.java,Bundle().apply {
|
launcher.launch(Intent(mContext, AddressEditOrAddActivity::class.java))
|
||||||
putBoolean(AppConfig.IS_ADD,true)
|
// ActivityUtils.startActivity(mContext,AddressEditOrAddActivity::class.java,Bundle().apply {
|
||||||
})
|
// putBoolean(AppConfig.IS_ADD,true)
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,4 +123,8 @@ class AddressListActivity : BaseActivity<ActivityAddressListBinding>(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getRefreshDate(stat: Int, page: Int, count: Int) {
|
||||||
|
initDate()
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package com.dhsd.glowner.ui.address
|
package com.dhsd.glowner.ui.address
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
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
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
@ -19,12 +21,15 @@ import com.amap.api.services.geocoder.RegeocodeResult
|
|||||||
import com.amap.api.services.help.Inputtips
|
import com.amap.api.services.help.Inputtips
|
||||||
import com.amap.api.services.help.Inputtips.InputtipsListener
|
import com.amap.api.services.help.Inputtips.InputtipsListener
|
||||||
import com.amap.api.services.help.InputtipsQuery
|
import com.amap.api.services.help.InputtipsQuery
|
||||||
|
import com.dahe.gldriver.base.AppConfig
|
||||||
import com.dahe.mylibrary.base.BaseActivity
|
import com.dahe.mylibrary.base.BaseActivity
|
||||||
import com.dhsd.glowner.R
|
import com.dhsd.glowner.R
|
||||||
import com.dhsd.glowner.adapter.ChoiceAddressAdapter
|
import com.dhsd.glowner.adapter.ChoiceAddressAdapter
|
||||||
|
import com.dhsd.glowner.bean.PostAddressBean
|
||||||
import com.dhsd.glowner.callback.OnMyGeocodeSearchListener
|
import com.dhsd.glowner.callback.OnMyGeocodeSearchListener
|
||||||
import com.dhsd.glowner.databinding.ActivityChoiceAddressByMapBinding
|
import com.dhsd.glowner.databinding.ActivityChoiceAddressByMapBinding
|
||||||
import com.dhsd.glowner.utils.GDLocationUtils
|
import com.dhsd.glowner.utils.GDLocationUtils
|
||||||
|
import com.google.gson.Gson
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName ChoiceAddressByMapActivity
|
* @ClassName ChoiceAddressByMapActivity
|
||||||
@ -49,6 +54,44 @@ class ChoiceAddressByMapActivity : BaseActivity<ActivityChoiceAddressByMapBindin
|
|||||||
adapter as ChoiceAddressAdapter
|
adapter as ChoiceAddressAdapter
|
||||||
}.apply {
|
}.apply {
|
||||||
isStateViewEnable = true
|
isStateViewEnable = true
|
||||||
|
setOnItemClickListener { adapter, _, position ->
|
||||||
|
val tip = adapter.getItem(position)
|
||||||
|
if (tip != null) {
|
||||||
|
println(tip.toString())
|
||||||
|
GDLocationUtils.instance.getAddressByLatLng(
|
||||||
|
mContext,
|
||||||
|
tip.point,
|
||||||
|
object : OnMyGeocodeSearchListener() {
|
||||||
|
override fun onRegeocodeSearched(
|
||||||
|
result: RegeocodeResult?,
|
||||||
|
rCode: Int
|
||||||
|
) {
|
||||||
|
super.onRegeocodeSearched(result, rCode)
|
||||||
|
result?.let {
|
||||||
|
val postAddressBean = PostAddressBean(
|
||||||
|
it.regeocodeAddress.province,
|
||||||
|
it.regeocodeAddress.city,
|
||||||
|
it.regeocodeAddress.district,
|
||||||
|
it.regeocodeAddress.adCode,
|
||||||
|
it.regeocodeQuery.point.latitude.toString(),
|
||||||
|
it.regeocodeQuery.point.longitude.toString(),
|
||||||
|
tip.district + tip.address//保持详细地址一致
|
||||||
|
)
|
||||||
|
setResult(AppCompatActivity.RESULT_OK, Intent().apply {
|
||||||
|
putExtras(Bundle().apply {
|
||||||
|
putSerializable(
|
||||||
|
AppConfig.BEAN,
|
||||||
|
Gson().toJson(postAddressBean)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
etInput.addTextChangedListener {
|
etInput.addTextChangedListener {
|
||||||
|
@ -89,7 +89,7 @@ class GDLocationUtils private constructor() {
|
|||||||
var geocoderSearch = GeocodeSearch(ctx)
|
var geocoderSearch = GeocodeSearch(ctx)
|
||||||
geocoderSearch.setOnGeocodeSearchListener(listener)
|
geocoderSearch.setOnGeocodeSearchListener(listener)
|
||||||
val query = RegeocodeQuery(
|
val query = RegeocodeQuery(
|
||||||
latLng, 1000f,
|
latLng, 200f,
|
||||||
GeocodeSearch.AMAP
|
GeocodeSearch.AMAP
|
||||||
) // 第一个参数表示一个Latlng,第二参数表示范围多少米,第三个参数表示是火系坐标系还是GPS原生坐标系
|
) // 第一个参数表示一个Latlng,第二参数表示范围多少米,第三个参数表示是火系坐标系还是GPS原生坐标系
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
@ -133,6 +134,8 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="@drawable/shape_gray_5"
|
android:background="@drawable/shape_gray_5"
|
||||||
android:hint="姓名"
|
android:hint="姓名"
|
||||||
|
android:inputType="text"
|
||||||
|
android:maxLines="1"
|
||||||
android:padding="@dimen/dp_11"
|
android:padding="@dimen/dp_11"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/sp_16" />
|
android:textSize="@dimen/sp_16" />
|
||||||
@ -140,44 +143,80 @@
|
|||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/etPhone"
|
android:id="@+id/etPhone"
|
||||||
android:layout_marginLeft="@dimen/dp_10"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/dp_10"
|
||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:background="@drawable/shape_gray_5"
|
android:background="@drawable/shape_gray_5"
|
||||||
android:hint="电话"
|
android:hint="电话"
|
||||||
|
android:inputType="phone"
|
||||||
|
android:maxLength="11"
|
||||||
|
android:maxLines="1"
|
||||||
android:padding="@dimen/dp_11"
|
android:padding="@dimen/dp_11"
|
||||||
android:textColor="#FF4A02"
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/sp_16" />
|
android:textSize="@dimen/sp_16" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/etCom"
|
android:id="@+id/etCom"
|
||||||
android:layout_marginTop="@dimen/dp_12"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/dp_12"
|
||||||
android:background="@drawable/shape_gray_5"
|
android:background="@drawable/shape_gray_5"
|
||||||
android:hint="公司/个人名称"
|
android:hint="公司名称"
|
||||||
|
android:inputType="text"
|
||||||
|
android:maxLines="1"
|
||||||
android:padding="@dimen/dp_11"
|
android:padding="@dimen/dp_11"
|
||||||
android:textColor="#FF4A02"
|
android:textColor="@color/black"
|
||||||
|
android:textSize="@dimen/sp_16" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/dp_18"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="是否企业用户" />
|
||||||
|
|
||||||
|
<com.dahe.mylibrary.weight.SwitchView
|
||||||
|
android:id="@+id/mySwitch"
|
||||||
|
android:layout_width="@dimen/dp_60"
|
||||||
|
android:layout_height="@dimen/dp_30"
|
||||||
|
app:isOpened="true"></com.dahe.mylibrary.weight.SwitchView>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etComNum"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/dp_12"
|
||||||
|
android:background="@drawable/shape_gray_5"
|
||||||
|
android:hint="社会统一代码"
|
||||||
|
android:inputType="text"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:padding="@dimen/dp_11"
|
||||||
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/sp_16" />
|
android:textSize="@dimen/sp_16" />
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/dp_15"
|
android:layout_marginLeft="@dimen/dp_15"
|
||||||
android:layout_marginTop="@dimen/dp_13"
|
android:layout_marginTop="@dimen/dp_13"
|
||||||
android:text="推荐地址"
|
android:text="推荐地址"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/sp_16" />
|
android:textSize="@dimen/sp_16"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recycler"
|
android:id="@+id/recycler"
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/dp_15"
|
android:layout_marginLeft="@dimen/dp_15"
|
||||||
@ -185,7 +224,8 @@
|
|||||||
android:layout_marginRight="@dimen/dp_15"
|
android:layout_marginRight="@dimen/dp_15"
|
||||||
android:background="@drawable/shape_white_8"
|
android:background="@drawable/shape_white_8"
|
||||||
android:paddingTop="@dimen/dp_15"
|
android:paddingTop="@dimen/dp_15"
|
||||||
android:paddingBottom="@dimen/dp_15" />
|
android:paddingBottom="@dimen/dp_15"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -10,11 +10,20 @@
|
|||||||
<include layout="@layout/common_toolbar"></include>
|
<include layout="@layout/common_toolbar"></include>
|
||||||
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||||
android:id="@+id/recycler"
|
android:id="@+id/smartRefresh"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_weight="1"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recycler"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
/>
|
||||||
|
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/llBtn"
|
android:id="@+id/llBtn"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -409,9 +409,11 @@ public class SwitchView extends View {
|
|||||||
if (state == STATE_SWITCH_OFF) {
|
if (state == STATE_SWITCH_OFF) {
|
||||||
refreshState(STATE_SWITCH_OFF2);
|
refreshState(STATE_SWITCH_OFF2);
|
||||||
listener.toggleToOn(this);
|
listener.toggleToOn(this);
|
||||||
|
listener2.onToggle(true);
|
||||||
} else if (state == STATE_SWITCH_ON) {
|
} else if (state == STATE_SWITCH_ON) {
|
||||||
refreshState(STATE_SWITCH_ON2);
|
refreshState(STATE_SWITCH_ON2);
|
||||||
listener.toggleToOff(this);
|
listener.toggleToOff(this);
|
||||||
|
listener2.onToggle(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mOnClickListener != null) {
|
if (mOnClickListener != null) {
|
||||||
@ -435,6 +437,22 @@ public class SwitchView extends View {
|
|||||||
void toggleToOff(SwitchView view);
|
void toggleToOff(SwitchView view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface OnMyStateChangedListener {
|
||||||
|
void onToggle(boolean isOpen);
|
||||||
|
}
|
||||||
|
|
||||||
|
private OnMyStateChangedListener listener2 = new OnMyStateChangedListener() {
|
||||||
|
@Override
|
||||||
|
public void onToggle(boolean isOpen) {
|
||||||
|
// toggleSwitch(isOpen);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public void setOnStateChangedListener2(OnMyStateChangedListener listener) {
|
||||||
|
if (listener == null) throw new IllegalArgumentException("empty listener");
|
||||||
|
this.listener2 = listener;
|
||||||
|
}
|
||||||
|
|
||||||
private OnStateChangedListener listener = new OnStateChangedListener() {
|
private OnStateChangedListener listener = new OnStateChangedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void toggleToOn(SwitchView view) {
|
public void toggleToOn(SwitchView view) {
|
||||||
|
Loading…
Reference in New Issue
Block a user