fix: 增加omdb图层管理
This commit is contained in:
15
app/src/main/java/com/navinfo/omqs/bean/SignBean.kt
Normal file
15
app/src/main/java/com/navinfo/omqs/bean/SignBean.kt
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.navinfo.omqs.bean
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class SignBean(
|
||||
//图标ID
|
||||
val iconId: Int,
|
||||
val distance: Int = 0,
|
||||
val iconText: String = "",
|
||||
val elementId: String = "",
|
||||
val linkId: String,
|
||||
val geometry: String,
|
||||
) : Parcelable
|
||||
@@ -67,6 +67,6 @@ open class TaskBean @JvmOverloads constructor(
|
||||
var message: String = ""
|
||||
) : RealmObject() {
|
||||
fun getDownLoadUrl(): String {
|
||||
return "${Constant.SERVER_ADDRESS}devcp/download?fileStr=26"
|
||||
return "${Constant.SERVER_ADDRESS}devcp/download?fileStr=$id"
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import org.oscim.core.MercatorProjection
|
||||
import javax.inject.Inject
|
||||
import kotlin.streams.toList
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class RealmOperateHelper() {
|
||||
@Inject
|
||||
lateinit var niMapController: NIMapController
|
||||
@@ -32,6 +31,7 @@ class RealmOperateHelper() {
|
||||
* @param bufferType 点位外扩距离的单位: 米-Meter,像素-PIXEL
|
||||
* @param sort 是否需要排序
|
||||
* */
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
suspend fun queryLink(
|
||||
point: Point,
|
||||
buffer: Double = DEFAULT_BUFFER,
|
||||
@@ -102,6 +102,7 @@ class RealmOperateHelper() {
|
||||
* @param bufferType 点位外扩距离的单位: 米-Meter,像素-PIXEL
|
||||
* @param sort 是否需要排序
|
||||
* */
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
suspend fun queryElement(
|
||||
point: Point,
|
||||
buffer: Double = DEFAULT_BUFFER,
|
||||
@@ -154,12 +155,13 @@ class RealmOperateHelper() {
|
||||
suspend fun queryLinkByLinkPid(linkPid: String): MutableList<RenderEntity> {
|
||||
val result = mutableListOf<RenderEntity>()
|
||||
withContext(Dispatchers.IO) {
|
||||
val realmList = Realm.getDefaultInstance().where(RenderEntity::class.java)
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val realmList = realm.where(RenderEntity::class.java)
|
||||
.notEqualTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
|
||||
.findAll()
|
||||
result.addAll(realmList)
|
||||
result.addAll(realm.copyFromRealm(realmList))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
44
app/src/main/java/com/navinfo/omqs/tools/LayerConfigUtils.kt
Normal file
44
app/src/main/java/com/navinfo/omqs/tools/LayerConfigUtils.kt
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.navinfo.omqs.tools
|
||||
|
||||
import com.blankj.utilcode.util.FileIOUtils
|
||||
import com.blankj.utilcode.util.SPStaticUtils
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.bean.ImportConfig
|
||||
import java.io.File
|
||||
|
||||
class LayerConfigUtils {
|
||||
companion object {
|
||||
private val omdbConfigFile = File("${Constant.USER_DATA_PATH}", Constant.OMDB_CONFIG)
|
||||
private val otherConfigFile = File("${Constant.USER_DATA_PATH}", Constant.OTHER_CONFIG)
|
||||
private val gson = Gson()
|
||||
|
||||
fun getLayerConfigList(): List<ImportConfig> {
|
||||
// 首先读取Shared文件,如果存在则直接返回,否则读取config文件
|
||||
return SPStaticUtils.getString(Constant.LAYER_MANAGER_CONFIG, null).let {
|
||||
if (this!=null) {
|
||||
val result: List<ImportConfig> = gson.fromJson(it, object : TypeToken<List<ImportConfig>>(){}.type)
|
||||
result
|
||||
} else {
|
||||
LayerConfigUtils.getLayerConfigListFromAssetsFile()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getLayerConfigListFromAssetsFile(): List<ImportConfig> {
|
||||
val resultList = mutableListOf<ImportConfig>()
|
||||
if (omdbConfigFile.exists()) {
|
||||
val omdbConfiStr = FileIOUtils.readFile2String(omdbConfigFile)
|
||||
val omdbConfig = gson.fromJson<ImportConfig>(omdbConfiStr, ImportConfig::class.java)
|
||||
resultList.add(omdbConfig)
|
||||
}
|
||||
if (otherConfigFile.exists()) {
|
||||
val otherConfiStr = FileIOUtils.readFile2String(otherConfigFile)
|
||||
val otherConfig = gson.fromJson<ImportConfig>(otherConfiStr, ImportConfig::class.java)
|
||||
resultList.add(otherConfig)
|
||||
}
|
||||
return resultList
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.navinfo.omqs.ui.activity.login
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.DisplayMetrics
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.activity.viewModels
|
||||
@@ -33,8 +34,35 @@ class LoginActivity : CheckPermissionsActivity() {
|
||||
binding.lifecycleOwner = this
|
||||
binding.activity = this
|
||||
initView()
|
||||
Log.e("jingo", getScreenParams())
|
||||
}
|
||||
|
||||
private fun getScreenParams(): String {
|
||||
val dm = DisplayMetrics();
|
||||
windowManager.defaultDisplay.getMetrics(dm);
|
||||
val heightPixels = dm.heightPixels;//高的像素
|
||||
val widthPixels = dm.widthPixels;//宽的像素
|
||||
val densityDpi = dm.densityDpi;//dpi
|
||||
val xdpi = dm.xdpi;//xdpi
|
||||
val ydpi = dm.ydpi;//ydpi
|
||||
val density = dm.density;//density=dpi/160,密度比
|
||||
val scaledDensity = dm.scaledDensity;//scaledDensity=dpi/160 字体缩放密度比
|
||||
val heightDP = heightPixels / density;//高度的dp
|
||||
val widthDP = widthPixels / density;//宽度的dp
|
||||
var str = "heightPixels: " + heightPixels + "px";
|
||||
str += "\nwidthPixels: " + widthPixels + "px";
|
||||
str += "\ndensityDpi: " + densityDpi + "dpi";
|
||||
str += "\nxdpi: " + xdpi + "dpi";
|
||||
str += "\nydpi: " + ydpi + "dpi";
|
||||
str += "\ndensity: " + density;
|
||||
str += "\nscaledDensity: " + scaledDensity;
|
||||
str += "\nheightDP: " + heightDP + "dp";
|
||||
str += "\nwidthDP: " + widthDP + "dp";
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 观察登录状态,把Observer提出来是为了防止每次数据变化都会有新的observer创建
|
||||
* 还有为了方便释放(需不需要手动释放?不清楚)不需要释放,当viewmodel观察到activity/fragment 的生命周期时会自动释放
|
||||
|
||||
@@ -10,17 +10,24 @@ import androidx.annotation.RequiresApi
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.blankj.utilcode.util.SPStaticUtils
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.bean.ImportConfig
|
||||
import com.navinfo.omqs.databinding.ActivityMainBinding
|
||||
import com.navinfo.omqs.http.offlinemapdownload.OfflineMapDownloadManager
|
||||
import com.navinfo.omqs.tools.LayerConfigUtils
|
||||
import com.navinfo.omqs.ui.activity.BaseActivity
|
||||
import com.navinfo.omqs.util.FlowEventBus
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
import com.navinfo.omqs.ui.widget.RecyclerViewSpacesItemDecoration
|
||||
import org.videolan.vlc.Util
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
@@ -39,12 +46,31 @@ class MainActivity : BaseActivity() {
|
||||
@Inject
|
||||
lateinit var offlineMapDownloadManager: OfflineMapDownloadManager
|
||||
|
||||
private val signAdapter by lazy { SignAdapter() }
|
||||
private val rightController by lazy {
|
||||
findNavController(R.id.main_activity_right_fragment)
|
||||
}
|
||||
|
||||
private val signAdapter by lazy {
|
||||
SignAdapter { position, signBean ->
|
||||
// val directions =
|
||||
// EmptyFragmentDirections.emptyFragmentToEvaluationResultFragment(
|
||||
// )
|
||||
// rightController.navigate(directions)
|
||||
rightController.currentDestination?.let {
|
||||
if (it.id == R.id.EmptyFragment) {
|
||||
val bundle = Bundle()
|
||||
bundle.putParcelable("SignBean", signBean)
|
||||
rightController.navigate(R.id.EvaluationResultFragment, bundle)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
|
||||
|
||||
//初始化地图
|
||||
mapController.init(
|
||||
this,
|
||||
@@ -53,6 +79,8 @@ class MainActivity : BaseActivity() {
|
||||
Constant.MAP_PATH,
|
||||
Constant.USER_DATA_PATH + "/trace.sqlite"
|
||||
)
|
||||
// 在mapController初始化前获取当前OMDB图层显隐
|
||||
viewModel.refreshOMDBLayer(LayerConfigUtils.getLayerConfigList())
|
||||
//关联生命周期
|
||||
binding.lifecycleOwner = this
|
||||
//给xml转递对象
|
||||
@@ -63,19 +91,18 @@ class MainActivity : BaseActivity() {
|
||||
binding.mainActivityVoice.setOnTouchListener(object : View.OnTouchListener {
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
override fun onTouch(v: View?, event: MotionEvent?): Boolean {
|
||||
Log.e("qj",event?.action.toString())
|
||||
Log.e("qj", event?.action.toString())
|
||||
when (event?.action) {
|
||||
MotionEvent.ACTION_DOWN ->{
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
voiceOnTouchStart()//Do Something
|
||||
Log.e("qj","voiceOnTouchStart")
|
||||
Log.e("qj", "voiceOnTouchStart")
|
||||
}
|
||||
MotionEvent.ACTION_UP ->{
|
||||
MotionEvent.ACTION_UP -> {
|
||||
voiceOnTouchStop()//Do Something
|
||||
Log.e("qj","voiceOnTouchStop")
|
||||
Log.e("qj", "voiceOnTouchStop")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return v?.onTouchEvent(event) ?: true
|
||||
}
|
||||
})
|
||||
@@ -86,6 +113,14 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
binding.mainActivitySignRecyclerview.layoutManager = LinearLayoutManager(this)
|
||||
binding.mainActivitySignRecyclerview.adapter = signAdapter
|
||||
//增加4dp的间隔
|
||||
binding.mainActivitySignRecyclerview.addItemDecoration(
|
||||
RecyclerViewSpacesItemDecoration(
|
||||
Util.convertDpToPx(
|
||||
this, 4
|
||||
)
|
||||
)
|
||||
)
|
||||
viewModel.liveDataSignList.observe(this) {
|
||||
signAdapter.refreshData(it)
|
||||
}
|
||||
@@ -93,17 +128,7 @@ class MainActivity : BaseActivity() {
|
||||
lifecycleScope.launch {
|
||||
// 初始化地图图层控制接收器
|
||||
FlowEventBus.subscribe<List<ImportConfig>>(lifecycle, Constant.EVENT_LAYER_MANAGER_CHANGE) {
|
||||
// 根据获取到的配置信息,筛选未勾选的图层名称
|
||||
val omdbVisibleList = it.filter { importConfig->
|
||||
importConfig.tableGroupName == "OMDB数据"
|
||||
}.first().tables.filter { tableInfo ->
|
||||
!tableInfo.checked
|
||||
}.map {
|
||||
tableInfo -> tableInfo.table
|
||||
}.toList()
|
||||
com.navinfo.collect.library.system.Constant.HAD_LAYER_INVISIABLE_ARRAY = omdbVisibleList.toTypedArray()
|
||||
// 刷新地图
|
||||
mapController.mMapView.vtmMap.clearMap()
|
||||
viewModel.refreshOMDBLayer(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -158,14 +183,14 @@ class MainActivity : BaseActivity() {
|
||||
naviController.navigate(R.id.EvaluationResultFragment)*/
|
||||
}
|
||||
|
||||
fun voiceOnTouchStart(){
|
||||
viewModel!!.startSoundMetter(this,binding.mainActivityVoice)
|
||||
fun voiceOnTouchStart() {
|
||||
viewModel.startSoundMetter(this, binding.mainActivityVoice)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
fun voiceOnTouchStop(){
|
||||
if(Constant.IS_VIDEO_SPEED){
|
||||
viewModel!!.stopSoundMeter()
|
||||
fun voiceOnTouchStop() {
|
||||
if (Constant.IS_VIDEO_SPEED) {
|
||||
viewModel.stopSoundMeter()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import androidx.lifecycle.viewModelScope
|
||||
import androidx.navigation.findNavController
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
|
||||
import com.navinfo.collect.library.data.entity.NiLocation
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.handler.OnQsRecordItemClickListener
|
||||
@@ -30,9 +29,11 @@ import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.bean.ImportConfig
|
||||
import com.navinfo.omqs.bean.SignBean
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import com.navinfo.omqs.ui.dialog.CommonDialog
|
||||
import com.navinfo.omqs.ui.manager.TakePhotoManager
|
||||
import com.navinfo.omqs.ui.widget.SignUtil
|
||||
import com.navinfo.omqs.util.DateTimeUtil
|
||||
import com.navinfo.omqs.util.FlowEventBus
|
||||
import com.navinfo.omqs.util.SoundMeter
|
||||
@@ -69,6 +70,7 @@ class MainViewModel @Inject constructor(
|
||||
val liveDataSignList = MutableLiveData<List<SignBean>>()
|
||||
|
||||
var testPoint = GeoPoint(0, 0)
|
||||
|
||||
//语音窗体
|
||||
private var pop: PopupWindow? = null
|
||||
|
||||
@@ -87,7 +89,7 @@ class MainViewModel @Inject constructor(
|
||||
})
|
||||
initLocation()
|
||||
viewModelScope.launch {
|
||||
mapController.onMapClickFlow.collect {
|
||||
mapController.onMapClickFlow.collectLatest {
|
||||
testPoint = it
|
||||
}
|
||||
}
|
||||
@@ -156,9 +158,12 @@ class MainViewModel @Inject constructor(
|
||||
)
|
||||
signList.add(
|
||||
SignBean(
|
||||
iconId = R.drawable.icon_speed_limit,
|
||||
iconText = element.name,
|
||||
iconId = SignUtil.getSignIcon(element),
|
||||
iconText = SignUtil.getSignText(element),
|
||||
distance = distance.toInt(),
|
||||
elementId = element.id,
|
||||
linkId = linkId,
|
||||
geometry = element.geometry
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -184,6 +189,9 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
mapController.lineHandler.removeLine()
|
||||
}
|
||||
}
|
||||
|
||||
//点击相机按钮
|
||||
@@ -226,7 +234,7 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
fun startSoundMetter(context: Context, v: View) {
|
||||
|
||||
if(mSpeakMode==null){
|
||||
if (mSpeakMode == null) {
|
||||
mSpeakMode = SpeakMode(context as Activity?)
|
||||
}
|
||||
|
||||
@@ -270,7 +278,8 @@ class MainViewModel @Inject constructor(
|
||||
}
|
||||
mSpeakMode!!.speakText("结束录音")
|
||||
//获取右侧fragment容器
|
||||
val naviController = (context as Activity).findNavController(R.id.main_activity_right_fragment)
|
||||
val naviController =
|
||||
(context as Activity).findNavController(R.id.main_activity_right_fragment)
|
||||
val bundle = Bundle()
|
||||
bundle.putString("filePath", filePath)
|
||||
naviController.navigate(R.id.EvaluationResultFragment, bundle)
|
||||
@@ -300,6 +309,24 @@ class MainViewModel @Inject constructor(
|
||||
if (pop != null && pop!!.isShowing) pop!!.dismiss()
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新OMDB图层显隐
|
||||
* */
|
||||
fun refreshOMDBLayer(layerConfigList: List<ImportConfig>) {
|
||||
// 根据获取到的配置信息,筛选未勾选的图层名称
|
||||
if (layerConfigList!=null && !layerConfigList.isEmpty()) {
|
||||
val omdbVisibleList = layerConfigList.filter { importConfig->
|
||||
importConfig.tableGroupName == "OMDB数据"
|
||||
}.first().tables.filter { tableInfo ->
|
||||
!tableInfo.checked
|
||||
}.map {
|
||||
tableInfo -> tableInfo.table
|
||||
}.toList()
|
||||
com.navinfo.collect.library.system.Constant.HAD_LAYER_INVISIABLE_ARRAY = omdbVisibleList.toTypedArray()
|
||||
// 刷新地图
|
||||
mapController.mMapView.vtmMap.clearMap()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理页面调转
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.navinfo.omqs.ui.activity.map
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.bean.SignBean
|
||||
import com.navinfo.omqs.databinding.AdapterSignBinding
|
||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
|
||||
class SignAdapter : BaseRecyclerViewAdapter<SignBean>() {
|
||||
class SignAdapter(private var itemListener: ((Int, SignBean) -> Unit?)? = null) :
|
||||
BaseRecyclerViewAdapter<SignBean>() {
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.adapter_sign
|
||||
}
|
||||
@@ -23,5 +25,8 @@ class SignAdapter : BaseRecyclerViewAdapter<SignBean>() {
|
||||
val item = data[position]
|
||||
bd.signMainIcon.background = holder.viewBinding.root.context.getDrawable(item.iconId)
|
||||
bd.signMainIcon.text = item.iconText
|
||||
bd.root.setOnClickListener {
|
||||
itemListener?.invoke(position, item)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.navinfo.omqs.ui.activity.map
|
||||
|
||||
data class SignBean(
|
||||
//图标ID
|
||||
val iconId: Int,
|
||||
val distance: Int = 0,
|
||||
val iconText: String = ""
|
||||
)
|
||||
@@ -13,6 +13,7 @@ import androidx.navigation.NavOptions
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.bean.SignBean
|
||||
import com.navinfo.omqs.databinding.FragmentEvaluationResultBinding
|
||||
import com.navinfo.omqs.ui.fragment.BaseFragment
|
||||
import com.navinfo.omqs.ui.other.shareViewModels
|
||||
@@ -24,6 +25,7 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
||||
private lateinit var binding: FragmentEvaluationResultBinding
|
||||
private val viewModel by shareViewModels<EvaluationResultViewModel>("QsRecode")
|
||||
|
||||
// private val args:EmptyFragmentArgs by navArgs()
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View {
|
||||
@@ -80,15 +82,15 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
||||
binding.evaluationVoice.setOnTouchListener(object : View.OnTouchListener {
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
override fun onTouch(v: View?, event: MotionEvent?): Boolean {
|
||||
Log.e("qj",event?.action.toString())
|
||||
Log.e("qj", event?.action.toString())
|
||||
when (event?.action) {
|
||||
MotionEvent.ACTION_DOWN ->{
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
voiceOnTouchStart()//Do Something
|
||||
Log.e("qj","voiceOnTouchStart")
|
||||
Log.e("qj", "voiceOnTouchStart")
|
||||
}
|
||||
MotionEvent.ACTION_UP ->{
|
||||
MotionEvent.ACTION_UP -> {
|
||||
voiceOnTouchStop()//Do Something
|
||||
Log.e("qj","voiceOnTouchStop")
|
||||
Log.e("qj", "voiceOnTouchStop")
|
||||
}
|
||||
}
|
||||
return v?.onTouchEvent(event) ?: true
|
||||
@@ -98,17 +100,23 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
||||
/**
|
||||
* 读取元数据
|
||||
*/
|
||||
if (arguments != null) {
|
||||
val id = requireArguments().getString("QsId")
|
||||
//语音路径
|
||||
val filePath = requireArguments().getString("filePath")
|
||||
if (id != null) {
|
||||
viewModel.initData(id)
|
||||
} else {
|
||||
viewModel.initNewData(filePath!!)
|
||||
// val id = args.qsId
|
||||
var id: String = ""
|
||||
var signBean: SignBean? = null
|
||||
var filePath: String = ""
|
||||
arguments?.let {
|
||||
id = it.getString("QsId", "")
|
||||
filePath = it.getString("filePath", "")
|
||||
try {
|
||||
signBean = it.getParcelable("SignBean")
|
||||
} catch (e: java.lang.Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
if (id == null || id.isEmpty()) {
|
||||
viewModel.initNewData(signBean, filePath)
|
||||
} else {
|
||||
viewModel.initNewData("")
|
||||
viewModel.initData(id)
|
||||
}
|
||||
// //监听大分类数据变化
|
||||
// viewModel.liveDataClassTypeList.observe(viewLifecycleOwner) {
|
||||
@@ -271,13 +279,13 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
||||
}
|
||||
}
|
||||
|
||||
fun voiceOnTouchStart(){
|
||||
viewModel!!.startSoundMetter(requireActivity(),binding.evaluationVoice)
|
||||
fun voiceOnTouchStart() {
|
||||
viewModel!!.startSoundMetter(requireActivity(), binding.evaluationVoice)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
fun voiceOnTouchStop(){
|
||||
if(Constant.IS_VIDEO_SPEED){
|
||||
fun voiceOnTouchStop() {
|
||||
if (Constant.IS_VIDEO_SPEED) {
|
||||
viewModel!!.stopSoundMeter()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity.Companion.LinkTable
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.omqs.bean.SignBean
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.bean.ChatMsgEntity
|
||||
@@ -108,7 +109,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
super.onCleared()
|
||||
Log.e("jingo", "EvaluationResultViewModel 销毁了 ${hashCode()}")
|
||||
mapController.markerHandle.removeMarker(markerTitle)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
mapController.lineHandler.removeLine()
|
||||
}
|
||||
}
|
||||
@@ -117,25 +118,44 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
/**
|
||||
* 查询数据库,获取问题分类
|
||||
*/
|
||||
fun initNewData(filePath: String) {
|
||||
fun initNewData(bean: SignBean?,filePath: String) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
getClassTypeList()
|
||||
getProblemLinkList()
|
||||
}
|
||||
val geoPoint = mapController.locationLayerHandler.getCurrentGeoPoint()
|
||||
geoPoint?.let {
|
||||
liveDataQsRecordBean.value!!.geometry = GeometryTools.createGeometry(it).toText()
|
||||
mapController.markerHandle.addMarker(geoPoint, markerTitle)
|
||||
viewModelScope.launch {
|
||||
captureLink(geoPoint.longitude, geoPoint.latitude)
|
||||
if (bean == null) {
|
||||
geoPoint?.let {
|
||||
liveDataQsRecordBean.value!!.geometry = GeometryTools.createGeometry(it).toText()
|
||||
mapController.markerHandle.addMarker(geoPoint, markerTitle)
|
||||
viewModelScope.launch {
|
||||
captureLink(geoPoint.longitude, geoPoint.latitude)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
liveDataQsRecordBean.value?.run {
|
||||
elementId = bean.elementId
|
||||
linkId = bean.linkId
|
||||
if (linkId.isNotEmpty()) {
|
||||
viewModelScope.launch {
|
||||
val link = realmOperateHelper.queryLink(linkId)
|
||||
link?.let { l ->
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mapController.lineHandler.showLine(l.geometry)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val point = GeometryTools.createGeoPoint(bean.geometry)
|
||||
mapController.markerHandle.addMarker(point, markerTitle)
|
||||
}
|
||||
|
||||
addChatMsgEntity(filePath)
|
||||
}
|
||||
|
||||
/**
|
||||
* 捕捉到路
|
||||
* 捕捉道路
|
||||
*/
|
||||
private suspend fun captureLink(longitude: Double, latitude: Double) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
@@ -364,7 +384,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
|
||||
fun addChatMsgEntity(filePath: String) {
|
||||
|
||||
if(filePath!=null){
|
||||
if(filePath.isNotEmpty()){
|
||||
var chatMsgEntityList: MutableList<ChatMsgEntity> = ArrayList()
|
||||
if(listDataChatMsgEntityList.value?.isEmpty() == false){
|
||||
chatMsgEntityList = listDataChatMsgEntityList.value!!
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.navinfo.omqs.ui.fragment.evaluationresult
|
||||
|
||||
import android.os.Build
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.TextItemSelectBinding
|
||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
@@ -21,6 +23,7 @@ class LeftAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) :
|
||||
return BaseViewHolder(viewBinding)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||
val bd = holder.viewBinding as TextItemSelectBinding
|
||||
val title = data[position]
|
||||
|
||||
@@ -8,29 +8,17 @@ import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.bean.ImportConfig
|
||||
import com.navinfo.omqs.tools.LayerConfigUtils
|
||||
import com.navinfo.omqs.util.FlowEventBus
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
|
||||
class LayerManagerViewModel(): ViewModel() {
|
||||
private val omdbConfigFile = File("${Constant.USER_DATA_PATH}", Constant.OMDB_CONFIG)
|
||||
private val otherConfigFile = File("${Constant.USER_DATA_PATH}", Constant.OTHER_CONFIG)
|
||||
private val gson = Gson()
|
||||
|
||||
fun getLayerConfigList(): List<ImportConfig> {
|
||||
// 首先读取Shared文件,如果存在则直接返回,否则读取config文件
|
||||
val importConfigList: List<ImportConfig>? = SPStaticUtils.getString(Constant.LAYER_MANAGER_CONFIG, null).run {
|
||||
if (this!=null) {
|
||||
gson.fromJson(this, object : TypeToken<List<ImportConfig>>(){}.type)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
if (importConfigList==null) {
|
||||
return getLayerConfigListFromAssetsFile()
|
||||
} else {
|
||||
return importConfigList as List<ImportConfig>
|
||||
}
|
||||
return LayerConfigUtils.getLayerConfigList()
|
||||
}
|
||||
|
||||
fun saveLayerConfigList(listData: List<ImportConfig>) {
|
||||
@@ -41,18 +29,4 @@ class LayerManagerViewModel(): ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getLayerConfigListFromAssetsFile(): List<ImportConfig> {
|
||||
val resultList = mutableListOf<ImportConfig>()
|
||||
if (omdbConfigFile.exists()) {
|
||||
val omdbConfiStr = FileIOUtils.readFile2String(omdbConfigFile)
|
||||
val omdbConfig = gson.fromJson<ImportConfig>(omdbConfiStr, ImportConfig::class.java)
|
||||
resultList.add(omdbConfig)
|
||||
}
|
||||
if (otherConfigFile.exists()) {
|
||||
val otherConfiStr = FileIOUtils.readFile2String(otherConfigFile)
|
||||
val otherConfig = gson.fromJson<ImportConfig>(otherConfiStr, ImportConfig::class.java)
|
||||
resultList.add(otherConfig)
|
||||
}
|
||||
return resultList
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class QsRecordListFragment : BaseFragment(){
|
||||
binding.qsRecyclerview.addItemDecoration(itemDecoration)
|
||||
viewModel.getList(requireContext())
|
||||
// itemClick
|
||||
adapter!!.setOnKotlinItemClickListener(object : QsRecordListAdapter.IKotlinItemClickListener {
|
||||
adapter.setOnKotlinItemClickListener(object : QsRecordListAdapter.IKotlinItemClickListener {
|
||||
override fun onItemClickListener(position: Int) {
|
||||
viewModel.onItemClickListener(activity as MainActivity,position)
|
||||
findNavController().popBackStack()
|
||||
|
||||
@@ -8,6 +8,10 @@ import android.widget.EditText
|
||||
import androidx.appcompat.widget.AppCompatEditText
|
||||
import com.navinfo.omqs.R
|
||||
|
||||
/**
|
||||
* 滚动嵌套时,处理滚动的edittext
|
||||
*/
|
||||
|
||||
class MyEditeText @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.navinfo.omqs.ui.widget
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.view.View
|
||||
import androidx.annotation.StringDef
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.ItemDecoration
|
||||
import java.lang.annotation.Retention
|
||||
import java.lang.annotation.RetentionPolicy
|
||||
|
||||
/**
|
||||
* 用来设置recyclerView 要素间的间隔
|
||||
*/
|
||||
class RecyclerViewSpacesItemDecoration : ItemDecoration {
|
||||
@StringDef(TOP_DECORATION, BOTTOM_DECORATION, LEFT_DECORATION, RIGHT_DECORATION)
|
||||
@Retention(
|
||||
RetentionPolicy.SOURCE
|
||||
)
|
||||
private annotation class Decoration
|
||||
|
||||
private var rightSpace = 0 //右边间距
|
||||
private var topSpace = 0 //上边边间距
|
||||
private var leftSpace = 0 //左边间距
|
||||
private var bottomSpace = 0 //下边间距
|
||||
|
||||
/**
|
||||
* @param bottomSpace 下间距
|
||||
*/
|
||||
constructor(bottomSpace: Int) {
|
||||
this.bottomSpace = bottomSpace
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定某一个属性
|
||||
*
|
||||
* @param decoration decoration
|
||||
* @param space 间距
|
||||
*/
|
||||
constructor(@Decoration decoration: String?, space: Int) {
|
||||
when (decoration) {
|
||||
RIGHT_DECORATION -> rightSpace = space
|
||||
TOP_DECORATION -> topSpace = space
|
||||
LEFT_DECORATION -> leftSpace = space
|
||||
BOTTOM_DECORATION -> bottomSpace = space
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rightSpace 右间距
|
||||
* @param topSpace 上间距
|
||||
* @param leftSpace 左间距
|
||||
* @param bottomSpace 下间距
|
||||
*/
|
||||
constructor(rightSpace: Int, topSpace: Int, leftSpace: Int, bottomSpace: Int) {
|
||||
this.rightSpace = rightSpace
|
||||
this.topSpace = topSpace
|
||||
this.leftSpace = leftSpace
|
||||
this.bottomSpace = bottomSpace
|
||||
}
|
||||
|
||||
/**
|
||||
* @param outRect Item的矩边界
|
||||
* @param view ItemView
|
||||
* @param parent RecyclerView
|
||||
* @param state RecyclerView的状态
|
||||
*/
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
outRect.top = topSpace
|
||||
outRect.left = leftSpace
|
||||
outRect.right = rightSpace
|
||||
outRect.bottom = bottomSpace
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TOP_DECORATION = "top_decoration"
|
||||
const val BOTTOM_DECORATION = "bottom_decoration"
|
||||
const val LEFT_DECORATION = "left_decoration"
|
||||
const val RIGHT_DECORATION = "right_decoration"
|
||||
}
|
||||
}
|
||||
153
app/src/main/java/com/navinfo/omqs/ui/widget/SignUtil.kt
Normal file
153
app/src/main/java/com/navinfo/omqs/ui/widget/SignUtil.kt
Normal file
@@ -0,0 +1,153 @@
|
||||
package com.navinfo.omqs.ui.widget
|
||||
|
||||
import android.util.Log
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.omqs.R
|
||||
|
||||
class SignUtil {
|
||||
companion object {
|
||||
|
||||
/**
|
||||
* 获取面板上的文字
|
||||
*/
|
||||
fun getSignText(data: RenderEntity): String {
|
||||
return when (data.code) {
|
||||
//常规点限速
|
||||
4002 -> getSpeedLimitText(data)
|
||||
// //道路种别
|
||||
// 2008 -> getKindCodeIcon(data)
|
||||
// //道路方向
|
||||
// 2010 -> getRoadDirection(data)
|
||||
// //车道数
|
||||
// 2041 -> getLaneNumIcon(data)
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取限速值文字
|
||||
*/
|
||||
private fun getSpeedLimitText(data: RenderEntity): String {
|
||||
try {
|
||||
//限速标志 0 限速开始 1 限速解除
|
||||
val maxSpeed = data.properties["max_speed"]
|
||||
val minSpeed = data.properties["min_speed"]
|
||||
return if (maxSpeed != "0")
|
||||
maxSpeed.toString()
|
||||
else
|
||||
minSpeed.toString()
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "获取限速面板ICON出错1 $e")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
/**
|
||||
* 限速图标
|
||||
*/
|
||||
fun getSpeedLimitIcon(data: RenderEntity): Int {
|
||||
try {
|
||||
//限速标志 0 限速开始 1 限速解除
|
||||
val speedFlag = data.properties["speed_flag"]
|
||||
return when (speedFlag) {
|
||||
"1" -> return R.drawable.icon_speed_limit_off
|
||||
else -> return R.drawable.icon_speed_limit
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "获取限速面板ICON出错2 $e")
|
||||
}
|
||||
return R.drawable.icon_speed_limit
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取看板图标
|
||||
*/
|
||||
|
||||
fun getSignIcon(data: RenderEntity): Int {
|
||||
return when (data.code) {
|
||||
//道路种别
|
||||
2008 -> getKindCodeIcon(data)
|
||||
//道路方向
|
||||
2010 -> getRoadDirection(data)
|
||||
//车道数
|
||||
2041 -> getLaneNumIcon(data)
|
||||
//限速
|
||||
4002 -> getSpeedLimitIcon(data)
|
||||
else -> R.drawable.icon_speed_limit
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取种别图标
|
||||
*/
|
||||
fun getKindCodeIcon(data: RenderEntity): Int {
|
||||
try {
|
||||
val kind = data.properties["kind"]
|
||||
return when (kind!!.toInt()) {
|
||||
1 -> R.mipmap.icon_kind_code_k1
|
||||
2 -> R.mipmap.icon_kind_code_k2
|
||||
3 -> R.mipmap.icon_kind_code_k3
|
||||
4 -> R.mipmap.icon_kind_code_k4
|
||||
6 -> R.mipmap.icon_kind_code_k6
|
||||
7 -> R.mipmap.icon_kind_code_k7
|
||||
8 -> R.mipmap.icon_kind_code_k8
|
||||
9 -> R.mipmap.icon_kind_code_k9
|
||||
10 -> R.mipmap.icon_kind_code_k10
|
||||
11 -> R.mipmap.icon_kind_code_k11
|
||||
13 -> R.mipmap.icon_kind_code_k13
|
||||
15 -> R.mipmap.icon_kind_code_k15
|
||||
else -> R.mipmap.icon_kind_code
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "获取种别面板ICON出错 $e")
|
||||
}
|
||||
return R.mipmap.icon_kind_code
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取到路线
|
||||
*/
|
||||
fun getLaneNumIcon(data: RenderEntity): Int {
|
||||
try {
|
||||
val lineNum = data.properties["laneNum"]
|
||||
return when (lineNum!!.toInt()) {
|
||||
1 -> R.mipmap.icon_lane_num1
|
||||
2 -> R.mipmap.icon_lane_num2
|
||||
3 -> R.mipmap.icon_lane_num3
|
||||
4 -> R.mipmap.icon_lane_num4
|
||||
5 -> R.mipmap.icon_lane_num5
|
||||
6 -> R.mipmap.icon_lane_num6
|
||||
7 -> R.mipmap.icon_lane_num7
|
||||
8 -> R.mipmap.icon_lane_num8
|
||||
9 -> R.mipmap.icon_lane_num9
|
||||
10 -> R.mipmap.icon_lane_num10
|
||||
11 -> R.mipmap.icon_lane_num11
|
||||
12 -> R.mipmap.icon_lane_num12
|
||||
else -> R.mipmap.icon_lane_num1
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "获取车道数面板ICON出错 $e")
|
||||
}
|
||||
return R.mipmap.icon_road_direction
|
||||
}
|
||||
|
||||
fun getRoadDirection(data: RenderEntity): Int {
|
||||
try {
|
||||
val direct = data.properties["direct"]
|
||||
return when (direct!!.toInt()) {
|
||||
0 -> R.mipmap.icon_road_direction
|
||||
1 -> R.mipmap.icon_road_direction
|
||||
2 -> R.mipmap.icon_road_direction
|
||||
3 -> R.mipmap.icon_road_direction
|
||||
-99 -> R.mipmap.icon_road_direction
|
||||
else -> R.mipmap.icon_road_direction
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "获取道路方向面板ICON出错 $e")
|
||||
}
|
||||
return R.mipmap.icon_road_direction
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user