货物信息选择显示
This commit is contained in:
parent
40697d7219
commit
41a4fafd01
@ -11,6 +11,7 @@ object AppConfig {
|
||||
const val TIME = "DA_HE_TIME"
|
||||
const val ID = "DA_HE_ID"
|
||||
const val BEAN = "DA_HE_BEAN"
|
||||
const val DATAS = "DA_HE_DATAS"
|
||||
const val CX = "DA_HE_CX"
|
||||
const val CC = "DA_HE_CC"
|
||||
const val IS_ADD = "DA_HE_IS_ADD"
|
||||
|
@ -4,6 +4,7 @@ import BaseObserver
|
||||
import DataManager
|
||||
import Good
|
||||
import RxHttpCallBack
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
@ -51,23 +52,16 @@ import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
class GoodsInfoListActivity : BaseActivity<ActivityGoodsInfoListBinding>(),
|
||||
OnLimitClickListener, OnClickListener {
|
||||
private var editPosition: Int = -1
|
||||
|
||||
// private val launcher =
|
||||
// registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
// if (result.resultCode == AppCompatActivity.RESULT_OK) {
|
||||
// result.data?.let {
|
||||
// val serializableExtra = it.getSerializableExtra(AppConfig.BEAN)
|
||||
// Gson().fromJson()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
lateinit var adapter: GoodsAdapter
|
||||
|
||||
override fun initView(savedInstanceState: Bundle?) {
|
||||
setStatusBarColor(R.color.white)
|
||||
setTitleBar("货物信息", { finish() }, true, "常用货物") {
|
||||
ActivityUtils.startActivityForResult(this@GoodsInfoListActivity, GoodsListActivity::class.java, 2)
|
||||
ActivityUtils.startActivityForResult(
|
||||
this@GoodsInfoListActivity,
|
||||
GoodsListActivity::class.java,
|
||||
2
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -106,6 +100,7 @@ class GoodsInfoListActivity : BaseActivity<ActivityGoodsInfoListBinding>(),
|
||||
}
|
||||
|
||||
btnLeft.setOnClickListener(OnLimitClickHelper(this@GoodsInfoListActivity))
|
||||
btnRight.setOnClickListener(OnLimitClickHelper(this@GoodsInfoListActivity))
|
||||
}
|
||||
|
||||
|
||||
@ -144,6 +139,10 @@ class GoodsInfoListActivity : BaseActivity<ActivityGoodsInfoListBinding>(),
|
||||
1
|
||||
)
|
||||
}
|
||||
|
||||
R.id.btnRight -> {
|
||||
submint()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,6 +172,17 @@ class GoodsInfoListActivity : BaseActivity<ActivityGoodsInfoListBinding>(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun submint(){
|
||||
if (adapter.items.isEmpty()){
|
||||
showToast("请添加货物信息")
|
||||
return
|
||||
}
|
||||
val json = Gson().toJson(adapter.items)
|
||||
setResult(Activity.RESULT_OK, Intent().putExtra(AppConfig.DATAS, json))
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun initList(rows: List<GoodBean>) {
|
||||
if (rows.isEmpty()) {
|
||||
adapter.submitList(null)
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.dhsd.glowner.ui.home.activtiy
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.widget.LinearLayout
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
@ -21,10 +23,12 @@ import com.dahe.mylibrary.utils.ToastUtils
|
||||
import com.dhsd.glowner.R
|
||||
import com.dhsd.glowner.adapter.SendGoodsAdapter
|
||||
import com.dhsd.glowner.bean.AddressBean
|
||||
import com.dhsd.glowner.bean.GoodBean
|
||||
import com.dhsd.glowner.databinding.ActivitySendGoodsBinding
|
||||
import com.dhsd.glowner.ui.address.AddressListActivity
|
||||
import com.dhsd.glowner.ui.mine.activity.ChoiceCarActivity
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
|
||||
/**
|
||||
* @ClassName SendGoodsActivity
|
||||
@ -46,18 +50,24 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
||||
)
|
||||
|
||||
binding.llGoods.setOnClickListener {
|
||||
// ActivityUtils.startActivity(mContext, GoodsInfoActivity::class.java)
|
||||
// ActivityUtils.startActivity(mContext, GoodsInfoListActivity::class.java)
|
||||
ActivityUtils.startActivity(mContext, GoodsInfoListActivity::class.java)
|
||||
ActivityUtils.startActivityForResult(
|
||||
this@SendGoodsActivity,
|
||||
GoodsInfoListActivity::class.java,
|
||||
8888
|
||||
)
|
||||
}
|
||||
binding.llCarType.setOnClickListener {
|
||||
ActivityUtils.startActivityForResult(this@SendGoodsActivity, CarTypeActivity::class.java,9999)
|
||||
ActivityUtils.startActivityForResult(
|
||||
this@SendGoodsActivity,
|
||||
CarTypeActivity::class.java,
|
||||
9999
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
binding.btnOk.setOnLongClickListener {
|
||||
binding.btnOk.setOnClickListener {
|
||||
|
||||
ActivityUtils.startActivity(mContext, SendSuccActivity::class.java)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
|
||||
binding.tvDate.setOnClickListener {
|
||||
@ -108,11 +118,27 @@ class SendGoodsActivity : BaseActivity<ActivitySendGoodsBinding>() {
|
||||
|
||||
}
|
||||
data?.let {
|
||||
if (requestCode==9999){
|
||||
val cx = it.getStringExtra(AppConfig.CX)
|
||||
val cc = it.getStringExtra(AppConfig.CC)
|
||||
binding.tvCarType.setText("""${cc} ${cx}""")
|
||||
when (requestCode) {
|
||||
8888 -> {
|
||||
val datas = it.getStringExtra(AppConfig.DATAS)
|
||||
val userListType = object : TypeToken<MutableList<GoodBean>>() {}.type
|
||||
|
||||
val goods = Gson().fromJson<MutableList<GoodBean>>(datas, userListType)
|
||||
val joinToString = goods.joinToString(separator = "\n") { innerIt ->
|
||||
"""${innerIt.goodName},${innerIt.jttGoodsCategoryName},${
|
||||
if (!TextUtils.isEmpty(innerIt.goodItemGrossWeight)) innerIt.goodItemGrossWeight + "吨" else innerIt.goodCube + "m³"
|
||||
}"""
|
||||
}
|
||||
binding.tvGoods.text = joinToString
|
||||
}
|
||||
|
||||
9999 -> {
|
||||
val cx = it.getStringExtra(AppConfig.CX)
|
||||
val cc = it.getStringExtra(AppConfig.CC)
|
||||
binding.tvCarType.text = """$cc $cx"""
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,144 +0,0 @@
|
||||
package com.dhsd.glowner.utils
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.dahe.mylibrary.base.SingletonNoPHolder
|
||||
import com.dahe.mylibrary.callback.OnMyDatePickedListener
|
||||
import com.github.gzuliyujiang.wheelpicker.AddressPicker
|
||||
import com.github.gzuliyujiang.wheelpicker.BirthdayPicker
|
||||
import com.github.gzuliyujiang.wheelpicker.DatePicker
|
||||
import com.github.gzuliyujiang.wheelpicker.OptionPicker
|
||||
import com.github.gzuliyujiang.wheelpicker.annotation.AddressMode
|
||||
import com.github.gzuliyujiang.wheelpicker.annotation.DateMode
|
||||
import com.github.gzuliyujiang.wheelpicker.contract.OnAddressPickedListener
|
||||
import com.github.gzuliyujiang.wheelpicker.contract.OnOptionPickedListener
|
||||
import com.github.gzuliyujiang.wheelpicker.entity.DateEntity
|
||||
import com.github.gzuliyujiang.wheelview.contract.TextProvider
|
||||
|
||||
/**
|
||||
* @ClassName PickUtils
|
||||
* @Author john
|
||||
* @Date 2024/2/5 14:48
|
||||
* @Description 选择器工具类
|
||||
*/
|
||||
class PickerUtils private constructor() {
|
||||
companion object : SingletonNoPHolder<PickerUtils>(::PickerUtils)
|
||||
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* 底部弹出生日日期选择
|
||||
* @param activity
|
||||
* @param title 日期选择title
|
||||
* @param dateEntity 默认参数:默认当天
|
||||
* @param listener
|
||||
*/
|
||||
fun showDate(
|
||||
activity: AppCompatActivity,
|
||||
title: String = "",
|
||||
dateEntity: DateEntity = DateEntity.today(),
|
||||
listener: OnMyDatePickedListener
|
||||
) {
|
||||
val picker = BirthdayPicker(activity)
|
||||
picker.setTitle(title)
|
||||
picker.setDefaultValue(dateEntity.year, dateEntity.month, dateEntity.day)
|
||||
picker.setOnDatePickedListener { year, month, day ->
|
||||
if (listener != null)
|
||||
listener.onDatePicked("$year-${if (month <= 9) "0${month}" else month}-${if (day <= 9) "0${day}" else day}")
|
||||
}
|
||||
picker.wheelLayout.setResetWhenLinkage(false)
|
||||
picker.show()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* 底部弹出日期选择
|
||||
* @param activity
|
||||
* @param title 日期选择title
|
||||
* @param listener
|
||||
*/
|
||||
fun showDateSim(
|
||||
activity: AppCompatActivity,
|
||||
title: String = "日期选择",
|
||||
listener: OnMyDatePickedListener
|
||||
) {
|
||||
val picker = DatePicker(activity)
|
||||
picker.setTitle(title)
|
||||
val wheelLayout = picker.wheelLayout
|
||||
wheelLayout.setDateMode(DateMode.YEAR_MONTH_DAY)
|
||||
wheelLayout.setDateLabel("年", "月", "日")
|
||||
picker.setOnDatePickedListener { year, month, day ->
|
||||
listener.onDatePicked("$year-${if (month <= 9) "0${month}" else month}-${if (day <= 9) "0${day}" else day}")
|
||||
|
||||
}
|
||||
picker.show()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 地址选择
|
||||
* @param activity AppCompatActivity
|
||||
* @param lis OnAddressPickedListener
|
||||
*/
|
||||
fun showAddress(activity: AppCompatActivity,lis:OnAddressPickedListener) {
|
||||
val picker = AddressPicker(activity)
|
||||
picker.setAddressMode(AddressMode.PROVINCE_CITY_COUNTY)
|
||||
picker.setDefaultValue("河南省", "郑州市", "金水区")
|
||||
picker.setOnAddressPickedListener(lis)
|
||||
picker.wheelLayout.setOnLinkageSelectedListener { first, second, third ->
|
||||
picker.titleView.text = String.format(
|
||||
"%s%s%s",
|
||||
picker.firstWheelView.formatItem(first),
|
||||
picker.secondWheelView.formatItem(second),
|
||||
picker.thirdWheelView.formatItem(third)
|
||||
)
|
||||
}
|
||||
picker.show()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 选择驾驶证类型
|
||||
* @param activity
|
||||
* @param title
|
||||
* @param listener
|
||||
*/
|
||||
fun showSelectCarType(
|
||||
activity: AppCompatActivity,
|
||||
title: String = "",
|
||||
listener: OnOptionPickedListener
|
||||
) {
|
||||
OptionPicker(activity)
|
||||
.run {
|
||||
setData("A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2")
|
||||
setDefaultValue("B1")
|
||||
setTitle(title)
|
||||
setOnOptionPickedListener(listener)
|
||||
show()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 底部弹框-单选
|
||||
* @param activity AppCompatActivity
|
||||
* @param title String
|
||||
* @param listener OnOptionPickedListener
|
||||
*/
|
||||
fun <T:TextProvider> showSelectCarColor(
|
||||
activity: AppCompatActivity,
|
||||
title: String = "",
|
||||
default: String = "",
|
||||
datas: MutableList<T>,
|
||||
listener: OnOptionPickedListener
|
||||
) {
|
||||
OptionPicker(activity)
|
||||
.run {
|
||||
setData(datas)
|
||||
setDefaultValue(default)
|
||||
setTitle(title)
|
||||
setOnOptionPickedListener(listener)
|
||||
show()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -48,7 +48,6 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:drawableLeft="@drawable/start"
|
||||
android:text="货物信息"
|
||||
android:textColor="@color/black"
|
||||
@ -56,9 +55,13 @@
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:hint="请选择货物信息"
|
||||
android:gravity="right"
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/tvGoods"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="螺纹钢,钢铁,40吨"
|
||||
tools:text="螺纹钢,钢铁,40吨"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/sp_16" />
|
||||
</LinearLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user