页面代码优化
This commit is contained in:
parent
8dd32b77c0
commit
fe4c8a2beb
@ -51,23 +51,16 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
|||||||
|
|
||||||
private var isMul = false
|
private var isMul = false
|
||||||
override fun initView(savedInstanceState: Bundle?) {
|
override fun initView(savedInstanceState: Bundle?) {
|
||||||
setStatusBarColor(R.color.white)
|
|
||||||
setTitleBar("普通装货", true)
|
|
||||||
|
|
||||||
intent.extras?.let {
|
intent.extras?.let {
|
||||||
isMul = it.getBoolean(AppConfig.IS_MUL, false)
|
isMul = it.getBoolean(AppConfig.IS_MUL, false)
|
||||||
}
|
}
|
||||||
|
setStatusBarColor(R.color.white)
|
||||||
|
setTitleBar( if (isMul) "一装多卸" else "普通装货", true)
|
||||||
|
|
||||||
datas = mutableListOf<AddressBean>(
|
|
||||||
AddressBean(),
|
|
||||||
AddressBean()
|
|
||||||
)
|
|
||||||
binding.run {
|
binding.run {
|
||||||
llAdd.visibility = if (isMul) View.VISIBLE else View.GONE
|
llAdd.visibility = if (isMul) View.VISIBLE else View.GONE
|
||||||
tvAdd.setOnClickListener {
|
tvAdd.setOnClickListener {
|
||||||
|
adapter.add(datas.size - 1, AddressBean())
|
||||||
adapter.add(datas.size-1,AddressBean())
|
|
||||||
adapter.notifyDataSetChanged()
|
|
||||||
}
|
}
|
||||||
llGoods.setOnClickListener {
|
llGoods.setOnClickListener {
|
||||||
ActivityUtils.startActivityForResult(
|
ActivityUtils.startActivityForResult(
|
||||||
@ -90,37 +83,8 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
|||||||
tvDate.setOnClickListener {
|
tvDate.setOnClickListener {
|
||||||
selectDate()
|
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() {
|
override fun initDate() {
|
||||||
@ -133,7 +97,7 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
|||||||
val string = it.getString(AppConfig.BEAN, "")
|
val string = it.getString(AppConfig.BEAN, "")
|
||||||
if (string.isNotEmpty()) {
|
if (string.isNotEmpty()) {
|
||||||
val addressBean = Gson().fromJson<AddressBean>(string, AddressBean::class.java)
|
val addressBean = Gson().fromJson<AddressBean>(string, AddressBean::class.java)
|
||||||
|
//处理地址信息
|
||||||
if (requestCode == 0) {
|
if (requestCode == 0) {
|
||||||
datas[requestCode] = addressBean.apply {
|
datas[requestCode] = addressBean.apply {
|
||||||
type = "1"
|
type = "1"
|
||||||
@ -141,14 +105,14 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
|||||||
name = contactPerson
|
name = contactPerson
|
||||||
phone = contactNumber
|
phone = contactNumber
|
||||||
}
|
}
|
||||||
} else if (requestCode == datas.size-1) {
|
} else if (requestCode == datas.size - 1) {
|
||||||
datas[requestCode] = addressBean.apply {
|
datas[requestCode] = addressBean.apply {
|
||||||
type = "2"
|
type = "2"
|
||||||
address = addressDetail
|
address = addressDetail
|
||||||
name = contactPerson
|
name = contactPerson
|
||||||
phone = contactNumber
|
phone = contactNumber
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
datas[requestCode] = addressBean.apply {
|
datas[requestCode] = addressBean.apply {
|
||||||
isPassingPoints = "1"
|
isPassingPoints = "1"
|
||||||
address = addressDetail
|
address = addressDetail
|
||||||
@ -166,7 +130,7 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
|||||||
val datas = it.getStringExtra(AppConfig.DATAS)
|
val datas = it.getStringExtra(AppConfig.DATAS)
|
||||||
val userListType = object : TypeToken<MutableList<GoodBean>>() {}.type
|
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 ->
|
val joinToString = goodList.joinToString(separator = "\n") { innerIt ->
|
||||||
"""${innerIt.goodName},${innerIt.jttGoodsCategoryName},${
|
"""${innerIt.goodName},${innerIt.jttGoodsCategoryName},${
|
||||||
if (!TextUtils.isEmpty(innerIt.goodItemGrossWeight)) innerIt.goodItemGrossWeight + "吨" else innerIt.goodCube + "m³"
|
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()
|
PickerUtils.getInstance()
|
||||||
.showDateSim(this@SendGoodsActivity, "装货截止时间") { date ->
|
.showDateSim(this@SendGoodsActivity, "装货截止时间") { date ->
|
||||||
binding.tvDate.text = 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