增加地图捕捉数据功能
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||||
<!-- 写入扩展存储,向扩展卡写入数据,用于写入离线定位数据-->
|
<!-- 写入扩展存储,向扩展卡写入数据,用于写入离线定位数据-->
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||||
<!-- 访问网络,网络定位需要上网 -->
|
<!-- 访问网络,网络定位需要上网 -->
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<!-- 允许访问振动设备 -->
|
<!-- 允许访问振动设备 -->
|
||||||
@@ -34,10 +35,10 @@
|
|||||||
android:fullBackupContent="@xml/backup_rules"
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:supportsRtl="true"
|
|
||||||
android:largeHeap="true"
|
android:largeHeap="true"
|
||||||
android:theme="@style/Theme.OMQualityInspection"
|
android:requestLegacyExternalStorage="true"
|
||||||
android:requestLegacyExternalStorage="true">
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.OMQualityInspection">
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activity.login.LoginActivity"
|
android:name=".ui.activity.login.LoginActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
@@ -57,7 +58,9 @@
|
|||||||
android:screenOrientation="landscape"
|
android:screenOrientation="landscape"
|
||||||
android:theme="@style/Theme.OMQualityInspection" />
|
android:theme="@style/Theme.OMQualityInspection" />
|
||||||
|
|
||||||
<meta-data android:name="ScopedStorage" android:value="true" />
|
<meta-data
|
||||||
|
android:name="ScopedStorage"
|
||||||
|
android:value="true" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -18,7 +18,7 @@ class OMQSApplication : Application() {
|
|||||||
FileManager.initRootDir(this)
|
FileManager.initRootDir(this)
|
||||||
Realm.init(this)
|
Realm.init(this)
|
||||||
val password = "encryp".encodeToByteArray().copyInto(ByteArray(64))
|
val password = "encryp".encodeToByteArray().copyInto(ByteArray(64))
|
||||||
// 70617373776f72640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
// 656e6372797000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
Log.d("OMQSApplication", "密码是: ${byteArrayToHexString(password)}")
|
Log.d("OMQSApplication", "密码是: ${byteArrayToHexString(password)}")
|
||||||
val config = RealmConfiguration.Builder()
|
val config = RealmConfiguration.Builder()
|
||||||
.directory(File(Constant.DATA_PATH))
|
.directory(File(Constant.DATA_PATH))
|
||||||
|
|||||||
@@ -11,20 +11,33 @@ import kotlinx.parcelize.Parcelize
|
|||||||
data class ScProblemTypeBean(
|
data class ScProblemTypeBean(
|
||||||
@PrimaryKey(autoGenerate = true)
|
@PrimaryKey(autoGenerate = true)
|
||||||
var id: Long = 0,
|
var id: Long = 0,
|
||||||
|
/**
|
||||||
|
* elementType
|
||||||
|
* 要素类型
|
||||||
|
*/
|
||||||
|
@ColumnInfo("ELEMENT_TYPE")
|
||||||
|
val elementType: String = "",
|
||||||
|
/**
|
||||||
|
* 要素代码
|
||||||
|
*/
|
||||||
|
@ColumnInfo("ELEMENT_CODE")
|
||||||
|
val elementCode: String = "",
|
||||||
/**
|
/**
|
||||||
* 问题分类
|
* 问题分类
|
||||||
*/
|
*/
|
||||||
@ColumnInfo("CLASS_TYPE")
|
@ColumnInfo("CLASS_TYPE")
|
||||||
var classType: String = "",
|
val classType: String = "",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 问题类型
|
* 问题类型
|
||||||
*/
|
*/
|
||||||
@ColumnInfo("TYPE")
|
@ColumnInfo("TYPE")
|
||||||
var problemType: String = "",
|
val problemType: String = "",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 问题现象
|
* 问题现象
|
||||||
*/
|
*/
|
||||||
@ColumnInfo("PHENOMENON")
|
@ColumnInfo("PHENOMENON")
|
||||||
var phenomenon: String = ""
|
val phenomenon: String = ""
|
||||||
|
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
@@ -30,7 +30,7 @@ open class PermissionsActivity : BaseActivity() {
|
|||||||
permissionList.add(Permission.ACCESS_FINE_LOCATION)
|
permissionList.add(Permission.ACCESS_FINE_LOCATION)
|
||||||
permissionList.add(Permission.ACCESS_COARSE_LOCATION)
|
permissionList.add(Permission.ACCESS_COARSE_LOCATION)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
permissionList.add(Permission.ACCESS_BACKGROUND_LOCATION)
|
// permissionList.add(Permission.ACCESS_BACKGROUND_LOCATION)
|
||||||
}
|
}
|
||||||
XXPermissions.with(this)
|
XXPermissions.with(this)
|
||||||
// 申请单个权限
|
// 申请单个权限
|
||||||
|
|||||||
@@ -52,8 +52,16 @@ class MainActivity : BaseActivity() {
|
|||||||
binding.mainActivity = this
|
binding.mainActivity = this
|
||||||
//给xml传递viewModel对象
|
//给xml传递viewModel对象
|
||||||
binding.viewModel = viewModel
|
binding.viewModel = viewModel
|
||||||
// lifecycle.addObserver(viewModel)
|
|
||||||
lifecycleScope
|
viewModel.liveDataQsRecordIdList.observe(this) {
|
||||||
|
if (it.size == 1) {
|
||||||
|
val bundle = Bundle()
|
||||||
|
bundle.putString("QsId", it[0])
|
||||||
|
val naviController = findNavController(R.id.main_activity_right_fragment)
|
||||||
|
naviController.navigate(R.id.EvaluationResultFragment, bundle)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
@@ -94,7 +102,7 @@ class MainActivity : BaseActivity() {
|
|||||||
naviController.navigate(R.id.EvaluationResultFragment)
|
naviController.navigate(R.id.EvaluationResultFragment)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
// override fun onBackPressed() {
|
||||||
super.onBackPressed()
|
// super.onBackPressed()
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.navinfo.omqs.ui.activity.map
|
package com.navinfo.omqs.ui.activity.map
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import com.navinfo.collect.library.map.NIMapController
|
import com.navinfo.collect.library.map.NIMapController
|
||||||
|
import com.navinfo.collect.library.map.handler.OnQsRecordItemClickListener
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import dagger.hilt.android.scopes.ActivityRetainedScoped
|
import dagger.hilt.android.scopes.ActivityRetainedScoped
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@@ -16,6 +18,16 @@ class MainViewModel @Inject constructor(
|
|||||||
private val mapController: NIMapController,
|
private val mapController: NIMapController,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
||||||
|
val liveDataQsRecordIdList = MutableLiveData<List<String>>()
|
||||||
|
|
||||||
|
init {
|
||||||
|
mapController.layerManagerHandler.setOnQsRecordItemClickListener(object :
|
||||||
|
OnQsRecordItemClickListener {
|
||||||
|
override fun onQsRecordList(list: MutableList<String>) {
|
||||||
|
liveDataQsRecordIdList.value = list
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 点击我的位置,回到我的位置
|
* 点击我的位置,回到我的位置
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.os.Bundle
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.databinding.DataBindingUtil
|
||||||
import androidx.navigation.NavOptions
|
import androidx.navigation.NavOptions
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import com.navinfo.omqs.R
|
import com.navinfo.omqs.R
|
||||||
@@ -14,30 +15,26 @@ import dagger.hilt.android.AndroidEntryPoint
|
|||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
||||||
private var _binding: FragmentEvaluationResultBinding? = null
|
private lateinit var binding: FragmentEvaluationResultBinding
|
||||||
private val binding get() = _binding!!
|
|
||||||
private val viewModel by shareViewModels<EvaluationResultViewModel>("QsRecode")
|
private val viewModel by shareViewModels<EvaluationResultViewModel>("QsRecode")
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
_binding = FragmentEvaluationResultBinding.inflate(inflater, container, false)
|
binding =
|
||||||
|
DataBindingUtil.inflate(inflater, R.layout.fragment_evaluation_result, container, false)
|
||||||
|
binding.fragment = this
|
||||||
|
binding.viewModel = viewModel
|
||||||
|
binding.lifecycleOwner = this
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
liveDataObserve()
|
//监听是否退出当前页面
|
||||||
|
viewModel.liveDataFinish.observe(viewLifecycleOwner) {
|
||||||
/**
|
onBackPressed()
|
||||||
* 点击监听
|
}
|
||||||
*/
|
|
||||||
binding.evaluationClassType.setOnClickListener(this)
|
|
||||||
binding.evaluationProblemType.setOnClickListener(this)
|
|
||||||
binding.evaluationPhenomenon.setOnClickListener(this)
|
|
||||||
binding.evaluationLink.setOnClickListener(this)
|
|
||||||
binding.evaluationCause.setOnClickListener(this)
|
|
||||||
|
|
||||||
//返回按钮点击
|
//返回按钮点击
|
||||||
binding.evaluationBar.setNavigationOnClickListener {
|
binding.evaluationBar.setNavigationOnClickListener {
|
||||||
onBackPressed()
|
onBackPressed()
|
||||||
@@ -59,7 +56,17 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
|||||||
/**
|
/**
|
||||||
* 读取元数据
|
* 读取元数据
|
||||||
*/
|
*/
|
||||||
viewModel.loadMetadata()
|
if (arguments != null) {
|
||||||
|
val id = requireArguments().getString("QsId")
|
||||||
|
if (id != null) {
|
||||||
|
viewModel.loadData(id)
|
||||||
|
} else {
|
||||||
|
viewModel.loadMetadata()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
viewModel.loadMetadata()
|
||||||
|
}
|
||||||
|
|
||||||
// //监听大分类数据变化
|
// //监听大分类数据变化
|
||||||
// viewModel.liveDataClassTypeList.observe(viewLifecycleOwner) {
|
// viewModel.liveDataClassTypeList.observe(viewLifecycleOwner) {
|
||||||
// if (it == null || it.isEmpty()) {
|
// if (it == null || it.isEmpty()) {
|
||||||
@@ -155,43 +162,12 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
|
||||||
* 监听liveData
|
|
||||||
*/
|
|
||||||
private fun liveDataObserve() {
|
|
||||||
|
|
||||||
//监听问题分类,更新UI
|
|
||||||
viewModel.liveDataCurrentClassType.observe(viewLifecycleOwner) {
|
|
||||||
binding.evaluationClassType.text = it
|
|
||||||
}
|
|
||||||
//监听问题类型,更新UI
|
|
||||||
viewModel.liveDataCurrentProblemType.observe(viewLifecycleOwner) {
|
|
||||||
binding.evaluationProblemType.text = it
|
|
||||||
}
|
|
||||||
//监听问题现象,更新UI
|
|
||||||
viewModel.liveDataCurrentPhenomenon.observe(viewLifecycleOwner) {
|
|
||||||
binding.evaluationPhenomenon.text = it
|
|
||||||
}
|
|
||||||
//监听问题环节,更新UI
|
|
||||||
viewModel.liveDataCurrentProblemLink.observe(viewLifecycleOwner) {
|
|
||||||
binding.evaluationLink.text = it
|
|
||||||
}
|
|
||||||
//监听问题初步原因,更新UI
|
|
||||||
viewModel.liveDataCurrentCause.observe(viewLifecycleOwner) {
|
|
||||||
binding.evaluationCause.text = it
|
|
||||||
}
|
|
||||||
//监听是否退出当前页面
|
|
||||||
viewModel.liveDataFinish.observe(viewLifecycleOwner) {
|
|
||||||
onBackPressed()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
activity?.apply {
|
activity?.apply {
|
||||||
findNavController(R.id.main_activity_middle_fragment).navigateUp()
|
findNavController(R.id.main_activity_middle_fragment).navigateUp()
|
||||||
}
|
}
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
_binding = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.navinfo.collect.library.data.entity.QsRecordBean
|
|||||||
import com.navinfo.omqs.db.RoomAppDatabase
|
import com.navinfo.omqs.db.RoomAppDatabase
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
|
import io.realm.kotlin.where
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -28,63 +29,32 @@ class EvaluationResultViewModel @Inject constructor(
|
|||||||
val liveDataFinish = MutableLiveData<Boolean>()
|
val liveDataFinish = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 问题分类 liveData,给[PhenomenonLeftAdapter]展示的数据
|
* 问题分类 liveData,给[LeftAdapter]展示的数据
|
||||||
*/
|
*/
|
||||||
val liveDataClassTypeList = MutableLiveData<List<String>>()
|
val liveDataLeftTypeList = MutableLiveData<List<String>>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 问题类型 liveData 给[PhenomenonMiddleAdapter]展示的数据
|
* 问题类型 liveData 给[MiddleAdapter]展示的数据
|
||||||
*/
|
*/
|
||||||
val liveDataProblemTypeList = MutableLiveData<List<String>>()
|
val liveDataMiddleTypeList = MutableLiveData<List<String>>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 问题现象 liveData 给[PhenomenonRightGroupHeaderAdapter]展示的数据
|
* 问题现象 liveData 给[RightGroupHeaderAdapter]展示的数据
|
||||||
*/
|
*/
|
||||||
val liveDataPhenomenonRightList = MutableLiveData<List<PhenomenonMiddleBean>>()
|
val liveDataRightTypeList = MutableLiveData<List<RightBean>>()
|
||||||
|
|
||||||
|
|
||||||
/**
|
var liveDataQsRecordBean = MutableLiveData<QsRecordBean>()
|
||||||
* 当前选择问题分类 给[EvaluationResultFragment]中 【问题分类】展示数据
|
|
||||||
*/
|
|
||||||
var liveDataCurrentClassType = MutableLiveData<String>()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当前选择的问题类型 给[EvaluationResultFragment]中 【问题类型】展示数据
|
|
||||||
*/
|
|
||||||
var liveDataCurrentProblemType = MutableLiveData<String>()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当前选择的问题现象 给[EvaluationResultFragment]中 【问题现象】展示数据
|
|
||||||
*/
|
|
||||||
var liveDataCurrentPhenomenon = MutableLiveData<String>()
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当前选择的问题环节 给[EvaluationResultFragment]中 【问题环节】展示数据
|
|
||||||
*/
|
|
||||||
var liveDataCurrentProblemLink = MutableLiveData<String>()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当前选择的问初步原因 给[EvaluationResultFragment]中 【初步原因】展示数据
|
|
||||||
*/
|
|
||||||
var liveDataCurrentCause = MutableLiveData<String>()
|
|
||||||
|
|
||||||
var currentGeoPoint: GeoPoint? = null
|
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
liveDataQsRecordBean.value = QsRecordBean(id = UUID.randomUUID().toString(), classType = "89193")
|
||||||
Log.e("jingo", "EvaluationResultViewModel 创建了 ${hashCode()}")
|
Log.e("jingo", "EvaluationResultViewModel 创建了 ${hashCode()}")
|
||||||
mapController.markerHandle.apply {
|
mapController.markerHandle.apply {
|
||||||
setOnMapClickListener {
|
setOnMapClickListener {
|
||||||
currentGeoPoint = it
|
liveDataQsRecordBean.value!!.geometry = it.toGeometry()
|
||||||
addMarker(it, markerTitle)
|
addMarker(it, markerTitle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val geoPoint = mapController.locationLayerHandler.getCurrentGeoPoint()
|
|
||||||
geoPoint?.let {
|
|
||||||
currentGeoPoint = it
|
|
||||||
mapController.markerHandle.addMarker(geoPoint, markerTitle)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,22 +74,31 @@ class EvaluationResultViewModel @Inject constructor(
|
|||||||
getClassTypeList()
|
getClassTypeList()
|
||||||
getProblemLinkList()
|
getProblemLinkList()
|
||||||
}
|
}
|
||||||
|
val geoPoint = mapController.locationLayerHandler.getCurrentGeoPoint()
|
||||||
|
geoPoint?.let {
|
||||||
|
liveDataQsRecordBean.value!!.geometry = it.toGeometry()
|
||||||
|
mapController.markerHandle.addMarker(geoPoint, markerTitle)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* //获取问题分类列表
|
* //获取问题分类列表
|
||||||
*/
|
*/
|
||||||
fun getClassTypeList() {
|
fun getClassTypeList() {
|
||||||
|
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
val list = roomAppDatabase.getScProblemTypeDao().findClassTypeList()
|
val list = roomAppDatabase.getScProblemTypeDao().findClassTypeList()
|
||||||
list?.let {
|
list?.let {
|
||||||
//通知页面更新
|
if (list.isNotEmpty()) {
|
||||||
liveDataClassTypeList.postValue(it)
|
//通知页面更新
|
||||||
//如果右侧栏没数据,给个默认值
|
liveDataLeftTypeList.postValue(it)
|
||||||
if (liveDataCurrentClassType.value == null) {
|
val classType = it[0]
|
||||||
liveDataCurrentClassType.postValue(it[0])
|
//如果右侧栏没数据,给个默认值
|
||||||
|
if (liveDataQsRecordBean.value!!.classType.isEmpty()) {
|
||||||
|
liveDataQsRecordBean.value!!.classType = classType
|
||||||
|
}
|
||||||
|
getProblemList(classType)
|
||||||
}
|
}
|
||||||
getProblemList(it[0])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,27 +112,26 @@ class EvaluationResultViewModel @Inject constructor(
|
|||||||
val list = roomAppDatabase.getScRootCauseAnalysisDao().findAllData()
|
val list = roomAppDatabase.getScRootCauseAnalysisDao().findAllData()
|
||||||
list?.let { tl ->
|
list?.let { tl ->
|
||||||
if (tl.isNotEmpty()) {
|
if (tl.isNotEmpty()) {
|
||||||
val typeTitleList = mutableListOf<String>()
|
val middleList = mutableListOf<String>()
|
||||||
val phenomenonRightList = mutableListOf<PhenomenonMiddleBean>()
|
val rightList = mutableListOf<RightBean>()
|
||||||
for (item in tl) {
|
for (item in tl) {
|
||||||
if (!typeTitleList.contains(item.problemLink)) {
|
if (!middleList.contains(item.problemLink)) {
|
||||||
typeTitleList.add(item.problemLink)
|
middleList.add(item.problemLink)
|
||||||
}
|
}
|
||||||
phenomenonRightList.add(
|
rightList.add(
|
||||||
PhenomenonMiddleBean(
|
RightBean(
|
||||||
title = item.problemLink, text = item.problemCause, isSelect = false
|
title = item.problemLink, text = item.problemCause, isSelect = false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (liveDataQsRecordBean.value!!.problemLink.isEmpty()) {
|
||||||
if (liveDataCurrentProblemLink.value == null) {
|
liveDataQsRecordBean.value!!.problemLink = middleList[0]
|
||||||
liveDataCurrentProblemLink.postValue(phenomenonRightList[0].text)
|
|
||||||
}
|
}
|
||||||
if (liveDataCurrentCause.value == null) {
|
if (liveDataQsRecordBean.value!!.cause.isEmpty()) {
|
||||||
liveDataCurrentCause.postValue(typeTitleList[0])
|
liveDataQsRecordBean.value!!.cause = rightList[0].text
|
||||||
}
|
}
|
||||||
liveDataProblemTypeList.postValue(typeTitleList)
|
liveDataMiddleTypeList.postValue(middleList)
|
||||||
liveDataPhenomenonRightList.postValue(phenomenonRightList)
|
liveDataRightTypeList.postValue(rightList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,76 +145,90 @@ class EvaluationResultViewModel @Inject constructor(
|
|||||||
typeList?.let { tl ->
|
typeList?.let { tl ->
|
||||||
if (tl.isNotEmpty()) {
|
if (tl.isNotEmpty()) {
|
||||||
val typeTitleList = mutableListOf<String>()
|
val typeTitleList = mutableListOf<String>()
|
||||||
val phenomenonRightList = mutableListOf<PhenomenonMiddleBean>()
|
val phenomenonRightList = mutableListOf<RightBean>()
|
||||||
for (item in tl) {
|
for (item in tl) {
|
||||||
if (!typeTitleList.contains(item.problemType)) {
|
if (!typeTitleList.contains(item.problemType)) {
|
||||||
typeTitleList.add(item.problemType)
|
typeTitleList.add(item.problemType)
|
||||||
}
|
}
|
||||||
phenomenonRightList.add(
|
phenomenonRightList.add(
|
||||||
PhenomenonMiddleBean(
|
RightBean(
|
||||||
title = item.problemType, text = item.phenomenon, isSelect = false
|
title = item.problemType, text = item.phenomenon, isSelect = false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (liveDataCurrentPhenomenon.value == null) {
|
liveDataMiddleTypeList.postValue(typeTitleList)
|
||||||
liveDataCurrentPhenomenon.postValue(phenomenonRightList[0].text)
|
liveDataRightTypeList.postValue(phenomenonRightList)
|
||||||
}
|
|
||||||
if (liveDataCurrentProblemType.value == null) {
|
|
||||||
liveDataCurrentProblemType.postValue(typeTitleList[0])
|
|
||||||
}
|
|
||||||
liveDataProblemTypeList.postValue(typeTitleList)
|
|
||||||
liveDataPhenomenonRightList.postValue(phenomenonRightList)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询问题类型
|
* 查询问题类型列表
|
||||||
*/
|
*/
|
||||||
fun getProblemTypeList(classType: String) {
|
fun getProblemTypeList(classType: String) {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
liveDataCurrentClassType.postValue(classType)
|
|
||||||
getProblemList(classType)
|
getProblemList(classType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setPhenomenonMiddleBean(bean: PhenomenonMiddleBean) {
|
/**
|
||||||
if (liveDataCurrentPhenomenon.value != bean.text) liveDataCurrentPhenomenon.value =
|
* 监听右侧栏的点击事件,修改数据
|
||||||
bean.text
|
*/
|
||||||
if (liveDataCurrentProblemType.value != bean.title) liveDataCurrentProblemType.value =
|
fun setPhenomenonMiddleBean(adapterBean: RightBean) {
|
||||||
bean.title
|
liveDataQsRecordBean.value!!.phenomenon = adapterBean.text
|
||||||
|
liveDataQsRecordBean.value!!.problemType = adapterBean.title
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setProblemLinkMiddleBean(bean: PhenomenonMiddleBean) {
|
fun setProblemLinkMiddleBean(adapterBean: RightBean) {
|
||||||
if (liveDataCurrentProblemLink.value != bean.text) liveDataCurrentProblemLink.value =
|
liveDataQsRecordBean.value!!.cause = adapterBean.text
|
||||||
bean.text
|
liveDataQsRecordBean.value!!.problemLink = adapterBean.title
|
||||||
if (liveDataCurrentCause.value != bean.title) liveDataCurrentCause.value = bean.title
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveData() {
|
fun saveData() {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
val qsRecord = QsRecordBean(
|
|
||||||
id = UUID.randomUUID().toString(),
|
|
||||||
classType = liveDataCurrentClassType.value.toString(),
|
|
||||||
type = liveDataCurrentProblemType.value.toString(),
|
|
||||||
phenomenon = liveDataCurrentPhenomenon.value.toString(),
|
|
||||||
problemLink = liveDataCurrentProblemLink.value.toString(),
|
|
||||||
cause = liveDataCurrentCause.value.toString(),
|
|
||||||
)
|
|
||||||
qsRecord.geometry = currentGeoPoint!!.toGeometry()
|
|
||||||
val realm = Realm.getDefaultInstance()
|
val realm = Realm.getDefaultInstance()
|
||||||
realm.executeTransaction {
|
realm.executeTransaction {
|
||||||
it.copyToRealmOrUpdate(qsRecord)
|
it.copyToRealmOrUpdate(liveDataQsRecordBean.value)
|
||||||
}
|
}
|
||||||
realm.close()
|
realm.close()
|
||||||
mapController.mMapView.updateMap()
|
mapController.layerManagerHandler.addOrUpdateQsRecordMark(liveDataQsRecordBean.value!!)
|
||||||
liveDataFinish.postValue(true)
|
liveDataFinish.postValue(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteData() {
|
fun deleteData() {
|
||||||
|
// viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
// val qsRecord = QsRecordBean(
|
||||||
|
// id = UUID.randomUUID().toString(),
|
||||||
|
// classType = liveDataCurrentClassType.value.toString(),
|
||||||
|
// type = liveDataCurrentProblemType.value.toString(),
|
||||||
|
// phenomenon = liveDataCurrentPhenomenon.value.toString(),
|
||||||
|
// problemLink = liveDataCurrentProblemLink.value.toString(),
|
||||||
|
// cause = liveDataCurrentCause.value.toString(),
|
||||||
|
// )
|
||||||
|
// qsRecord.geometry = currentGeoPoint!!.toGeometry()
|
||||||
|
// val realm = Realm.getDefaultInstance()
|
||||||
|
// realm.executeTransaction {
|
||||||
|
// it.copyToRealmOrUpdate(qsRecord)
|
||||||
|
// }
|
||||||
|
// realm.close()
|
||||||
|
// mapController.layerManagerHandler.addOrUpdateQsRecordMark(qsRecord)
|
||||||
|
// liveDataFinish.postValue(true)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据数据id,查询数据
|
||||||
|
*/
|
||||||
|
fun loadData(id: String) {
|
||||||
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
val realm = Realm.getDefaultInstance()
|
||||||
|
val objects = realm.where<QsRecordBean>().equalTo("id", id).findFirst()
|
||||||
|
|
||||||
|
if (objects != null) {
|
||||||
|
liveDataQsRecordBean.postValue(realm.copyFromRealm(objects))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ import com.navinfo.omqs.databinding.TextItemSelectBinding
|
|||||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||||
|
|
||||||
class PhenomenonLeftAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) :
|
class LeftAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) :
|
||||||
BaseRecyclerViewAdapter<String>() {
|
BaseRecyclerViewAdapter<String>() {
|
||||||
private var selectTitle = ""
|
private var selectTitle = ""
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ import com.navinfo.omqs.databinding.TextItemSelectBinding
|
|||||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||||
|
|
||||||
class PhenomenonMiddleAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) :
|
class MiddleAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) :
|
||||||
BaseRecyclerViewAdapter<String>() {
|
BaseRecyclerViewAdapter<String>() {
|
||||||
private var selectTitle = ""
|
private var selectTitle = ""
|
||||||
|
|
||||||
@@ -5,13 +5,9 @@ import android.util.Log
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.navigation.findNavController
|
|
||||||
import androidx.navigation.fragment.findNavController
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.recyclerview.widget.RecyclerView.OnScrollListener
|
import androidx.recyclerview.widget.RecyclerView.OnScrollListener
|
||||||
import com.navinfo.omqs.R
|
|
||||||
import com.navinfo.omqs.databinding.FragmentPhenomenonBinding
|
import com.navinfo.omqs.databinding.FragmentPhenomenonBinding
|
||||||
import com.navinfo.omqs.ui.fragment.BaseFragment
|
import com.navinfo.omqs.ui.fragment.BaseFragment
|
||||||
import com.navinfo.omqs.ui.other.shareViewModels
|
import com.navinfo.omqs.ui.other.shareViewModels
|
||||||
@@ -41,12 +37,15 @@ class PhenomenonFragment :
|
|||||||
//左侧菜单
|
//左侧菜单
|
||||||
binding.phenomenonLeftRecyclerview.setHasFixedSize(true)
|
binding.phenomenonLeftRecyclerview.setHasFixedSize(true)
|
||||||
binding.phenomenonLeftRecyclerview.layoutManager = LinearLayoutManager(requireContext())
|
binding.phenomenonLeftRecyclerview.layoutManager = LinearLayoutManager(requireContext())
|
||||||
val leftAdapter = PhenomenonLeftAdapter { _, text ->
|
/**
|
||||||
|
* 监听左侧栏的点击事件
|
||||||
|
*/
|
||||||
|
val leftAdapter = LeftAdapter { _, text ->
|
||||||
viewModel.getProblemTypeList(text)
|
viewModel.getProblemTypeList(text)
|
||||||
}
|
}
|
||||||
binding.phenomenonLeftRecyclerview.adapter = leftAdapter
|
binding.phenomenonLeftRecyclerview.adapter = leftAdapter
|
||||||
//左侧菜单查询结果监听
|
//左侧菜单查询结果监听
|
||||||
viewModel.liveDataClassTypeList.observe(viewLifecycleOwner) {
|
viewModel.liveDataLeftTypeList.observe(viewLifecycleOwner) {
|
||||||
leftAdapter.refreshData(it)
|
leftAdapter.refreshData(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,26 +54,34 @@ class PhenomenonFragment :
|
|||||||
var rightLayoutManager = LinearLayoutManager(requireContext())
|
var rightLayoutManager = LinearLayoutManager(requireContext())
|
||||||
|
|
||||||
binding.phenomenonRightRecyclerview.layoutManager = rightLayoutManager
|
binding.phenomenonRightRecyclerview.layoutManager = rightLayoutManager
|
||||||
val rightAdapter = PhenomenonRightGroupHeaderAdapter { _, bean ->
|
/**
|
||||||
|
* 监听右侧栏的点击事件
|
||||||
|
*/
|
||||||
|
val rightAdapter = RightGroupHeaderAdapter { _, bean ->
|
||||||
viewModel.setPhenomenonMiddleBean(bean)
|
viewModel.setPhenomenonMiddleBean(bean)
|
||||||
}
|
}
|
||||||
binding.phenomenonRightRecyclerview.adapter = rightAdapter
|
binding.phenomenonRightRecyclerview.adapter = rightAdapter
|
||||||
//右侧菜单增加组标题
|
//右侧菜单增加组标题
|
||||||
binding.phenomenonRightRecyclerview.addItemDecoration(
|
binding.phenomenonRightRecyclerview.addItemDecoration(
|
||||||
PhenomenonRightGroupHeaderDecoration(
|
RightGroupHeaderDecoration(
|
||||||
requireContext()
|
requireContext()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
//右侧菜单查询数据监听
|
//右侧菜单查询数据监听
|
||||||
viewModel.liveDataPhenomenonRightList.observe(viewLifecycleOwner) {
|
viewModel.liveDataRightTypeList.observe(viewLifecycleOwner) {
|
||||||
rightAdapter.refreshData(it)
|
rightAdapter.refreshData(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
val middleAdapter = PhenomenonMiddleAdapter { _, title ->
|
/**
|
||||||
|
* 监听中间栏的点击事件
|
||||||
|
*/
|
||||||
|
val middleAdapter = MiddleAdapter { _, title ->
|
||||||
rightLayoutManager.scrollToPositionWithOffset(rightAdapter.getGroupTopIndex(title), 0)
|
rightLayoutManager.scrollToPositionWithOffset(rightAdapter.getGroupTopIndex(title), 0)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监控右侧滚动,更新左侧
|
||||||
|
*/
|
||||||
binding.phenomenonRightRecyclerview.addOnScrollListener(object :
|
binding.phenomenonRightRecyclerview.addOnScrollListener(object :
|
||||||
OnScrollListener() {
|
OnScrollListener() {
|
||||||
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||||
@@ -98,7 +105,7 @@ class PhenomenonFragment :
|
|||||||
binding.phenomenonMiddleRecyclerview.layoutManager = LinearLayoutManager(requireContext())
|
binding.phenomenonMiddleRecyclerview.layoutManager = LinearLayoutManager(requireContext())
|
||||||
binding.phenomenonMiddleRecyclerview.adapter = middleAdapter
|
binding.phenomenonMiddleRecyclerview.adapter = middleAdapter
|
||||||
//中间侧菜单查询结果监听
|
//中间侧菜单查询结果监听
|
||||||
viewModel.liveDataProblemTypeList.observe(viewLifecycleOwner) {
|
viewModel.liveDataMiddleTypeList.observe(viewLifecycleOwner) {
|
||||||
middleAdapter.refreshData(it)
|
middleAdapter.refreshData(it)
|
||||||
}
|
}
|
||||||
binding.phenomenonDrawer.setOnClickListener {
|
binding.phenomenonDrawer.setOnClickListener {
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package com.navinfo.omqs.ui.fragment.evaluationresult
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 问题现象列表
|
|
||||||
*/
|
|
||||||
data class PhenomenonMiddleBean(val title: String, val text: String, var isSelect: Boolean = false)
|
|
||||||
@@ -35,22 +35,22 @@ class ProblemLinkFragment : BaseFragment() {
|
|||||||
var rightLayoutManager = LinearLayoutManager(requireContext())
|
var rightLayoutManager = LinearLayoutManager(requireContext())
|
||||||
|
|
||||||
binding.linkRightRecyclerview.layoutManager = rightLayoutManager
|
binding.linkRightRecyclerview.layoutManager = rightLayoutManager
|
||||||
val rightAdapter = PhenomenonRightGroupHeaderAdapter { _, bean ->
|
val rightAdapter = RightGroupHeaderAdapter { _, bean ->
|
||||||
viewModel.setProblemLinkMiddleBean(bean)
|
viewModel.setProblemLinkMiddleBean(bean)
|
||||||
}
|
}
|
||||||
binding.linkRightRecyclerview.adapter = rightAdapter
|
binding.linkRightRecyclerview.adapter = rightAdapter
|
||||||
//右侧菜单增加组标题
|
//右侧菜单增加组标题
|
||||||
binding.linkRightRecyclerview.addItemDecoration(
|
binding.linkRightRecyclerview.addItemDecoration(
|
||||||
PhenomenonRightGroupHeaderDecoration(
|
RightGroupHeaderDecoration(
|
||||||
requireContext()
|
requireContext()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
//右侧菜单查询数据监听
|
//右侧菜单查询数据监听
|
||||||
viewModel.liveDataPhenomenonRightList.observe(viewLifecycleOwner) {
|
viewModel.liveDataRightTypeList.observe(viewLifecycleOwner) {
|
||||||
rightAdapter.refreshData(it)
|
rightAdapter.refreshData(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
val middleAdapter = PhenomenonMiddleAdapter { _, title ->
|
val middleAdapter = MiddleAdapter { _, title ->
|
||||||
rightLayoutManager.scrollToPositionWithOffset(rightAdapter.getGroupTopIndex(title), 0)
|
rightLayoutManager.scrollToPositionWithOffset(rightAdapter.getGroupTopIndex(title), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ class ProblemLinkFragment : BaseFragment() {
|
|||||||
binding.linkMiddleRecyclerview.layoutManager = LinearLayoutManager(requireContext())
|
binding.linkMiddleRecyclerview.layoutManager = LinearLayoutManager(requireContext())
|
||||||
binding.linkMiddleRecyclerview.adapter = middleAdapter
|
binding.linkMiddleRecyclerview.adapter = middleAdapter
|
||||||
//中间侧菜单查询结果监听
|
//中间侧菜单查询结果监听
|
||||||
viewModel.liveDataProblemTypeList.observe(viewLifecycleOwner) {
|
viewModel.liveDataMiddleTypeList.observe(viewLifecycleOwner) {
|
||||||
middleAdapter.refreshData(it)
|
middleAdapter.refreshData(it)
|
||||||
}
|
}
|
||||||
binding.linkDrawer.setOnClickListener {
|
binding.linkDrawer.setOnClickListener {
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.navinfo.omqs.ui.fragment.evaluationresult
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 问题现象列表
|
||||||
|
*/
|
||||||
|
data class RightBean(val title: String, val text: String, var isSelect: Boolean = false)
|
||||||
@@ -7,8 +7,8 @@ import com.navinfo.omqs.databinding.TextItemSelectBinding
|
|||||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||||
|
|
||||||
class PhenomenonRightGroupHeaderAdapter(private var itemListener: ((Int, PhenomenonMiddleBean) -> Unit?)? = null) :
|
class RightGroupHeaderAdapter(private var itemListener: ((Int, RightBean) -> Unit?)? = null) :
|
||||||
BaseRecyclerViewAdapter<PhenomenonMiddleBean>() {
|
BaseRecyclerViewAdapter<RightBean>() {
|
||||||
private var groupTitleList = mutableListOf<String>()
|
private var groupTitleList = mutableListOf<String>()
|
||||||
override fun getItemViewRes(position: Int): Int {
|
override fun getItemViewRes(position: Int): Int {
|
||||||
return R.layout.text_item_select
|
return R.layout.text_item_select
|
||||||
@@ -85,7 +85,7 @@ class PhenomenonRightGroupHeaderAdapter(private var itemListener: ((Int, Phenome
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun refreshData(newData: List<PhenomenonMiddleBean>) {
|
override fun refreshData(newData: List<RightBean>) {
|
||||||
super.refreshData(newData)
|
super.refreshData(newData)
|
||||||
groupTitleList.clear()
|
groupTitleList.clear()
|
||||||
for (item in newData) {
|
for (item in newData) {
|
||||||
@@ -5,7 +5,6 @@ import android.graphics.Canvas
|
|||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.Paint
|
import android.graphics.Paint
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.util.Log
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
@@ -15,7 +14,7 @@ import androidx.recyclerview.widget.RecyclerView.ItemDecoration
|
|||||||
/**
|
/**
|
||||||
* 自定义装饰器(实现分组+吸顶效果)
|
* 自定义装饰器(实现分组+吸顶效果)
|
||||||
*/
|
*/
|
||||||
class PhenomenonRightGroupHeaderDecoration(context: Context) : ItemDecoration() {
|
class RightGroupHeaderDecoration(context: Context) : ItemDecoration() {
|
||||||
//头部的高
|
//头部的高
|
||||||
private val mItemHeaderHeight: Int
|
private val mItemHeaderHeight: Int
|
||||||
private val mTextPaddingLeft: Int
|
private val mTextPaddingLeft: Int
|
||||||
@@ -48,8 +47,8 @@ class PhenomenonRightGroupHeaderDecoration(context: Context) : ItemDecoration()
|
|||||||
* @param state
|
* @param state
|
||||||
*/
|
*/
|
||||||
override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
|
override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
|
||||||
if (parent.adapter is PhenomenonRightGroupHeaderAdapter) {
|
if (parent.adapter is RightGroupHeaderAdapter) {
|
||||||
val adapter = parent.adapter as PhenomenonRightGroupHeaderAdapter
|
val adapter = parent.adapter as RightGroupHeaderAdapter
|
||||||
val count = parent.childCount //获取可见范围内Item的总数
|
val count = parent.childCount //获取可见范围内Item的总数
|
||||||
for (i in 0 until count) {
|
for (i in 0 until count) {
|
||||||
val view: View = parent.getChildAt(i)
|
val view: View = parent.getChildAt(i)
|
||||||
@@ -99,8 +98,8 @@ class PhenomenonRightGroupHeaderDecoration(context: Context) : ItemDecoration()
|
|||||||
* @param state
|
* @param state
|
||||||
*/
|
*/
|
||||||
override fun onDrawOver(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
|
override fun onDrawOver(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
|
||||||
if (parent.adapter is PhenomenonRightGroupHeaderAdapter) {
|
if (parent.adapter is RightGroupHeaderAdapter) {
|
||||||
val adapter = parent.adapter as PhenomenonRightGroupHeaderAdapter
|
val adapter = parent.adapter as RightGroupHeaderAdapter
|
||||||
val position =
|
val position =
|
||||||
(parent.layoutManager as LinearLayoutManager?)!!.findFirstVisibleItemPosition()
|
(parent.layoutManager as LinearLayoutManager?)!!.findFirstVisibleItemPosition()
|
||||||
parent.findViewHolderForAdapterPosition(position)?.let {
|
parent.findViewHolderForAdapterPosition(position)?.let {
|
||||||
@@ -169,8 +168,8 @@ class PhenomenonRightGroupHeaderDecoration(context: Context) : ItemDecoration()
|
|||||||
parent: RecyclerView,
|
parent: RecyclerView,
|
||||||
state: RecyclerView.State
|
state: RecyclerView.State
|
||||||
) {
|
) {
|
||||||
if (parent.adapter is PhenomenonRightGroupHeaderAdapter) {
|
if (parent.adapter is RightGroupHeaderAdapter) {
|
||||||
val adapter = parent.adapter as PhenomenonRightGroupHeaderAdapter
|
val adapter = parent.adapter as RightGroupHeaderAdapter
|
||||||
//获取当前view在整个列表中的位置
|
//获取当前view在整个列表中的位置
|
||||||
val position = parent.getChildLayoutPosition(view)
|
val position = parent.getChildLayoutPosition(view)
|
||||||
//是不是改组的第一个
|
//是不是改组的第一个
|
||||||
@@ -180,7 +179,7 @@ class PhenomenonRightGroupHeaderDecoration(context: Context) : ItemDecoration()
|
|||||||
if (adapter.isLastGroupTitle(position)) {
|
if (adapter.isLastGroupTitle(position)) {
|
||||||
lastGroupView = view
|
lastGroupView = view
|
||||||
}
|
}
|
||||||
} else if (position == (parent.adapter as PhenomenonRightGroupHeaderAdapter).itemCount - 1) {
|
} else if (position == (parent.adapter as RightGroupHeaderAdapter).itemCount - 1) {
|
||||||
//判断这条是不是最后一条
|
//判断这条是不是最后一条
|
||||||
//如果是最后一个,找到他所在组的第一个
|
//如果是最后一个,找到他所在组的第一个
|
||||||
lastGroupView?.let {
|
lastGroupView?.let {
|
||||||
@@ -71,15 +71,16 @@ class PersonalCenterViewModel @Inject constructor(
|
|||||||
val list = mutableListOf<ScProblemTypeBean>()
|
val list = mutableListOf<ScProblemTypeBean>()
|
||||||
for (i in 1 until rowCount) {
|
for (i in 1 until rowCount) {
|
||||||
val row: Row = it.getRow(i) // 获取行
|
val row: Row = it.getRow(i) // 获取行
|
||||||
val cellCount: Int = row.physicalNumberOfCells // 获取列数
|
// val cellCount: Int = row.physicalNumberOfCells // 获取列数
|
||||||
if (cellCount == 3) {
|
val bean = ScProblemTypeBean(
|
||||||
val bean = ScProblemTypeBean()
|
elementType = row.getCell(0).stringCellValue,
|
||||||
bean.classType = row.getCell(0).stringCellValue
|
elementCode = row.getCell(1).numericCellValue.toString(),
|
||||||
bean.problemType = row.getCell(1).stringCellValue
|
classType = row.getCell(2).stringCellValue,
|
||||||
bean.phenomenon = row.getCell(2).stringCellValue
|
problemType = row.getCell(3).stringCellValue,
|
||||||
list.add(bean)
|
phenomenon = row.getCell(4).stringCellValue
|
||||||
Log.e("jingo", bean.toString())
|
)
|
||||||
}
|
list.add(bean)
|
||||||
|
Log.e("jingo", bean.toString())
|
||||||
}
|
}
|
||||||
roomAppDatabase.getScProblemTypeDao().insertOrUpdateList(list)
|
roomAppDatabase.getScProblemTypeDao().insertOrUpdateList(list)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,10 +98,9 @@
|
|||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/main_activity_drawer_fragment"
|
android:id="@+id/main_activity_drawer_fragment"
|
||||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="300dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="left"
|
android:layout_gravity="left"
|
||||||
app:layout_constraintHorizontal_bias="0.3"
|
|
||||||
app:navGraph="@navigation/left_drawer_nav_graph" />
|
app:navGraph="@navigation/left_drawer_nav_graph" />
|
||||||
|
|
||||||
</androidx.drawerlayout.widget.DrawerLayout>
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
|
|||||||
@@ -1,97 +1,120 @@
|
|||||||
<?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"
|
<layout 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_height="match_parent"
|
|
||||||
android:background="@color/white"
|
|
||||||
tools:context=".ui.fragment.evaluationresult.EvaluationResultFragment">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<data>
|
||||||
android:id="@+id/evaluation_appbar_layout"
|
<variable
|
||||||
|
name="fragment"
|
||||||
|
type="com.navinfo.omqs.ui.fragment.evaluationresult.EvaluationResultFragment"
|
||||||
|
/>
|
||||||
|
<variable
|
||||||
|
name="viewModel"
|
||||||
|
type="com.navinfo.omqs.ui.fragment.evaluationresult.EvaluationResultViewModel" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
android:background="@color/white"
|
||||||
|
tools:context=".ui.fragment.evaluationresult.EvaluationResultFragment">
|
||||||
|
|
||||||
<com.google.android.material.appbar.MaterialToolbar
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/evaluation_bar"
|
android:id="@+id/evaluation_appbar_layout"
|
||||||
style="@style/Widget.MaterialComponents.Toolbar.Surface"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/default_blue"
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
app:menu="@menu/evaluation_bar_mean"
|
|
||||||
app:navigationIcon="@drawable/btn_back_xml"
|
|
||||||
app:title="测评结果" />
|
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
|
android:id="@+id/evaluation_bar"
|
||||||
<androidx.core.widget.NestedScrollView
|
style="@style/Widget.MaterialComponents.Toolbar.Surface"
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:padding="10dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/evaluation_appbar_layout">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="问题分类" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/evaluation_class_type"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:layout_marginTop="5dp"
|
android:background="@color/default_blue"
|
||||||
android:background="@drawable/fm_card_map_down_status_bg" />
|
app:menu="@menu/evaluation_bar_mean"
|
||||||
|
app:navigationIcon="@drawable/btn_back_xml"
|
||||||
|
app:title="测评结果" />
|
||||||
|
|
||||||
<TextView
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
android:id="@+id/evaluation_problem_type"
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:padding="10dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/evaluation_appbar_layout">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="5dp"
|
android:orientation="vertical">
|
||||||
android:background="@drawable/fm_card_map_down_status_bg" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/evaluation_phenomenon"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:text="问题分类" />
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:background="@drawable/fm_card_map_down_status_bg" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/evaluation_link"
|
android:id="@+id/evaluation_class_type"
|
||||||
android:layout_width="match_parent"
|
text="@{viewModel.liveDataQsRecordBean.classType}"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/fm_card_map_down_status_bg" />
|
android:layout_marginTop="5dp"
|
||||||
|
android:onClick="@{fragment.onClick}"
|
||||||
|
android:background="@drawable/fm_card_map_down_status_bg" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/evaluation_cause"
|
android:id="@+id/evaluation_problem_type"
|
||||||
android:layout_width="match_parent"
|
text="@{viewModel.liveDataQsRecordBean.problemType}"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/fm_card_map_down_status_bg" />
|
android:layout_marginTop="5dp"
|
||||||
|
android:onClick="@{fragment.onClick}"
|
||||||
|
android:background="@drawable/fm_card_map_down_status_bg" />
|
||||||
|
|
||||||
<!-- <com.google.android.material.tabs.TabLayout-->
|
<TextView
|
||||||
<!-- android:id="@+id/evaluation_class_tab_layout"-->
|
android:id="@+id/evaluation_phenomenon"
|
||||||
<!-- android:layout_width="match_parent"-->
|
text="@{viewModel.liveDataQsRecordBean.phenomenon}"
|
||||||
<!-- android:layout_height="wrap_content"-->
|
android:layout_width="match_parent"
|
||||||
<!-- android:layout_marginTop="5dp" />-->
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:onClick="@{fragment.onClick}"
|
||||||
|
android:background="@drawable/fm_card_map_down_status_bg" />
|
||||||
|
|
||||||
<!-- <androidx.viewpager2.widget.ViewPager2-->
|
<TextView
|
||||||
<!-- android:id="@+id/evaluation_viewpager"-->
|
android:id="@+id/evaluation_link"
|
||||||
<!-- android:layout_width="match_parent"-->
|
text="@{viewModel.liveDataQsRecordBean.problemLink}"
|
||||||
<!-- android:layout_height="match_parent"-->
|
android:layout_width="match_parent"
|
||||||
<!-- android:layout_marginTop="5dp" />-->
|
android:layout_height="wrap_content"
|
||||||
</LinearLayout>
|
android:layout_marginTop="5dp"
|
||||||
</androidx.core.widget.NestedScrollView>
|
android:onClick="@{fragment.onClick}"
|
||||||
|
android:background="@drawable/fm_card_map_down_status_bg" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
<TextView
|
||||||
|
android:id="@+id/evaluation_cause"
|
||||||
|
text="@{viewModel.liveDataQsRecordBean.cause}"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:onClick="@{fragment.onClick}"
|
||||||
|
android:background="@drawable/fm_card_map_down_status_bg" />
|
||||||
|
|
||||||
|
<!-- <com.google.android.material.tabs.TabLayout-->
|
||||||
|
<!-- android:id="@+id/evaluation_class_tab_layout"-->
|
||||||
|
<!-- android:layout_width="match_parent"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:layout_marginTop="5dp" />-->
|
||||||
|
|
||||||
|
<!-- <androidx.viewpager2.widget.ViewPager2-->
|
||||||
|
<!-- android:id="@+id/evaluation_viewpager"-->
|
||||||
|
<!-- android:layout_width="match_parent"-->
|
||||||
|
<!-- android:layout_height="match_parent"-->
|
||||||
|
<!-- android:layout_marginTop="5dp" />-->
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</layout>
|
||||||
@@ -15,5 +15,10 @@
|
|||||||
android:id="@+id/EvaluationResultFragment"
|
android:id="@+id/EvaluationResultFragment"
|
||||||
android:name="com.navinfo.omqs.ui.fragment.evaluationresult.EvaluationResultFragment"
|
android:name="com.navinfo.omqs.ui.fragment.evaluationresult.EvaluationResultFragment"
|
||||||
android:label="评测页面"
|
android:label="评测页面"
|
||||||
tools:layout="@layout/fragment_evaluation_result"></fragment>
|
tools:layout="@layout/fragment_evaluation_result">
|
||||||
|
<argument
|
||||||
|
android:name="QsId"
|
||||||
|
app:argType="string"
|
||||||
|
app:nullable="true" />
|
||||||
|
</fragment>
|
||||||
</navigation>
|
</navigation>
|
||||||
@@ -36,7 +36,7 @@ open class QsRecordBean @JvmOverloads constructor(
|
|||||||
/**
|
/**
|
||||||
* 问题类型
|
* 问题类型
|
||||||
*/
|
*/
|
||||||
var type: String = "",
|
var problemType: String = "",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 问题现象
|
* 问题现象
|
||||||
|
|||||||
@@ -10,15 +10,7 @@ import org.oscim.layers.marker.MarkerItem
|
|||||||
*10:51
|
*10:51
|
||||||
*说明()
|
*说明()
|
||||||
*/
|
*/
|
||||||
class ClusterMarkerItem(uid: Any?, title: String?, description: String?, geoPoint: GeoPoint?) :
|
class ClusterMarkerItem(uid: Any, title: String?, description: String?, geoPoint: GeoPoint) :
|
||||||
MarkerItem(uid, title, description, geoPoint) {
|
MarkerItem(uid, title, description, geoPoint) {
|
||||||
var clusterList: List<Int> = ArrayList()
|
var clusterList: List<Int> = ArrayList()
|
||||||
|
|
||||||
constructor(title: String?, description: String?, geoPoint: GeoPoint?) : this(
|
|
||||||
null,
|
|
||||||
title,
|
|
||||||
description,
|
|
||||||
geoPoint
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -34,10 +34,12 @@ import org.oscim.layers.marker.*
|
|||||||
import org.oscim.layers.tile.buildings.BuildingLayer
|
import org.oscim.layers.tile.buildings.BuildingLayer
|
||||||
import org.oscim.layers.tile.vector.VectorTileLayer
|
import org.oscim.layers.tile.vector.VectorTileLayer
|
||||||
import org.oscim.layers.tile.vector.labeling.LabelLayer
|
import org.oscim.layers.tile.vector.labeling.LabelLayer
|
||||||
|
import org.oscim.map.Map.UpdateListener
|
||||||
import org.oscim.tiling.source.OkHttpEngine.OkHttpFactory
|
import org.oscim.tiling.source.OkHttpEngine.OkHttpFactory
|
||||||
import org.oscim.tiling.source.mapfile.MapFileTileSource
|
import org.oscim.tiling.source.mapfile.MapFileTileSource
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import java.util.stream.Collectors
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer 操作
|
* Layer 操作
|
||||||
@@ -62,7 +64,8 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
private lateinit var canvas: org.oscim.backend.canvas.Canvas
|
private lateinit var canvas: org.oscim.backend.canvas.Canvas
|
||||||
private lateinit var itemizedLayer: MyItemizedLayer
|
private lateinit var itemizedLayer: MyItemizedLayer
|
||||||
private lateinit var markerRendererFactory: MarkerRendererFactory
|
private lateinit var markerRendererFactory: MarkerRendererFactory
|
||||||
private val markerItemsNames = mutableListOf<MarkerInterface>()
|
private var resId = R.mipmap.map_icon_point_add
|
||||||
|
private var itemListener: OnQsRecordItemClickListener? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文字大小
|
* 文字大小
|
||||||
@@ -79,11 +82,16 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
private fun initMap() {
|
private fun initMap() {
|
||||||
|
|
||||||
loadBaseMap()
|
loadBaseMap()
|
||||||
mMapView.switchTileVectorLayerTheme(NIMapView.MAP_THEME.DEFAULT)
|
|
||||||
//初始化之间数据图层
|
//初始化之间数据图层
|
||||||
initQsRecordDataLayer()
|
initQsRecordDataLayer()
|
||||||
mMapView.vtmMap.updateMap()
|
mMapView.updateMap()
|
||||||
// initMapLifeSource()
|
// initMapLifeSource()
|
||||||
|
// 设置矢量图层均在12级以上才显示
|
||||||
|
mMapView.vtmMap.events.bind(UpdateListener { e, mapPosition ->
|
||||||
|
if (e == org.oscim.map.Map.SCALE_EVENT) {
|
||||||
|
itemizedLayer.isEnabled = mapPosition.getZoomLevel() >= 12
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -144,7 +152,45 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
for (layer in it.layers) {
|
for (layer in it.layers) {
|
||||||
addLayer(layer, NIMapView.LAYER_GROUPS.BASE)
|
addLayer(layer, NIMapView.LAYER_GROUPS.BASE)
|
||||||
}
|
}
|
||||||
mMapView.updateMap()
|
}
|
||||||
|
}
|
||||||
|
mMapView.switchTileVectorLayerTheme(NIMapView.MAP_THEME.DEFAULT)
|
||||||
|
mMapView.updateMap()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setOnQsRecordItemClickListener(listener: OnQsRecordItemClickListener?) {
|
||||||
|
itemListener = listener
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加或更新marker
|
||||||
|
*/
|
||||||
|
suspend fun addOrUpdateQsRecordMark(data: QsRecordBean) {
|
||||||
|
for (item in itemizedLayer.itemList) {
|
||||||
|
if (item is MarkerItem) {
|
||||||
|
if (item.title == data.id) {
|
||||||
|
itemizedLayer.itemList.remove(item)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
createMarkerItem(data)
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
mMapView.updateMap(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除marker
|
||||||
|
*/
|
||||||
|
suspend fun deleteQsRecordMark(data: QsRecordBean) {
|
||||||
|
for (item in itemizedLayer.itemList) {
|
||||||
|
if (item is MarkerItem) {
|
||||||
|
if (item.title == data.id) {
|
||||||
|
itemizedLayer.itemList.remove(item)
|
||||||
|
mMapView.updateMap()
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,6 +199,7 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
* 初始话质检数据图层
|
* 初始话质检数据图层
|
||||||
*/
|
*/
|
||||||
private fun initQsRecordDataLayer() {
|
private fun initQsRecordDataLayer() {
|
||||||
|
|
||||||
canvas = CanvasAdapter.newCanvas()
|
canvas = CanvasAdapter.newCanvas()
|
||||||
paint = CanvasAdapter.newPaint()
|
paint = CanvasAdapter.newPaint()
|
||||||
paint.setTypeface(Paint.FontFamily.DEFAULT, Paint.FontStyle.NORMAL)
|
paint.setTypeface(Paint.FontFamily.DEFAULT, Paint.FontStyle.NORMAL)
|
||||||
@@ -182,50 +229,67 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var resId = R.mipmap.map_icon_point_add
|
itemizedLayer =
|
||||||
|
MyItemizedLayer(
|
||||||
|
mMapView.vtmMap,
|
||||||
|
mutableListOf(),
|
||||||
|
markerRendererFactory,
|
||||||
|
object : MyItemizedLayer.OnItemGestureListener {
|
||||||
|
override fun onItemSingleTapUp(
|
||||||
|
list: MutableList<Int>,
|
||||||
|
nearest: Int
|
||||||
|
): Boolean {
|
||||||
|
itemListener?.let {
|
||||||
|
val idList = mutableListOf<String>()
|
||||||
|
if (list.size == 0) {
|
||||||
|
} else {
|
||||||
|
for (i in list) {
|
||||||
|
val markerInterface: MarkerInterface =
|
||||||
|
itemizedLayer.itemList[i]
|
||||||
|
if (markerInterface is MarkerItem) {
|
||||||
|
idList.add(markerInterface.title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it.onQsRecordList(idList.distinct().toMutableList())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemLongPress(
|
||||||
|
list: MutableList<Int>?,
|
||||||
|
nearest: Int
|
||||||
|
): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
addLayer(itemizedLayer, NIMapView.LAYER_GROUPS.OPERATE)
|
||||||
mContext.lifecycleScope.launch(Dispatchers.IO) {
|
mContext.lifecycleScope.launch(Dispatchers.IO) {
|
||||||
var list = mutableListOf<QsRecordBean>()
|
var list = mutableListOf<QsRecordBean>()
|
||||||
val realm = Realm.getDefaultInstance()
|
val realm = Realm.getDefaultInstance()
|
||||||
realm.executeTransaction {
|
realm.executeTransaction {
|
||||||
val objects =realm.where<QsRecordBean>().findAll()
|
val objects = realm.where<QsRecordBean>().findAll()
|
||||||
list = realm.copyFromRealm(objects)
|
list = realm.copyFromRealm(objects)
|
||||||
}
|
}
|
||||||
realm.close()
|
realm.close()
|
||||||
|
|
||||||
itemizedLayer =
|
|
||||||
MyItemizedLayer(
|
|
||||||
mMapView.vtmMap,
|
|
||||||
mutableListOf(),
|
|
||||||
markerRendererFactory,
|
|
||||||
object : MyItemizedLayer.OnItemGestureListener {
|
|
||||||
override fun onItemSingleTapUp(
|
|
||||||
layer: MyItemizedLayer?,
|
|
||||||
list: MutableList<Int>?,
|
|
||||||
nearest: Int
|
|
||||||
): Boolean {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onItemLongPress(
|
|
||||||
layer: MyItemizedLayer?,
|
|
||||||
list: MutableList<Int>?,
|
|
||||||
nearest: Int
|
|
||||||
): Boolean {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
for (item in list) {
|
for (item in list) {
|
||||||
val bitmap: Bitmap = createTextMarkerBitmap(mContext, item.description, resId)
|
createMarkerItem(item)
|
||||||
if (item.t_lifecycle != 2) {
|
}
|
||||||
val geometry: Geometry? = GeometryTools.createGeometry(item.geometry)
|
}
|
||||||
if (geometry != null) {
|
|
||||||
var geoPoint: GeoPoint? = null
|
}
|
||||||
if (geometry.geometryType != null) {
|
|
||||||
when (geometry.geometryType.uppercase(Locale.getDefault())) {
|
private suspend fun createMarkerItem(item: QsRecordBean) {
|
||||||
"POINT" -> geoPoint =
|
val bitmap: Bitmap = createTextMarkerBitmap(mContext, item.description, resId)
|
||||||
GeoPoint(geometry.coordinate.y, geometry.coordinate.x)
|
if (item.t_lifecycle != 2) {
|
||||||
|
val geometry: Geometry? = GeometryTools.createGeometry(item.geometry)
|
||||||
|
if (geometry != null) {
|
||||||
|
var geoPoint: GeoPoint? = null
|
||||||
|
if (geometry.geometryType != null) {
|
||||||
|
when (geometry.geometryType.uppercase(Locale.getDefault())) {
|
||||||
|
"POINT" -> geoPoint =
|
||||||
|
GeoPoint(geometry.coordinate.y, geometry.coordinate.x)
|
||||||
// "LINESTRING" -> {
|
// "LINESTRING" -> {
|
||||||
// val lineString = geometry as LineString
|
// val lineString = geometry as LineString
|
||||||
// if (lineString != null && lineString.coordinates.size > 0) {
|
// if (lineString != null && lineString.coordinates.size > 0) {
|
||||||
@@ -254,14 +318,14 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
// dataVectorLayer.add(drawablePolygon)
|
// dataVectorLayer.add(drawablePolygon)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (geoPoint != null) {
|
if (geoPoint != null) {
|
||||||
var geoMarkerItem: MarkerItem
|
var geoMarkerItem: MarkerItem
|
||||||
// if (item.getType() === 1) {
|
// if (item.getType() === 1) {
|
||||||
geoMarkerItem = ClusterMarkerItem(
|
geoMarkerItem = ClusterMarkerItem(
|
||||||
1, item.id, item.description, geoPoint
|
1, item.id, item.description, geoPoint
|
||||||
)
|
)
|
||||||
// } else {
|
// } else {
|
||||||
// geoMarkerItem = MarkerItem(
|
// geoMarkerItem = MarkerItem(
|
||||||
// ePointTemp.getType(),
|
// ePointTemp.getType(),
|
||||||
@@ -270,22 +334,21 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
// geoPoint
|
// geoPoint
|
||||||
// )
|
// )
|
||||||
// }
|
// }
|
||||||
markerItemsNames.add(geoMarkerItem)
|
val markerSymbol =
|
||||||
val markerSymbol =
|
MarkerSymbol(bitmap, MarkerSymbol.HotspotPlace.CENTER)
|
||||||
MarkerSymbol(bitmap, MarkerSymbol.HotspotPlace.CENTER)
|
geoMarkerItem.marker = markerSymbol
|
||||||
geoMarkerItem.marker = markerSymbol
|
itemizedLayer.itemList.add(geoMarkerItem)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemizedLayer.addItems(markerItemsNames)
|
|
||||||
addLayer(itemizedLayer, NIMapView.LAYER_GROUPS.OPERATE)
|
|
||||||
withContext(Dispatchers.Main) {
|
|
||||||
itemizedLayer.map().updateMap(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
itemizedLayer.update()
|
||||||
|
}
|
||||||
|
|
||||||
|
itemizedLayer.populate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文字和图片拼装,文字换行
|
* 文字和图片拼装,文字换行
|
||||||
*
|
*
|
||||||
@@ -498,6 +561,9 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface OnQsRecordItemClickListener {
|
||||||
|
fun onQsRecordList(list: MutableList<String>)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础
|
* 基础
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class MyItemizedLayer extends ItemizedLayer {
|
|||||||
|
|
||||||
public boolean run(List list1, int nearest) {
|
public boolean run(List list1, int nearest) {
|
||||||
if (mOnItemGestureListener != null) {
|
if (mOnItemGestureListener != null) {
|
||||||
return mOnItemGestureListener.onItemSingleTapUp(MyItemizedLayer.this, list1, nearest);
|
return mOnItemGestureListener.onItemSingleTapUp(list1, nearest);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ public class MyItemizedLayer extends ItemizedLayer {
|
|||||||
|
|
||||||
public boolean run(List list1, int nearest) {
|
public boolean run(List list1, int nearest) {
|
||||||
if (mOnItemGestureListener != null) {
|
if (mOnItemGestureListener != null) {
|
||||||
return mOnItemGestureListener.onItemLongPress(MyItemizedLayer.this, list1, nearest);
|
return mOnItemGestureListener.onItemLongPress(list1, nearest);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -155,8 +155,8 @@ public class MyItemizedLayer extends ItemizedLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface OnItemGestureListener {
|
public interface OnItemGestureListener {
|
||||||
boolean onItemSingleTapUp(MyItemizedLayer layer, List<Integer> list, int nearest);
|
boolean onItemSingleTapUp(List<Integer> list, int nearest);
|
||||||
|
|
||||||
boolean onItemLongPress(MyItemizedLayer layer, List<Integer> list, int nearest);
|
boolean onItemLongPress(List<Integer> list, int nearest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user