页面代码优化
This commit is contained in:
parent
8dd32b77c0
commit
fe4c8a2beb
@ -51,23 +51,16 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
||||
|
||||
private var isMul = false
|
||||
override fun initView(savedInstanceState: Bundle?) {
|
||||
setStatusBarColor(R.color.white)
|
||||
setTitleBar("普通装货", true)
|
||||
|
||||
intent.extras?.let {
|
||||
isMul = it.getBoolean(AppConfig.IS_MUL, false)
|
||||
}
|
||||
setStatusBarColor(R.color.white)
|
||||
setTitleBar( if (isMul) "一装多卸" else "普通装货", true)
|
||||
|
||||
datas = mutableListOf<AddressBean>(
|
||||
AddressBean(),
|
||||
AddressBean()
|
||||
)
|
||||
binding.run {
|
||||
llAdd.visibility = if (isMul) View.VISIBLE else View.GONE
|
||||
tvAdd.setOnClickListener {
|
||||
|
||||
adapter.add(datas.size-1,AddressBean())
|
||||
adapter.notifyDataSetChanged()
|
||||
adapter.add(datas.size - 1, AddressBean())
|
||||
}
|
||||
llGoods.setOnClickListener {
|
||||
ActivityUtils.startActivityForResult(
|
||||
@ -90,37 +83,8 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
||||
tvDate.setOnClickListener {
|
||||
selectDate()
|
||||
}
|
||||
initRecycle()
|
||||
}
|
||||
|
||||
|
||||
|
||||
adapter = binding.recycler.run {
|
||||
layoutManager = LinearLayoutManager(mContext, RecyclerView.VERTICAL, false)
|
||||
addItemDecoration(
|
||||
RecycleViewDivider(
|
||||
LinearLayout.VERTICAL,
|
||||
ConvertUtils.dp2px(10.0f),
|
||||
Color.TRANSPARENT
|
||||
)
|
||||
)
|
||||
adapter = SendGoodsAdapter()
|
||||
adapter as SendGoodsAdapter
|
||||
}.apply {
|
||||
isStateViewEnable = true
|
||||
setOnItemClickListener { adapter, view, position ->
|
||||
ActivityUtils.startActivityForResult(
|
||||
this@SendGoodsActivity,
|
||||
AddressListActivity::class.java,
|
||||
position
|
||||
)
|
||||
}
|
||||
|
||||
addOnItemChildClickListener(R.id.tvDel){adapter,_,position->
|
||||
adapter.removeAt(position)
|
||||
}
|
||||
}
|
||||
adapter.submitList(datas)
|
||||
|
||||
}
|
||||
|
||||
override fun initDate() {
|
||||
@ -133,7 +97,7 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
||||
val string = it.getString(AppConfig.BEAN, "")
|
||||
if (string.isNotEmpty()) {
|
||||
val addressBean = Gson().fromJson<AddressBean>(string, AddressBean::class.java)
|
||||
|
||||
//处理地址信息
|
||||
if (requestCode == 0) {
|
||||
datas[requestCode] = addressBean.apply {
|
||||
type = "1"
|
||||
@ -141,14 +105,14 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
||||
name = contactPerson
|
||||
phone = contactNumber
|
||||
}
|
||||
} else if (requestCode == datas.size-1) {
|
||||
} else if (requestCode == datas.size - 1) {
|
||||
datas[requestCode] = addressBean.apply {
|
||||
type = "2"
|
||||
address = addressDetail
|
||||
name = contactPerson
|
||||
phone = contactNumber
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
datas[requestCode] = addressBean.apply {
|
||||
isPassingPoints = "1"
|
||||
address = addressDetail
|
||||
@ -166,7 +130,7 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
||||
val datas = it.getStringExtra(AppConfig.DATAS)
|
||||
val userListType = object : TypeToken<MutableList<GoodBean>>() {}.type
|
||||
|
||||
goodList = Gson().fromJson<MutableList<GoodBean>>(datas, userListType)
|
||||
goodList = Gson().fromJson(datas, userListType)
|
||||
val joinToString = goodList.joinToString(separator = "\n") { innerIt ->
|
||||
"""${innerIt.goodName},${innerIt.jttGoodsCategoryName},${
|
||||
if (!TextUtils.isEmpty(innerIt.goodItemGrossWeight)) innerIt.goodItemGrossWeight + "吨" else innerIt.goodCube + "m³"
|
||||
@ -240,7 +204,7 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
||||
}))
|
||||
}
|
||||
|
||||
private fun selectDate(){
|
||||
private fun selectDate() {
|
||||
PickerUtils.getInstance()
|
||||
.showDateSim(this@SendGoodsActivity, "装货截止时间") { date ->
|
||||
binding.tvDate.text = date
|
||||
@ -281,4 +245,37 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun initRecycle() {
|
||||
datas = mutableListOf<AddressBean>(
|
||||
AddressBean(),
|
||||
AddressBean()
|
||||
)
|
||||
adapter = binding.recycler.run {
|
||||
layoutManager = LinearLayoutManager(mContext, RecyclerView.VERTICAL, false)
|
||||
addItemDecoration(
|
||||
RecycleViewDivider(
|
||||
LinearLayout.VERTICAL,
|
||||
ConvertUtils.dp2px(10.0f),
|
||||
Color.TRANSPARENT
|
||||
)
|
||||
)
|
||||
adapter = SendGoodsAdapter()
|
||||
adapter as SendGoodsAdapter
|
||||
}.apply {
|
||||
isStateViewEnable = true
|
||||
setOnItemClickListener { adapter, view, position ->
|
||||
ActivityUtils.startActivityForResult(
|
||||
this@SendGoodsActivity,
|
||||
AddressListActivity::class.java,
|
||||
position
|
||||
)
|
||||
}
|
||||
|
||||
addOnItemChildClickListener(R.id.tvDel) { adapter, _, position ->
|
||||
adapter.removeAt(position)
|
||||
}
|
||||
}
|
||||
adapter.submitList(datas)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user