添加车辆优化

This commit is contained in:
lijia 2024-05-11 17:51:39 +08:00
parent 77448b0e90
commit acf37b474b
3 changed files with 54 additions and 22 deletions

View File

@ -165,7 +165,6 @@ class MineFragment : BaseFragment<FragmentMineBinding>(), View.OnClickListener,
ActivityUtils.startActivity(mContext, SettingActivity::class.java) ActivityUtils.startActivity(mContext, SettingActivity::class.java)
} }
carAdapter = recycler.run { carAdapter = recycler.run {
layoutManager = LinearLayoutManager(mContext, RecyclerView.VERTICAL, false) layoutManager = LinearLayoutManager(mContext, RecyclerView.VERTICAL, false)
addItemDecoration( addItemDecoration(
@ -187,7 +186,9 @@ class MineFragment : BaseFragment<FragmentMineBinding>(), View.OnClickListener,
Bundle().apply { putString(AppConfig.CAR_ID, items[position].carId) }) Bundle().apply { putString(AppConfig.CAR_ID, items[position].carId) })
} }
} }
tvAddCarOne.setOnClickListener {
ActivityUtils.startActivity(mContext, CarsManActivity::class.java)
}
tvAddCar.setOnClickListener { tvAddCar.setOnClickListener {
ActivityUtils.startActivity(mContext, CarsManActivity::class.java) ActivityUtils.startActivity(mContext, CarsManActivity::class.java)
@ -351,9 +352,17 @@ class MineFragment : BaseFragment<FragmentMineBinding>(), View.OnClickListener,
override fun onSuccess(t: CommonResponseBean<MutableList<CarBean>>) { override fun onSuccess(t: CommonResponseBean<MutableList<CarBean>>) {
super.onSuccess(t) super.onSuccess(t)
if (t.data == null || t.data.size == 0) { if (t.data == null || t.data.size == 0) {
carAdapter.submitList(null) binding.run {
carAdapter.setStateViewLayout(mContext, R.layout.empty_view) tvAddCarOne.visibility = View.VISIBLE
recycler.visibility = View.GONE
}
// carAdapter.submitList(null)
// carAdapter.setStateViewLayout(mContext, R.layout.empty_view)
} else { } else {
binding.run {
tvAddCarOne.visibility = View.GONE
recycler.visibility = View.VISIBLE
}
carAdapter?.submitList(t.data) carAdapter?.submitList(t.data)
} }
} }

View File

@ -77,11 +77,11 @@ class OneKeyLoginUtils private constructor() {
//模拟的是必须登录 否则直接退出app的场景 //模拟的是必须登录 否则直接退出app的场景
// finish() // finish()
} else { } else {
Toast.makeText( // Toast.makeText(
context, // context,
"一键登录失败切换到其他登录方式", // "一键登录失败切换到其他登录方式",
Toast.LENGTH_SHORT // Toast.LENGTH_SHORT
).show() // ).show()
//获取token失败去获取验证码页面 //获取token失败去获取验证码页面
EventBus.getDefault().post(RefreshEvent(1)) EventBus.getDefault().post(RefreshEvent(1))
} }
@ -101,11 +101,11 @@ class OneKeyLoginUtils private constructor() {
//模拟的是必须登录 否则直接退出app的场景 //模拟的是必须登录 否则直接退出app的场景
// finish() // finish()
} else { } else {
Toast.makeText( // Toast.makeText(
context, // context,
"一键登录失败切换到其他登录方式", // "一键登录失败切换到其他登录方式",
Toast.LENGTH_SHORT // Toast.LENGTH_SHORT
).show() // ).show()
//获取token失败去获取验证码页面 //获取token失败去获取验证码页面
EventBus.getDefault().post(RefreshEvent(1)) EventBus.getDefault().post(RefreshEvent(1))
} }
@ -139,11 +139,11 @@ class OneKeyLoginUtils private constructor() {
//模拟的是必须登录 否则直接退出app的场景 //模拟的是必须登录 否则直接退出app的场景
// finish() // finish()
} else { } else {
Toast.makeText( // Toast.makeText(
context, // context,
"一键登录失败切换到其他登录方式", // "一键登录失败切换到其他登录方式",
Toast.LENGTH_SHORT // Toast.LENGTH_SHORT
).show() // ).show()
//获取token失败去获取验证码页面 //获取token失败去获取验证码页面
EventBus.getDefault().post(RefreshEvent(1)) EventBus.getDefault().post(RefreshEvent(1))
} }

View File

@ -313,12 +313,35 @@
android:layout_alignTop="@+id/tvToolsTitle" android:layout_alignTop="@+id/tvToolsTitle"
android:paddingRight="@dimen/dp_16" android:paddingRight="@dimen/dp_16"
/> />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler" <RelativeLayout
android:layout_below="@+id/tvToolsTitle" android:layout_below="@+id/tvToolsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
<TextView
android:visibility="gone"
android:id="@+id/tvAddCarOne"
android:layout_marginBottom="@dimen/dp_26"
android:layout_marginTop="@dimen/dp_16"
android:background="@drawable/shape_btn_empty_bg"
android:layout_centerHorizontal="true"
android:layout_width="@dimen/dp_160"
android:layout_height="@dimen/dp_40"
android:text="添加车辆"
android:gravity="center"
android:textColor="@color/main_red"
android:textSize="@dimen/sp_18"
/>
</RelativeLayout>
<GridView <GridView
android:visibility="gone" android:visibility="gone"