This commit is contained in:
squallzhjch
2023-06-02 14:12:25 +08:00
parent b8015a8b20
commit d68e7bd768
9 changed files with 76 additions and 57 deletions

View File

@@ -9,7 +9,7 @@ data class SignBean(
var iconId: Int = 0,
//定位点到目标距离
val distance: Int = 0,
//图表中的问题
//左上图标中的文字
val iconText: String = "",
//绑定的要素id
val elementId: String = "",
@@ -20,7 +20,11 @@ data class SignBean(
//名称
val name: String,
//底部右侧文字
val bottomRightText: String,
val bottomRightText: String = "",
//要素code类型
val elementCode: Int
val elementCode: Int,
//需要展示更多的内容
val moreText: String = "",
//左上角信息
val topRightText: String = ""
) : Parcelable

View File

@@ -16,6 +16,8 @@ import androidx.annotation.RequiresApi
import androidx.core.view.WindowCompat
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@@ -49,7 +51,9 @@ class MainActivity : BaseActivity() {
var switchFragment = false
/**
* 检测是否含有tts插件
*/
private val someActivityResultLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
@@ -136,7 +140,6 @@ 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())
when (event?.action) {
MotionEvent.ACTION_DOWN -> {
voiceOnTouchStart()//Do Something
@@ -147,14 +150,13 @@ class MainActivity : BaseActivity() {
Log.e("qj", "voiceOnTouchStop")
}
}
return v?.onTouchEvent(event) ?: true
}
})
viewModel.liveDataQsRecordIdList.observe(this) {
//处理页面跳转
viewModel.navigation(this, it)
viewModel.navigationRightFragment(this, it)
}
viewModel.liveDataMenuState.observe(this) {
@@ -164,7 +166,6 @@ class MainActivity : BaseActivity() {
} else {
binding.mainActivityMenuGroup.visibility = View.INVISIBLE
}
}
//道路属性面板
@@ -214,6 +215,16 @@ class MainActivity : BaseActivity() {
viewModel.refreshOMDBLayer(it)
}
}
findNavController(R.id.main_activity_right_fragment).addOnDestinationChangedListener { controller, destination, arguments ->
if (destination.id == R.id.RightEmptyFragment) {
binding.mainActivityRightVisibilityButtonsGroup.visibility = View.VISIBLE
} else {
binding.mainActivityRightVisibilityButtonsGroup.visibility = View.GONE
viewModel.setSelectRoad(false)
binding.mainActivitySelectLine.isSelected = false
}
}
}
//根据输入的经纬度跳转坐标
@@ -235,7 +246,7 @@ class MainActivity : BaseActivity() {
val x = parts[0].toDouble()
val y = parts[0].toDouble()
mapController.animationHandler.animationByLatLon(y, x)
}else{
} else {
Toast.makeText(this, "输入格式不正确", Toast.LENGTH_SHORT).show()
}
} catch (e: Exception) {

View File

@@ -3,7 +3,6 @@ package com.navinfo.omqs.ui.activity.map
import android.app.Activity
import android.content.Context
import android.content.DialogInterface
import android.graphics.Color
import android.graphics.drawable.AnimationDrawable
import android.graphics.drawable.BitmapDrawable
import android.os.Build
@@ -16,6 +15,7 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.PopupWindow
import androidx.annotation.RequiresApi
import androidx.constraintlayout.widget.Group
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
@@ -275,15 +275,17 @@ class MainViewModel @Inject constructor(
}
}
}
liveDataTopSignList.postValue(topSignList.distinctBy { it.elementCode })
liveDataSignList.postValue(signList.distinctBy { it.elementCode })
val speechText = SignUtil.getRoadSpeechText(topSignList)
withContext(Dispatchers.Main) {
speakMode?.speakText(speechText)
}
Log.e("jingo", "自动捕捉数据 共${signList.size}")
}else{
mapController.lineHandler.removeLine()
}
}
liveDataTopSignList.postValue(topSignList.distinctBy { it.elementCode })
liveDataSignList.postValue(signList.distinctBy { it.elementCode })
val speechText = SignUtil.getRoadSpeechText(topSignList)
withContext(Dispatchers.Main) {
speakMode?.speakText(speechText)
}
Log.e("jingo", "自动捕捉数据 共${signList.size}")
}
}
@@ -445,27 +447,11 @@ class MainViewModel @Inject constructor(
/**
* 处理页面调转
*/
fun navigation(activity: MainActivity, list: List<String>) {
fun navigationRightFragment(activity: MainActivity, list: List<String>) {
//获取右侧fragment容器
val naviController = activity.findNavController(R.id.main_activity_right_fragment)
naviController.currentDestination?.let { navDestination ->
// when (val fragment =
// activity.supportFragmentManager.findFragmentById(navDestination.id)) {
// //判断右侧的fragment是不是质检数据
//// is EvaluationResultFragment -> {
//// val viewModelFragment =
//// ViewModelProvider(fragment)[EvaluationResultViewModel::class.java]
//// viewModelFragment.notifyData(list)
//// }
// is EmptyFragment -> {
// if (list.size == 1) {
// val bundle = Bundle()
// bundle.putString("QsId", list[0])
// naviController.navigate(R.id.EvaluationResultFragment, bundle)
// }
// }
// }
when (navDestination.id) {
R.id.RightEmptyFragment -> {
if (list.size == 1) {

View File

@@ -32,6 +32,7 @@ class EmptyFragment : Fragment() {
override fun onStart() {
super.onStart()
val currentDestination = findNavController().currentDestination
//有右侧面板的时候
if (currentDestination?.label == "右侧空页面") {
currentDestinationLabel = "右侧空页面"
(activity as MainActivity).setRightSwitchButton(View.GONE)
@@ -40,6 +41,7 @@ class EmptyFragment : Fragment() {
override fun onStop() {
super.onStop()
//没有有右侧面板的时候
if (currentDestinationLabel == "右侧空页面") {
(activity as MainActivity).setRightSwitchButton(View.VISIBLE)
}

View File

@@ -139,10 +139,6 @@ class PhenomenonFragment :
override fun onDestroyView() {
super.onDestroyView()
_binding = null
Log.e("jingo", "PhenomenonFragment onDestroyView ${hashCode()}")
}
override fun onResume() {
super.onResume()
}
}

View File

@@ -6,8 +6,10 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.navinfo.omqs.R
import com.navinfo.omqs.databinding.FragmentProblemLinkBinding
import com.navinfo.omqs.ui.fragment.BaseFragment
import com.navinfo.omqs.ui.other.shareViewModels
@@ -28,7 +30,6 @@ class ProblemLinkFragment : BaseFragment() {
savedInstanceState: Bundle?
): View {
_binding = FragmentProblemLinkBinding.inflate(inflater, container, false)
Log.e("jingo", "linkFragment onCreateView ${hashCode()}")
return binding.root
}
@@ -43,6 +44,9 @@ class ProblemLinkFragment : BaseFragment() {
binding.linkRightRecyclerview.layoutManager = rightLayoutManager
val rightAdapter = RightGroupHeaderAdapter { _, bean ->
viewModel.setProblemLinkMiddleBean(bean)
if (activity != null) {
requireActivity().findNavController(R.id.main_activity_middle_fragment).navigateUp()
}
}
binding.linkRightRecyclerview.adapter = rightAdapter
//右侧菜单增加组标题
@@ -55,6 +59,7 @@ class ProblemLinkFragment : BaseFragment() {
}
//右侧菜单查询数据监听
viewModel.liveDataRightTypeList.observe(viewLifecycleOwner) {
rightAdapter.setSelectTitle(viewModel.liveDataQsRecordBean.value!!.cause)
rightAdapter.refreshData(it)
}
@@ -82,10 +87,5 @@ class ProblemLinkFragment : BaseFragment() {
override fun onDestroyView() {
super.onDestroyView()
_binding = null
Log.e("jingo", "linkFragment onDestroyView ${hashCode()}")
}
override fun onResume() {
super.onResume()
}
}