1、适配上传接口2、代码融合
This commit is contained in:
@@ -12,6 +12,7 @@ import android.widget.EditText
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.activity.viewModels
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
@@ -145,6 +146,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@@ -370,6 +372,7 @@ class MainActivity : BaseActivity() {
|
||||
mapController.mMapView.onPause()
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
viewModel.speakMode?.shutdown()
|
||||
@@ -400,6 +403,7 @@ class MainActivity : BaseActivity() {
|
||||
/**
|
||||
* 打开相机预览
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
fun openCamera() {
|
||||
//显示轨迹图层
|
||||
viewModel.onClickCameraButton(this)
|
||||
@@ -408,6 +412,7 @@ class MainActivity : BaseActivity() {
|
||||
/**
|
||||
* 开关菜单
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
fun onClickMenu() {
|
||||
//显示菜单图层
|
||||
viewModel.onClickMenu()
|
||||
@@ -543,6 +548,7 @@ class MainActivity : BaseActivity() {
|
||||
.animateTo(GeoPoint( mapController.mMapView.vtmMap.mapPosition.geoPoint.latitude,mapController.mMapView.vtmMap.mapPosition.geoPoint.longitude))
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
private fun voiceOnTouchStart() {
|
||||
viewModel.startSoundMetter(this, binding.mainActivityVoice)
|
||||
}
|
||||
@@ -625,6 +631,7 @@ class MainActivity : BaseActivity() {
|
||||
/**
|
||||
* 打开道路名称属性看板,选择的道路在viewmodel里记录,不用
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
fun openRoadNameFragment() {
|
||||
if (viewModel.liveDataRoadName.value != null) {
|
||||
viewModel.showSignMoreInfo(viewModel.liveDataRoadName.value!!)
|
||||
@@ -643,7 +650,6 @@ class MainActivity : BaseActivity() {
|
||||
*/
|
||||
fun onClickTaskLink() {
|
||||
rightController.navigate(R.id.TaskLinkFragment)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -151,7 +151,9 @@ class MainViewModel @Inject constructor(
|
||||
liveDataNILocationList.value = list
|
||||
}
|
||||
})
|
||||
|
||||
initLocation()
|
||||
|
||||
//处理地图点击操作
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
mapController.onMapClickFlow.collectLatest {
|
||||
@@ -172,33 +174,15 @@ class MainViewModel @Inject constructor(
|
||||
/**
|
||||
* 初始化选中的任务高亮高亮
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
private fun initTaskData() {
|
||||
viewModelScope.launch {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val results = realm.where(TaskBean::class.java).findAll()
|
||||
val list = realm.copyFromRealm(results)
|
||||
results.addChangeListener { changes ->
|
||||
val list2 = realm.copyFromRealm(changes)
|
||||
mapController.lineHandler.omdbTaskLinkLayer.removeAll()
|
||||
for (item in list2) {
|
||||
mapController.lineHandler.omdbTaskLinkLayer.addLineList(item.hadLinkDvoList)
|
||||
}
|
||||
}
|
||||
mapController.lineHandler.omdbTaskLinkLayer.removeAll()
|
||||
for (item in list) {
|
||||
mapController.lineHandler.omdbTaskLinkLayer.addLineList(item.hadLinkDvoList)
|
||||
}
|
||||
private suspend fun initTaskData() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
|
||||
if (res != null) {
|
||||
val taskBean = realm.copyFromRealm(res)
|
||||
mapController.lineHandler.omdbTaskLinkLayer.addLineList(taskBean.hadLinkDvoList)
|
||||
}
|
||||
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
|
||||
if (res != null) {
|
||||
val taskBean = realm.copyFromRealm(res)
|
||||
mapController.lineHandler.omdbTaskLinkLayer.addLineList(taskBean.hadLinkDvoList)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,6 +221,7 @@ class MainViewModel @Inject constructor(
|
||||
/**
|
||||
* 初始化定位信息
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
private fun initLocation() {
|
||||
//用于定位点存储到数据库
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
@@ -290,7 +275,12 @@ class MainViewModel @Inject constructor(
|
||||
//用于定位点捕捉道路
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
mapController.locationLayerHandler.niLocationFlow.collectLatest { location ->
|
||||
if (!isSelectRoad()) captureLink(GeoPoint(location.latitude, location.longitude))
|
||||
if (!isSelectRoad()) captureLink(
|
||||
GeoPoint(
|
||||
location.latitude,
|
||||
location.longitude
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,9 +449,13 @@ class MainViewModel @Inject constructor(
|
||||
mCameraDialog!!.stopVideo()
|
||||
try {
|
||||
if (!mCameraDialog!!.getmShareUtil().connectstate) {
|
||||
mCameraDialog!!.updateCameraResources(1, mCameraDialog!!.getmDeviceNum())
|
||||
mCameraDialog!!.updateCameraResources(
|
||||
1,
|
||||
mCameraDialog!!.getmDeviceNum()
|
||||
)
|
||||
}
|
||||
TakePhotoManager.getInstance().getCameraVedioClent(mCameraDialog!!.getmDeviceNum())
|
||||
TakePhotoManager.getInstance()
|
||||
.getCameraVedioClent(mCameraDialog!!.getmDeviceNum())
|
||||
.StopSearch()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
@@ -598,4 +592,5 @@ class MainViewModel @Inject constructor(
|
||||
liveDataSignMoreInfo.value = data
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user