增加地图捕捉数据功能
This commit is contained in:
parent
6da6a4d101
commit
ab5cb7a078
@ -14,6 +14,7 @@
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<!-- 写入扩展存储,向扩展卡写入数据,用于写入离线定位数据-->
|
||||
<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" />
|
||||
<!-- 允许访问振动设备 -->
|
||||
@ -34,10 +35,10 @@
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:largeHeap="true"
|
||||
android:theme="@style/Theme.OMQualityInspection"
|
||||
android:requestLegacyExternalStorage="true">
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.OMQualityInspection">
|
||||
<activity
|
||||
android:name=".ui.activity.login.LoginActivity"
|
||||
android:exported="true"
|
||||
@ -57,7 +58,9 @@
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/Theme.OMQualityInspection" />
|
||||
|
||||
<meta-data android:name="ScopedStorage" android:value="true" />
|
||||
<meta-data
|
||||
android:name="ScopedStorage"
|
||||
android:value="true" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -18,7 +18,7 @@ class OMQSApplication : Application() {
|
||||
FileManager.initRootDir(this)
|
||||
Realm.init(this)
|
||||
val password = "encryp".encodeToByteArray().copyInto(ByteArray(64))
|
||||
// 70617373776f72640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
// 656e6372797000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
Log.d("OMQSApplication", "密码是: ${byteArrayToHexString(password)}")
|
||||
val config = RealmConfiguration.Builder()
|
||||
.directory(File(Constant.DATA_PATH))
|
||||
|
@ -11,20 +11,33 @@ import kotlinx.parcelize.Parcelize
|
||||
data class ScProblemTypeBean(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
var id: Long = 0,
|
||||
/**
|
||||
* elementType
|
||||
* 要素类型
|
||||
*/
|
||||
@ColumnInfo("ELEMENT_TYPE")
|
||||
val elementType: String = "",
|
||||
/**
|
||||
* 要素代码
|
||||
*/
|
||||
@ColumnInfo("ELEMENT_CODE")
|
||||
val elementCode: String = "",
|
||||
/**
|
||||
* 问题分类
|
||||
*/
|
||||
@ColumnInfo("CLASS_TYPE")
|
||||
var classType: String = "",
|
||||
val classType: String = "",
|
||||
|
||||
/**
|
||||
* 问题类型
|
||||
*/
|
||||
@ColumnInfo("TYPE")
|
||||
var problemType: String = "",
|
||||
val problemType: String = "",
|
||||
|
||||
/**
|
||||
* 问题现象
|
||||
*/
|
||||
@ColumnInfo("PHENOMENON")
|
||||
var phenomenon: String = ""
|
||||
val phenomenon: String = ""
|
||||
|
||||
) : Parcelable
|
@ -30,7 +30,7 @@ open class PermissionsActivity : BaseActivity() {
|
||||
permissionList.add(Permission.ACCESS_FINE_LOCATION)
|
||||
permissionList.add(Permission.ACCESS_COARSE_LOCATION)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
permissionList.add(Permission.ACCESS_BACKGROUND_LOCATION)
|
||||
// permissionList.add(Permission.ACCESS_BACKGROUND_LOCATION)
|
||||
}
|
||||
XXPermissions.with(this)
|
||||
// 申请单个权限
|
||||
|
@ -52,8 +52,16 @@ class MainActivity : BaseActivity() {
|
||||
binding.mainActivity = this
|
||||
//给xml传递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() {
|
||||
@ -94,7 +102,7 @@ class MainActivity : BaseActivity() {
|
||||
naviController.navigate(R.id.EvaluationResultFragment)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
super.onBackPressed()
|
||||
}
|
||||
// override fun onBackPressed() {
|
||||
// super.onBackPressed()
|
||||
// }
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
package com.navinfo.omqs.ui.activity.map
|
||||
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
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.scopes.ActivityRetainedScoped
|
||||
import javax.inject.Inject
|
||||
@ -16,6 +18,16 @@ class MainViewModel @Inject constructor(
|
||||
private val mapController: NIMapController,
|
||||
) : 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.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.navigation.NavOptions
|
||||
import androidx.navigation.findNavController
|
||||
import com.navinfo.omqs.R
|
||||
@ -14,30 +15,26 @@ import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
||||
private var _binding: FragmentEvaluationResultBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
private lateinit var binding: FragmentEvaluationResultBinding
|
||||
private val viewModel by shareViewModels<EvaluationResultViewModel>("QsRecode")
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): 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
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
liveDataObserve()
|
||||
|
||||
/**
|
||||
* 点击监听
|
||||
*/
|
||||
binding.evaluationClassType.setOnClickListener(this)
|
||||
binding.evaluationProblemType.setOnClickListener(this)
|
||||
binding.evaluationPhenomenon.setOnClickListener(this)
|
||||
binding.evaluationLink.setOnClickListener(this)
|
||||
binding.evaluationCause.setOnClickListener(this)
|
||||
|
||||
//监听是否退出当前页面
|
||||
viewModel.liveDataFinish.observe(viewLifecycleOwner) {
|
||||
onBackPressed()
|
||||
}
|
||||
//返回按钮点击
|
||||
binding.evaluationBar.setNavigationOnClickListener {
|
||||
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) {
|
||||
// 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() {
|
||||
activity?.apply {
|
||||
findNavController(R.id.main_activity_middle_fragment).navigateUp()
|
||||
}
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,6 +10,7 @@ import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.omqs.db.RoomAppDatabase
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import io.realm.Realm
|
||||
import io.realm.kotlin.where
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.*
|
||||
@ -28,63 +29,32 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
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>>()
|
||||
|
||||
|
||||
/**
|
||||
* 当前选择问题分类 给[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
|
||||
|
||||
var liveDataQsRecordBean = MutableLiveData<QsRecordBean>()
|
||||
|
||||
init {
|
||||
liveDataQsRecordBean.value = QsRecordBean(id = UUID.randomUUID().toString(), classType = "89193")
|
||||
Log.e("jingo", "EvaluationResultViewModel 创建了 ${hashCode()}")
|
||||
mapController.markerHandle.apply {
|
||||
setOnMapClickListener {
|
||||
currentGeoPoint = it
|
||||
liveDataQsRecordBean.value!!.geometry = it.toGeometry()
|
||||
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()
|
||||
getProblemLinkList()
|
||||
}
|
||||
val geoPoint = mapController.locationLayerHandler.getCurrentGeoPoint()
|
||||
geoPoint?.let {
|
||||
liveDataQsRecordBean.value!!.geometry = it.toGeometry()
|
||||
mapController.markerHandle.addMarker(geoPoint, markerTitle)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* //获取问题分类列表
|
||||
*/
|
||||
fun getClassTypeList() {
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val list = roomAppDatabase.getScProblemTypeDao().findClassTypeList()
|
||||
list?.let {
|
||||
//通知页面更新
|
||||
liveDataClassTypeList.postValue(it)
|
||||
//如果右侧栏没数据,给个默认值
|
||||
if (liveDataCurrentClassType.value == null) {
|
||||
liveDataCurrentClassType.postValue(it[0])
|
||||
if (list.isNotEmpty()) {
|
||||
//通知页面更新
|
||||
liveDataLeftTypeList.postValue(it)
|
||||
val classType = 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()
|
||||
list?.let { tl ->
|
||||
if (tl.isNotEmpty()) {
|
||||
val typeTitleList = mutableListOf<String>()
|
||||
val phenomenonRightList = mutableListOf<PhenomenonMiddleBean>()
|
||||
val middleList = mutableListOf<String>()
|
||||
val rightList = mutableListOf<RightBean>()
|
||||
for (item in tl) {
|
||||
if (!typeTitleList.contains(item.problemLink)) {
|
||||
typeTitleList.add(item.problemLink)
|
||||
if (!middleList.contains(item.problemLink)) {
|
||||
middleList.add(item.problemLink)
|
||||
}
|
||||
phenomenonRightList.add(
|
||||
PhenomenonMiddleBean(
|
||||
rightList.add(
|
||||
RightBean(
|
||||
title = item.problemLink, text = item.problemCause, isSelect = false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
if (liveDataCurrentProblemLink.value == null) {
|
||||
liveDataCurrentProblemLink.postValue(phenomenonRightList[0].text)
|
||||
if (liveDataQsRecordBean.value!!.problemLink.isEmpty()) {
|
||||
liveDataQsRecordBean.value!!.problemLink = middleList[0]
|
||||
}
|
||||
if (liveDataCurrentCause.value == null) {
|
||||
liveDataCurrentCause.postValue(typeTitleList[0])
|
||||
if (liveDataQsRecordBean.value!!.cause.isEmpty()) {
|
||||
liveDataQsRecordBean.value!!.cause = rightList[0].text
|
||||
}
|
||||
liveDataProblemTypeList.postValue(typeTitleList)
|
||||
liveDataPhenomenonRightList.postValue(phenomenonRightList)
|
||||
liveDataMiddleTypeList.postValue(middleList)
|
||||
liveDataRightTypeList.postValue(rightList)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,76 +145,90 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
typeList?.let { tl ->
|
||||
if (tl.isNotEmpty()) {
|
||||
val typeTitleList = mutableListOf<String>()
|
||||
val phenomenonRightList = mutableListOf<PhenomenonMiddleBean>()
|
||||
val phenomenonRightList = mutableListOf<RightBean>()
|
||||
for (item in tl) {
|
||||
if (!typeTitleList.contains(item.problemType)) {
|
||||
typeTitleList.add(item.problemType)
|
||||
}
|
||||
phenomenonRightList.add(
|
||||
PhenomenonMiddleBean(
|
||||
RightBean(
|
||||
title = item.problemType, text = item.phenomenon, isSelect = false
|
||||
)
|
||||
)
|
||||
}
|
||||
if (liveDataCurrentPhenomenon.value == null) {
|
||||
liveDataCurrentPhenomenon.postValue(phenomenonRightList[0].text)
|
||||
}
|
||||
if (liveDataCurrentProblemType.value == null) {
|
||||
liveDataCurrentProblemType.postValue(typeTitleList[0])
|
||||
}
|
||||
liveDataProblemTypeList.postValue(typeTitleList)
|
||||
liveDataPhenomenonRightList.postValue(phenomenonRightList)
|
||||
liveDataMiddleTypeList.postValue(typeTitleList)
|
||||
liveDataRightTypeList.postValue(phenomenonRightList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询问题类型
|
||||
* 查询问题类型列表
|
||||
*/
|
||||
fun getProblemTypeList(classType: String) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
liveDataCurrentClassType.postValue(classType)
|
||||
getProblemList(classType)
|
||||
}
|
||||
}
|
||||
|
||||
fun setPhenomenonMiddleBean(bean: PhenomenonMiddleBean) {
|
||||
if (liveDataCurrentPhenomenon.value != bean.text) liveDataCurrentPhenomenon.value =
|
||||
bean.text
|
||||
if (liveDataCurrentProblemType.value != bean.title) liveDataCurrentProblemType.value =
|
||||
bean.title
|
||||
|
||||
/**
|
||||
* 监听右侧栏的点击事件,修改数据
|
||||
*/
|
||||
fun setPhenomenonMiddleBean(adapterBean: RightBean) {
|
||||
liveDataQsRecordBean.value!!.phenomenon = adapterBean.text
|
||||
liveDataQsRecordBean.value!!.problemType = adapterBean.title
|
||||
}
|
||||
|
||||
fun setProblemLinkMiddleBean(bean: PhenomenonMiddleBean) {
|
||||
if (liveDataCurrentProblemLink.value != bean.text) liveDataCurrentProblemLink.value =
|
||||
bean.text
|
||||
if (liveDataCurrentCause.value != bean.title) liveDataCurrentCause.value = bean.title
|
||||
fun setProblemLinkMiddleBean(adapterBean: RightBean) {
|
||||
liveDataQsRecordBean.value!!.cause = adapterBean.text
|
||||
liveDataQsRecordBean.value!!.problemLink = adapterBean.title
|
||||
|
||||
}
|
||||
|
||||
fun saveData() {
|
||||
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)
|
||||
it.copyToRealmOrUpdate(liveDataQsRecordBean.value)
|
||||
}
|
||||
realm.close()
|
||||
mapController.mMapView.updateMap()
|
||||
mapController.layerManagerHandler.addOrUpdateQsRecordMark(liveDataQsRecordBean.value!!)
|
||||
liveDataFinish.postValue(true)
|
||||
}
|
||||
}
|
||||
|
||||
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.BaseViewHolder
|
||||
|
||||
class PhenomenonLeftAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) :
|
||||
class LeftAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) :
|
||||
BaseRecyclerViewAdapter<String>() {
|
||||
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.BaseViewHolder
|
||||
|
||||
class PhenomenonMiddleAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) :
|
||||
class MiddleAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) :
|
||||
BaseRecyclerViewAdapter<String>() {
|
||||
private var selectTitle = ""
|
||||
|
@ -5,13 +5,9 @@ import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
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.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.OnScrollListener
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.FragmentPhenomenonBinding
|
||||
import com.navinfo.omqs.ui.fragment.BaseFragment
|
||||
import com.navinfo.omqs.ui.other.shareViewModels
|
||||
@ -41,12 +37,15 @@ class PhenomenonFragment :
|
||||
//左侧菜单
|
||||
binding.phenomenonLeftRecyclerview.setHasFixedSize(true)
|
||||
binding.phenomenonLeftRecyclerview.layoutManager = LinearLayoutManager(requireContext())
|
||||
val leftAdapter = PhenomenonLeftAdapter { _, text ->
|
||||
/**
|
||||
* 监听左侧栏的点击事件
|
||||
*/
|
||||
val leftAdapter = LeftAdapter { _, text ->
|
||||
viewModel.getProblemTypeList(text)
|
||||
}
|
||||
binding.phenomenonLeftRecyclerview.adapter = leftAdapter
|
||||
//左侧菜单查询结果监听
|
||||
viewModel.liveDataClassTypeList.observe(viewLifecycleOwner) {
|
||||
viewModel.liveDataLeftTypeList.observe(viewLifecycleOwner) {
|
||||
leftAdapter.refreshData(it)
|
||||
}
|
||||
|
||||
@ -55,26 +54,34 @@ class PhenomenonFragment :
|
||||
var rightLayoutManager = LinearLayoutManager(requireContext())
|
||||
|
||||
binding.phenomenonRightRecyclerview.layoutManager = rightLayoutManager
|
||||
val rightAdapter = PhenomenonRightGroupHeaderAdapter { _, bean ->
|
||||
/**
|
||||
* 监听右侧栏的点击事件
|
||||
*/
|
||||
val rightAdapter = RightGroupHeaderAdapter { _, bean ->
|
||||
viewModel.setPhenomenonMiddleBean(bean)
|
||||
}
|
||||
binding.phenomenonRightRecyclerview.adapter = rightAdapter
|
||||
//右侧菜单增加组标题
|
||||
binding.phenomenonRightRecyclerview.addItemDecoration(
|
||||
PhenomenonRightGroupHeaderDecoration(
|
||||
RightGroupHeaderDecoration(
|
||||
requireContext()
|
||||
)
|
||||
)
|
||||
//右侧菜单查询数据监听
|
||||
viewModel.liveDataPhenomenonRightList.observe(viewLifecycleOwner) {
|
||||
viewModel.liveDataRightTypeList.observe(viewLifecycleOwner) {
|
||||
rightAdapter.refreshData(it)
|
||||
}
|
||||
|
||||
val middleAdapter = PhenomenonMiddleAdapter { _, title ->
|
||||
/**
|
||||
* 监听中间栏的点击事件
|
||||
*/
|
||||
val middleAdapter = MiddleAdapter { _, title ->
|
||||
rightLayoutManager.scrollToPositionWithOffset(rightAdapter.getGroupTopIndex(title), 0)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控右侧滚动,更新左侧
|
||||
*/
|
||||
binding.phenomenonRightRecyclerview.addOnScrollListener(object :
|
||||
OnScrollListener() {
|
||||
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||
@ -98,7 +105,7 @@ class PhenomenonFragment :
|
||||
binding.phenomenonMiddleRecyclerview.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.phenomenonMiddleRecyclerview.adapter = middleAdapter
|
||||
//中间侧菜单查询结果监听
|
||||
viewModel.liveDataProblemTypeList.observe(viewLifecycleOwner) {
|
||||
viewModel.liveDataMiddleTypeList.observe(viewLifecycleOwner) {
|
||||
middleAdapter.refreshData(it)
|
||||
}
|
||||
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())
|
||||
|
||||
binding.linkRightRecyclerview.layoutManager = rightLayoutManager
|
||||
val rightAdapter = PhenomenonRightGroupHeaderAdapter { _, bean ->
|
||||
val rightAdapter = RightGroupHeaderAdapter { _, bean ->
|
||||
viewModel.setProblemLinkMiddleBean(bean)
|
||||
}
|
||||
binding.linkRightRecyclerview.adapter = rightAdapter
|
||||
//右侧菜单增加组标题
|
||||
binding.linkRightRecyclerview.addItemDecoration(
|
||||
PhenomenonRightGroupHeaderDecoration(
|
||||
RightGroupHeaderDecoration(
|
||||
requireContext()
|
||||
)
|
||||
)
|
||||
//右侧菜单查询数据监听
|
||||
viewModel.liveDataPhenomenonRightList.observe(viewLifecycleOwner) {
|
||||
viewModel.liveDataRightTypeList.observe(viewLifecycleOwner) {
|
||||
rightAdapter.refreshData(it)
|
||||
}
|
||||
|
||||
val middleAdapter = PhenomenonMiddleAdapter { _, title ->
|
||||
val middleAdapter = MiddleAdapter { _, title ->
|
||||
rightLayoutManager.scrollToPositionWithOffset(rightAdapter.getGroupTopIndex(title), 0)
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ class ProblemLinkFragment : BaseFragment() {
|
||||
binding.linkMiddleRecyclerview.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.linkMiddleRecyclerview.adapter = middleAdapter
|
||||
//中间侧菜单查询结果监听
|
||||
viewModel.liveDataProblemTypeList.observe(viewLifecycleOwner) {
|
||||
viewModel.liveDataMiddleTypeList.observe(viewLifecycleOwner) {
|
||||
middleAdapter.refreshData(it)
|
||||
}
|
||||
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.BaseViewHolder
|
||||
|
||||
class PhenomenonRightGroupHeaderAdapter(private var itemListener: ((Int, PhenomenonMiddleBean) -> Unit?)? = null) :
|
||||
BaseRecyclerViewAdapter<PhenomenonMiddleBean>() {
|
||||
class RightGroupHeaderAdapter(private var itemListener: ((Int, RightBean) -> Unit?)? = null) :
|
||||
BaseRecyclerViewAdapter<RightBean>() {
|
||||
private var groupTitleList = mutableListOf<String>()
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.text_item_select
|
||||
@ -85,7 +85,7 @@ class PhenomenonRightGroupHeaderAdapter(private var itemListener: ((Int, Phenome
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun refreshData(newData: List<PhenomenonMiddleBean>) {
|
||||
override fun refreshData(newData: List<RightBean>) {
|
||||
super.refreshData(newData)
|
||||
groupTitleList.clear()
|
||||
for (item in newData) {
|
@ -5,7 +5,6 @@ import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Rect
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
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 mTextPaddingLeft: Int
|
||||
@ -48,8 +47,8 @@ class PhenomenonRightGroupHeaderDecoration(context: Context) : ItemDecoration()
|
||||
* @param state
|
||||
*/
|
||||
override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
|
||||
if (parent.adapter is PhenomenonRightGroupHeaderAdapter) {
|
||||
val adapter = parent.adapter as PhenomenonRightGroupHeaderAdapter
|
||||
if (parent.adapter is RightGroupHeaderAdapter) {
|
||||
val adapter = parent.adapter as RightGroupHeaderAdapter
|
||||
val count = parent.childCount //获取可见范围内Item的总数
|
||||
for (i in 0 until count) {
|
||||
val view: View = parent.getChildAt(i)
|
||||
@ -99,8 +98,8 @@ class PhenomenonRightGroupHeaderDecoration(context: Context) : ItemDecoration()
|
||||
* @param state
|
||||
*/
|
||||
override fun onDrawOver(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
|
||||
if (parent.adapter is PhenomenonRightGroupHeaderAdapter) {
|
||||
val adapter = parent.adapter as PhenomenonRightGroupHeaderAdapter
|
||||
if (parent.adapter is RightGroupHeaderAdapter) {
|
||||
val adapter = parent.adapter as RightGroupHeaderAdapter
|
||||
val position =
|
||||
(parent.layoutManager as LinearLayoutManager?)!!.findFirstVisibleItemPosition()
|
||||
parent.findViewHolderForAdapterPosition(position)?.let {
|
||||
@ -169,8 +168,8 @@ class PhenomenonRightGroupHeaderDecoration(context: Context) : ItemDecoration()
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
if (parent.adapter is PhenomenonRightGroupHeaderAdapter) {
|
||||
val adapter = parent.adapter as PhenomenonRightGroupHeaderAdapter
|
||||
if (parent.adapter is RightGroupHeaderAdapter) {
|
||||
val adapter = parent.adapter as RightGroupHeaderAdapter
|
||||
//获取当前view在整个列表中的位置
|
||||
val position = parent.getChildLayoutPosition(view)
|
||||
//是不是改组的第一个
|
||||
@ -180,7 +179,7 @@ class PhenomenonRightGroupHeaderDecoration(context: Context) : ItemDecoration()
|
||||
if (adapter.isLastGroupTitle(position)) {
|
||||
lastGroupView = view
|
||||
}
|
||||
} else if (position == (parent.adapter as PhenomenonRightGroupHeaderAdapter).itemCount - 1) {
|
||||
} else if (position == (parent.adapter as RightGroupHeaderAdapter).itemCount - 1) {
|
||||
//判断这条是不是最后一条
|
||||
//如果是最后一个,找到他所在组的第一个
|
||||
lastGroupView?.let {
|
@ -71,15 +71,16 @@ class PersonalCenterViewModel @Inject constructor(
|
||||
val list = mutableListOf<ScProblemTypeBean>()
|
||||
for (i in 1 until rowCount) {
|
||||
val row: Row = it.getRow(i) // 获取行
|
||||
val cellCount: Int = row.physicalNumberOfCells // 获取列数
|
||||
if (cellCount == 3) {
|
||||
val bean = ScProblemTypeBean()
|
||||
bean.classType = row.getCell(0).stringCellValue
|
||||
bean.problemType = row.getCell(1).stringCellValue
|
||||
bean.phenomenon = row.getCell(2).stringCellValue
|
||||
list.add(bean)
|
||||
Log.e("jingo", bean.toString())
|
||||
}
|
||||
// val cellCount: Int = row.physicalNumberOfCells // 获取列数
|
||||
val bean = ScProblemTypeBean(
|
||||
elementType = row.getCell(0).stringCellValue,
|
||||
elementCode = row.getCell(1).numericCellValue.toString(),
|
||||
classType = row.getCell(2).stringCellValue,
|
||||
problemType = row.getCell(3).stringCellValue,
|
||||
phenomenon = row.getCell(4).stringCellValue
|
||||
)
|
||||
list.add(bean)
|
||||
Log.e("jingo", bean.toString())
|
||||
}
|
||||
roomAppDatabase.getScProblemTypeDao().insertOrUpdateList(list)
|
||||
}
|
||||
|
@ -98,10 +98,9 @@
|
||||
<fragment
|
||||
android:id="@+id/main_activity_drawer_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="left"
|
||||
app:layout_constraintHorizontal_bias="0.3"
|
||||
app:navGraph="@navigation/left_drawer_nav_graph" />
|
||||
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
|
@ -1,97 +1,120 @@
|
||||
<?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: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">
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/evaluation_appbar_layout"
|
||||
<data>
|
||||
<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_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
tools:context=".ui.fragment.evaluationresult.EvaluationResultFragment">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/evaluation_bar"
|
||||
style="@style/Widget.MaterialComponents.Toolbar.Surface"
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/evaluation_appbar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/default_blue"
|
||||
app:menu="@menu/evaluation_bar_mean"
|
||||
app:navigationIcon="@drawable/btn_back_xml"
|
||||
app:title="测评结果" />
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<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_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"
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/evaluation_bar"
|
||||
style="@style/Widget.MaterialComponents.Toolbar.Surface"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/fm_card_map_down_status_bg" />
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/default_blue"
|
||||
app:menu="@menu/evaluation_bar_mean"
|
||||
app:navigationIcon="@drawable/btn_back_xml"
|
||||
app:title="测评结果" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/evaluation_problem_type"
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<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_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/fm_card_map_down_status_bg" />
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/evaluation_phenomenon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/fm_card_map_down_status_bg" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="问题分类" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/evaluation_link"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/fm_card_map_down_status_bg" />
|
||||
<TextView
|
||||
android:id="@+id/evaluation_class_type"
|
||||
text="@{viewModel.liveDataQsRecordBean.classType}"
|
||||
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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/evaluation_cause"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/fm_card_map_down_status_bg" />
|
||||
<TextView
|
||||
android:id="@+id/evaluation_problem_type"
|
||||
text="@{viewModel.liveDataQsRecordBean.problemType}"
|
||||
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" />-->
|
||||
<TextView
|
||||
android:id="@+id/evaluation_phenomenon"
|
||||
text="@{viewModel.liveDataQsRecordBean.phenomenon}"
|
||||
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" />
|
||||
|
||||
<!-- <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>
|
||||
<TextView
|
||||
android:id="@+id/evaluation_link"
|
||||
text="@{viewModel.liveDataQsRecordBean.problemLink}"
|
||||
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" />
|
||||
|
||||
</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:name="com.navinfo.omqs.ui.fragment.evaluationresult.EvaluationResultFragment"
|
||||
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>
|
@ -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
|
||||
*说明()
|
||||
*/
|
||||
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) {
|
||||
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.vector.VectorTileLayer
|
||||
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.mapfile.MapFileTileSource
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import java.util.stream.Collectors
|
||||
|
||||
/**
|
||||
* Layer 操作
|
||||
@ -62,7 +64,8 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
private lateinit var canvas: org.oscim.backend.canvas.Canvas
|
||||
private lateinit var itemizedLayer: MyItemizedLayer
|
||||
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() {
|
||||
|
||||
loadBaseMap()
|
||||
mMapView.switchTileVectorLayerTheme(NIMapView.MAP_THEME.DEFAULT)
|
||||
//初始化之间数据图层
|
||||
initQsRecordDataLayer()
|
||||
mMapView.vtmMap.updateMap()
|
||||
mMapView.updateMap()
|
||||
// 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) {
|
||||
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() {
|
||||
|
||||
canvas = CanvasAdapter.newCanvas()
|
||||
paint = CanvasAdapter.newPaint()
|
||||
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) {
|
||||
var list = mutableListOf<QsRecordBean>()
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.executeTransaction {
|
||||
val objects =realm.where<QsRecordBean>().findAll()
|
||||
val objects = realm.where<QsRecordBean>().findAll()
|
||||
list = realm.copyFromRealm(objects)
|
||||
}
|
||||
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) {
|
||||
val bitmap: Bitmap = createTextMarkerBitmap(mContext, item.description, resId)
|
||||
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)
|
||||
createMarkerItem(item)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private suspend fun createMarkerItem(item: QsRecordBean) {
|
||||
val bitmap: Bitmap = createTextMarkerBitmap(mContext, item.description, resId)
|
||||
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" -> {
|
||||
// val lineString = geometry as LineString
|
||||
// if (lineString != null && lineString.coordinates.size > 0) {
|
||||
@ -254,14 +318,14 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
// dataVectorLayer.add(drawablePolygon)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (geoPoint != null) {
|
||||
var geoMarkerItem: MarkerItem
|
||||
}
|
||||
}
|
||||
if (geoPoint != null) {
|
||||
var geoMarkerItem: MarkerItem
|
||||
// if (item.getType() === 1) {
|
||||
geoMarkerItem = ClusterMarkerItem(
|
||||
1, item.id, item.description, geoPoint
|
||||
)
|
||||
geoMarkerItem = ClusterMarkerItem(
|
||||
1, item.id, item.description, geoPoint
|
||||
)
|
||||
// } else {
|
||||
// geoMarkerItem = MarkerItem(
|
||||
// ePointTemp.getType(),
|
||||
@ -270,22 +334,21 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
// geoPoint
|
||||
// )
|
||||
// }
|
||||
markerItemsNames.add(geoMarkerItem)
|
||||
val markerSymbol =
|
||||
MarkerSymbol(bitmap, MarkerSymbol.HotspotPlace.CENTER)
|
||||
geoMarkerItem.marker = markerSymbol
|
||||
}
|
||||
}
|
||||
val markerSymbol =
|
||||
MarkerSymbol(bitmap, MarkerSymbol.HotspotPlace.CENTER)
|
||||
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) {
|
||||
if (mOnItemGestureListener != null) {
|
||||
return mOnItemGestureListener.onItemSingleTapUp(MyItemizedLayer.this, list1, nearest);
|
||||
return mOnItemGestureListener.onItemSingleTapUp(list1, nearest);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -62,7 +62,7 @@ public class MyItemizedLayer extends ItemizedLayer {
|
||||
|
||||
public boolean run(List list1, int nearest) {
|
||||
if (mOnItemGestureListener != null) {
|
||||
return mOnItemGestureListener.onItemLongPress(MyItemizedLayer.this, list1, nearest);
|
||||
return mOnItemGestureListener.onItemLongPress(list1, nearest);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -155,8 +155,8 @@ public class MyItemizedLayer extends ItemizedLayer {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user