增加多点列表
This commit is contained in:
parent
53e5154c36
commit
31991ebe00
@ -38,6 +38,7 @@ import com.navinfo.omqs.http.offlinemapdownload.OfflineMapDownloadManager
|
|||||||
import com.navinfo.omqs.tools.LayerConfigUtils
|
import com.navinfo.omqs.tools.LayerConfigUtils
|
||||||
import com.navinfo.omqs.ui.activity.BaseActivity
|
import com.navinfo.omqs.ui.activity.BaseActivity
|
||||||
import com.navinfo.omqs.ui.fragment.console.ConsoleFragment
|
import com.navinfo.omqs.ui.fragment.console.ConsoleFragment
|
||||||
|
import com.navinfo.omqs.ui.fragment.itemlist.ItemListFragment
|
||||||
import com.navinfo.omqs.ui.fragment.offlinemap.OfflineMapFragment
|
import com.navinfo.omqs.ui.fragment.offlinemap.OfflineMapFragment
|
||||||
import com.navinfo.omqs.ui.fragment.qsrecordlist.QsRecordListFragment
|
import com.navinfo.omqs.ui.fragment.qsrecordlist.QsRecordListFragment
|
||||||
import com.navinfo.omqs.ui.fragment.signMoreInfo.SignMoreInfoFragment
|
import com.navinfo.omqs.ui.fragment.signMoreInfo.SignMoreInfoFragment
|
||||||
@ -390,6 +391,25 @@ class MainActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewModel.liveDataItemList.observe(this) {
|
||||||
|
if (leftFragment == null || leftFragment !is ItemListFragment) {
|
||||||
|
leftFragment = ItemListFragment {
|
||||||
|
binding.mainActivityLeftFragment.visibility = View.GONE
|
||||||
|
supportFragmentManager.beginTransaction().remove(leftFragment!!).commit()
|
||||||
|
leftFragment = null
|
||||||
|
null
|
||||||
|
}
|
||||||
|
binding.mainActivityLeftFragment.visibility = View.VISIBLE
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(R.id.main_activity_left_fragment, leftFragment!!)
|
||||||
|
.commit()
|
||||||
|
} else {
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.show(leftFragment!!)
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
// 初始化地图图层控制接收器
|
// 初始化地图图层控制接收器
|
||||||
FlowEventBus.subscribe<List<ImportConfig>>(
|
FlowEventBus.subscribe<List<ImportConfig>>(
|
||||||
|
@ -112,6 +112,11 @@ class MainViewModel @Inject constructor(
|
|||||||
*/
|
*/
|
||||||
val liveDataSignMoreInfo = MutableLiveData<RenderEntity>()
|
val liveDataSignMoreInfo = MutableLiveData<RenderEntity>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 捕捉到的itemList
|
||||||
|
*/
|
||||||
|
val liveDataItemList = MutableLiveData<List<RenderEntity>>()
|
||||||
|
|
||||||
private var traceTag: String = "TRACE_TAG"
|
private var traceTag: String = "TRACE_TAG"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -473,8 +478,10 @@ class MainViewModel @Inject constructor(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (itemList.size > 0) {
|
if (itemList.size == 1) {
|
||||||
liveDataSignMoreInfo.postValue(itemList[0])
|
liveDataSignMoreInfo.postValue(itemList[0])
|
||||||
|
} else {
|
||||||
|
liveDataItemList.postValue(itemList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.navinfo.omqs.ui.fragment.itemlist
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||||
|
import com.navinfo.collect.library.enums.DataCodeEnum
|
||||||
|
import com.navinfo.omqs.databinding.AdapterItemBinding
|
||||||
|
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||||
|
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||||
|
|
||||||
|
class ItemAdapter(private var itemListener: ((Int, RenderEntity) -> Unit?)? = null) :
|
||||||
|
BaseRecyclerViewAdapter<RenderEntity>() {
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||||
|
val viewBinding =
|
||||||
|
AdapterItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||||
|
return BaseViewHolder(viewBinding)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||||
|
val binding = holder.viewBinding as AdapterItemBinding
|
||||||
|
var renderEntity = data[position]
|
||||||
|
|
||||||
|
binding.name.text = DataCodeEnum.findTableNameByCode(renderEntity.code)
|
||||||
|
binding.root.setOnClickListener {
|
||||||
|
if (itemListener != null) {
|
||||||
|
itemListener!!.invoke(position, renderEntity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package com.navinfo.omqs.ui.fragment.itemlist
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import com.navinfo.omqs.databinding.FragmentItemListBinding
|
||||||
|
import com.navinfo.omqs.ui.activity.map.MainViewModel
|
||||||
|
import com.navinfo.omqs.ui.fragment.BaseFragment
|
||||||
|
import com.navinfo.omqs.ui.widget.RecycleViewDivider
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class ItemListFragment(private var backListener: ((ItemListFragment) -> Unit?)? = null) :
|
||||||
|
BaseFragment() {
|
||||||
|
private var _binding: FragmentItemListBinding? = null
|
||||||
|
private val binding get() = _binding!!
|
||||||
|
private val viewModel by activityViewModels<MainViewModel>()
|
||||||
|
private val adapter by lazy {
|
||||||
|
ItemAdapter { _, data ->
|
||||||
|
viewModel.showSignMoreInfo(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||||
|
): View {
|
||||||
|
_binding = FragmentItemListBinding.inflate(inflater, container, false)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
binding.itemListRecyclerview.layoutManager = LinearLayoutManager(requireContext())
|
||||||
|
binding.itemListRecyclerview.adapter = adapter
|
||||||
|
binding.itemListRecyclerview.addItemDecoration(
|
||||||
|
RecycleViewDivider(
|
||||||
|
requireContext(),
|
||||||
|
LinearLayoutManager.VERTICAL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
viewModel.liveDataItemList.observe(viewLifecycleOwner) {
|
||||||
|
adapter.refreshData(it)
|
||||||
|
}
|
||||||
|
binding.taskBack.setOnClickListener {
|
||||||
|
backListener?.invoke(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
app/src/main/res/layout/adapter_item.xml
Normal file
15
app/src/main/res/layout/adapter_item.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:padding="5dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="name"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
</FrameLayout>
|
41
app/src/main/res/layout/fragment_item_list.xml
Normal file
41
app/src/main/res/layout/fragment_item_list.xml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@drawable/shape_left_fragment_bg"
|
||||||
|
tools:context=".ui.fragment.itemlist.ItemListFragment">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/task_back"
|
||||||
|
style="@style/btn_round"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:background="@drawable/selector_bg_round_button"
|
||||||
|
android:foreground="@drawable/ripple_btn_press"
|
||||||
|
android:src="@drawable/ic_baseline_keyboard_arrow_left_24"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/task_fragment_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:text="捕捉列表"
|
||||||
|
android:textColor="@color/default_blue_text_color"
|
||||||
|
android:textSize="16sp"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/item_list_recyclerview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/task_fragment_title" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -61,6 +61,18 @@ enum class DataCodeEnum(var tableName: String, var code: String) {
|
|||||||
OMDB_ELECTRONICEYE("电子眼", "4010"),
|
OMDB_ELECTRONICEYE("电子眼", "4010"),
|
||||||
OMDB_TRAFFICLIGHT("交通灯", "4022"),
|
OMDB_TRAFFICLIGHT("交通灯", "4022"),
|
||||||
OMDB_LANEINFO("车信", "4601"),
|
OMDB_LANEINFO("车信", "4601"),
|
||||||
OMDB_LANE_LINK_LG("车道中心线", "5001")
|
OMDB_LANE_LINK_LG("车道中心线", "5001");
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun findTableNameByCode(code: String): String? {
|
||||||
|
for (enumInstance in DataCodeEnum.values()) {
|
||||||
|
if (enumInstance.code == code) {
|
||||||
|
return enumInstance.tableName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null // 若未找到匹配的 code,则返回 null 或其他适当的默认值
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user