修改点击聚合marker崩溃问题
This commit is contained in:
@@ -176,7 +176,7 @@ class MainActivity : BaseActivity() {
|
||||
//给xml传递viewModel对象
|
||||
binding.viewModel = viewModel
|
||||
|
||||
binding.mainActivityVoice.setOnTouchListener { v, event ->
|
||||
binding.mainActivityVoice.setOnTouchListener { v, event ->
|
||||
when (event?.action) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
voiceOnTouchStart()//Do Something
|
||||
@@ -206,7 +206,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
//捕捉列表变化回调
|
||||
viewModel.liveDataNoteIdList.observe(this) {
|
||||
viewModel.liveDataNoteId.observe(this) {
|
||||
//跳转到质检数据页面
|
||||
//获取右侧fragment容器
|
||||
val naviController = findNavController(R.id.main_activity_right_fragment)
|
||||
@@ -214,11 +214,9 @@ class MainActivity : BaseActivity() {
|
||||
naviController.currentDestination?.let { navDestination ->
|
||||
when (navDestination.id) {
|
||||
R.id.RightEmptyFragment -> {
|
||||
if (it.size == 1) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("NoteId", it[0])
|
||||
naviController.navigate(R.id.NoteFragment, bundle)
|
||||
}
|
||||
val bundle = Bundle()
|
||||
bundle.putString("NoteId", it)
|
||||
naviController.navigate(R.id.NoteFragment, bundle)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,8 +233,8 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
//捕捉列表变化回调
|
||||
viewModel.liveDataNILocationList.observe(this) {
|
||||
if(viewModel.isSelectTrace()){
|
||||
Toast.makeText(this,"轨迹被点击了",Toast.LENGTH_LONG).show()
|
||||
if (viewModel.isSelectTrace()) {
|
||||
Toast.makeText(this, "轨迹被点击了", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,8 +542,8 @@ class MainActivity : BaseActivity() {
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
fun tracePointsOnclick() {
|
||||
viewModel.setSelectTrace(!viewModel.isSelectTrace())
|
||||
if(viewModel.isSelectTrace()){
|
||||
Toast.makeText(this,"请选择轨迹点!",Toast.LENGTH_LONG).show()
|
||||
if (viewModel.isSelectTrace()) {
|
||||
Toast.makeText(this, "请选择轨迹点!", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
|
||||
}
|
||||
@@ -628,7 +626,12 @@ class MainActivity : BaseActivity() {
|
||||
mapController.mMapView.setScaleBarLayer(GLViewport.Position.BOTTOM_CENTER, 128, 65)
|
||||
}
|
||||
mapController.mMapView.vtmMap.animator()
|
||||
.animateTo(GeoPoint( mapController.mMapView.vtmMap.mapPosition.geoPoint.latitude,mapController.mMapView.vtmMap.mapPosition.geoPoint.longitude))
|
||||
.animateTo(
|
||||
GeoPoint(
|
||||
mapController.mMapView.vtmMap.mapPosition.geoPoint.latitude,
|
||||
mapController.mMapView.vtmMap.mapPosition.geoPoint.longitude
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
@@ -689,14 +692,14 @@ class MainActivity : BaseActivity() {
|
||||
*/
|
||||
fun showIndoorDataLayout() {
|
||||
binding.mainActivityMenuIndoorGroup.visibility = View.VISIBLE
|
||||
if(Constant.INDOOR_IP.isNotEmpty()){
|
||||
if (Constant.INDOOR_IP.isNotEmpty()) {
|
||||
setIndoorGroupEnable(true)
|
||||
}else{
|
||||
} else {
|
||||
setIndoorGroupEnable(false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setIndoorGroupEnable(enable: Boolean){
|
||||
private fun setIndoorGroupEnable(enable: Boolean) {
|
||||
binding.mainActivitySnapshotFinish.isEnabled = enable
|
||||
binding.mainActivityTraceSnapshotPoints.isEnabled = enable
|
||||
binding.mainActivitySnapshotMediaFlag.isEnabled = enable
|
||||
|
||||
@@ -75,7 +75,7 @@ class MainViewModel @Inject constructor(
|
||||
val liveDataQsRecordIdList = MutableLiveData<List<String>>()
|
||||
|
||||
//地图点击捕捉到的标签ID列表
|
||||
val liveDataNoteIdList = MutableLiveData<List<String>>()
|
||||
val liveDataNoteId = MutableLiveData<String>()
|
||||
|
||||
//地图点击捕捉到的轨迹列表
|
||||
val liveDataNILocationList = MutableLiveData<NiLocation>()
|
||||
@@ -159,8 +159,8 @@ class MainViewModel @Inject constructor(
|
||||
liveDataQsRecordIdList.value = list
|
||||
}
|
||||
|
||||
override fun onNoteList(list: MutableList<String>) {
|
||||
liveDataNoteIdList.value = list
|
||||
override fun onNote(id: String) {
|
||||
liveDataNoteId.value = id
|
||||
}
|
||||
|
||||
override fun onNiLocation(item: NiLocation) {
|
||||
@@ -182,9 +182,7 @@ class MainViewModel @Inject constructor(
|
||||
// testPoint = it
|
||||
//线选择状态
|
||||
if (bSelectRoad) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
captureLink(it)
|
||||
}
|
||||
captureLink(it)
|
||||
} else {
|
||||
captureItem(it)
|
||||
}
|
||||
@@ -249,8 +247,7 @@ class MainViewModel @Inject constructor(
|
||||
//加载轨迹数据
|
||||
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||
val list: List<NiLocation>? = TraceDataBase.getDatabase(
|
||||
mapController.mMapView.context,
|
||||
Constant.USER_DATA_PATH
|
||||
mapController.mMapView.context, Constant.USER_DATA_PATH
|
||||
).niLocationDao.findToTaskIdAll(id.toString())
|
||||
if (list != null) {
|
||||
for (location in list) {
|
||||
@@ -268,11 +265,13 @@ class MainViewModel @Inject constructor(
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
//用于定位点捕捉道路
|
||||
mapController.locationLayerHandler.niLocationFlow.collectLatest { location ->
|
||||
if (!isSelectRoad()&&!GeometryTools.isCheckError(location.longitude,location.latitude)) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
if (!isSelectRoad() && !GeometryTools.isCheckError(
|
||||
location.longitude, location.latitude
|
||||
)
|
||||
) {
|
||||
captureLink(
|
||||
GeoPoint(
|
||||
location.latitude,
|
||||
location.longitude
|
||||
location.latitude, location.longitude
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -280,7 +279,7 @@ class MainViewModel @Inject constructor(
|
||||
mapController.locationLayerHandler.niLocationFlow.collect { location ->
|
||||
|
||||
//过滤掉无效点
|
||||
if(!GeometryTools.isCheckError(location.longitude,location.latitude)){
|
||||
if (!GeometryTools.isCheckError(location.longitude, location.latitude)) {
|
||||
val geometry = GeometryTools.createGeometry(
|
||||
GeoPoint(
|
||||
location.latitude, location.longitude
|
||||
@@ -309,8 +308,11 @@ class MainViewModel @Inject constructor(
|
||||
//增加间距判断
|
||||
if (lastNiLocaion != null) {
|
||||
val disance = GeometryTools.getDistance(
|
||||
location.latitude, location.longitude,
|
||||
lastNiLocaion!!.latitude, lastNiLocaion!!.longitude)
|
||||
location.latitude,
|
||||
location.longitude,
|
||||
lastNiLocaion!!.latitude,
|
||||
lastNiLocaion!!.longitude
|
||||
)
|
||||
//相距差距大于2.5米以上进行存储
|
||||
if (disance > 2.5) {
|
||||
traceDataBase.niLocationDao.insert(location)
|
||||
@@ -345,11 +347,11 @@ class MainViewModel @Inject constructor(
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
private suspend fun captureLink(point: GeoPoint) {
|
||||
if(captureLinkState){
|
||||
if (captureLinkState) {
|
||||
return
|
||||
}
|
||||
|
||||
try{
|
||||
try {
|
||||
captureLinkState = true
|
||||
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
@@ -447,9 +449,9 @@ class MainViewModel @Inject constructor(
|
||||
liveDataRoadName.postValue(null)
|
||||
}
|
||||
|
||||
}catch (e:Exception){
|
||||
} catch (e: Exception) {
|
||||
|
||||
}finally {
|
||||
} finally {
|
||||
captureLinkState = false
|
||||
}
|
||||
|
||||
@@ -501,12 +503,10 @@ class MainViewModel @Inject constructor(
|
||||
try {
|
||||
if (!mCameraDialog!!.getmShareUtil().connectstate) {
|
||||
mCameraDialog!!.updateCameraResources(
|
||||
1,
|
||||
mCameraDialog!!.getmDeviceNum()
|
||||
1, mCameraDialog!!.getmDeviceNum()
|
||||
)
|
||||
}
|
||||
TakePhotoManager.getInstance()
|
||||
.getCameraVedioClent(mCameraDialog!!.getmDeviceNum())
|
||||
TakePhotoManager.getInstance().getCameraVedioClent(mCameraDialog!!.getmDeviceNum())
|
||||
.StopSearch()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user