修改任务新增link刷新列表崩溃问题
This commit is contained in:
parent
9bc68b52fa
commit
40d07cc329
@ -327,10 +327,6 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
DataCodeEnum.OMDB_LANE_MARK_BOUNDARYTYPE.code.toInt() -> {
|
DataCodeEnum.OMDB_LANE_MARK_BOUNDARYTYPE.code.toInt() -> {
|
||||||
var featurePid = renderEntity.properties["featurePid"]
|
|
||||||
if(featurePid!="135340259623248665"){
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var boundaryType = renderEntity.properties["boundaryType"]
|
var boundaryType = renderEntity.properties["boundaryType"]
|
||||||
if (boundaryType != null) {
|
if (boundaryType != null) {
|
||||||
when (boundaryType.toInt()) {
|
when (boundaryType.toInt()) {
|
||||||
|
@ -282,6 +282,12 @@ class LoginViewModel @Inject constructor(
|
|||||||
task.fileSize = item.fileSize
|
task.fileSize = item.fileSize
|
||||||
task.status = item.status
|
task.status = item.status
|
||||||
task.currentSize = item.currentSize
|
task.currentSize = item.currentSize
|
||||||
|
//增加mesh==null兼容性处理
|
||||||
|
for (hadLink in item.hadLinkDvoList) {
|
||||||
|
if(hadLink.mesh==null){
|
||||||
|
hadLink.mesh = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
task.hadLinkDvoList = item.hadLinkDvoList
|
task.hadLinkDvoList = item.hadLinkDvoList
|
||||||
task.syncStatus = item.syncStatus
|
task.syncStatus = item.syncStatus
|
||||||
//已上传后不在更新操作时间
|
//已上传后不在更新操作时间
|
||||||
@ -293,8 +299,10 @@ class LoginViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (hadLink in task.hadLinkDvoList) {
|
for (hadLink in task.hadLinkDvoList) {
|
||||||
if(hadLink.geometry==null||hadLink.mesh==null){
|
if(hadLink.geometry==null){
|
||||||
inSertData = false
|
inSertData = false
|
||||||
|
}else if(hadLink.mesh==null){
|
||||||
|
hadLink.mesh = ""
|
||||||
}else{
|
}else{
|
||||||
hadLink.taskId = task.id
|
hadLink.taskId = task.id
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,9 @@ class TaskFragment : BaseFragment() {
|
|||||||
viewModel.liveDataAddLinkDialog.observe(viewLifecycleOwner){
|
viewModel.liveDataAddLinkDialog.observe(viewLifecycleOwner){
|
||||||
viewModel.addTaskLink(requireContext(),it)
|
viewModel.addTaskLink(requireContext(),it)
|
||||||
}
|
}
|
||||||
|
viewModel.liveDataUpdateTask.observe(viewLifecycleOwner) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//注意:使用滑动菜单不能开启滑动删除,否则只有滑动删除没有滑动菜单
|
//注意:使用滑动菜单不能开启滑动删除,否则只有滑动删除没有滑动菜单
|
||||||
val mSwipeMenuCreator = SwipeMenuCreator { _, rightMenu, _ ->
|
val mSwipeMenuCreator = SwipeMenuCreator { _, rightMenu, _ ->
|
||||||
|
@ -145,6 +145,28 @@ class TaskListFragment : BaseFragment() {
|
|||||||
binding.taskListRecyclerview.smoothScrollToPosition(position)
|
binding.taskListRecyclerview.smoothScrollToPosition(position)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewModel.liveDataCloseTask.observe(viewLifecycleOwner){
|
||||||
|
when(it){
|
||||||
|
TaskDelStatus.TASK_DEL_STATUS_BEGIN->{
|
||||||
|
showLoadingDialog("正在重置...")
|
||||||
|
}
|
||||||
|
TaskDelStatus.TASK_DEL_STATUS_LOADING->{
|
||||||
|
showLoadingDialog("正在重置...")
|
||||||
|
}
|
||||||
|
TaskDelStatus.TASK_DEL_STATUS_SUCCESS->{
|
||||||
|
hideLoadingDialog()
|
||||||
|
Toast.makeText(context,"成功重置",Toast.LENGTH_LONG).show()
|
||||||
|
|
||||||
|
}
|
||||||
|
TaskDelStatus.TASK_DEL_STATUS_FAILED->{
|
||||||
|
hideLoadingDialog()
|
||||||
|
}
|
||||||
|
TaskDelStatus.TASK_DEL_STATUS_CANCEL->{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//监听并调用上传
|
//监听并调用上传
|
||||||
viewModel.liveDataTaskUpload.observe(viewLifecycleOwner) {
|
viewModel.liveDataTaskUpload.observe(viewLifecycleOwner) {
|
||||||
for ((key, value) in it) {
|
for ((key, value) in it) {
|
||||||
|
@ -4,6 +4,7 @@ import android.content.Context
|
|||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
@ -31,6 +32,32 @@ import org.oscim.core.GeoPoint
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
enum class TaskDelStatus {
|
||||||
|
/**
|
||||||
|
* 删除开始
|
||||||
|
*/
|
||||||
|
TASK_DEL_STATUS_BEGIN,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除中
|
||||||
|
*/
|
||||||
|
TASK_DEL_STATUS_LOADING,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除成功
|
||||||
|
*/
|
||||||
|
TASK_DEL_STATUS_SUCCESS,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除失败
|
||||||
|
*/
|
||||||
|
TASK_DEL_STATUS_FAILED,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消删除
|
||||||
|
*/
|
||||||
|
TASK_DEL_STATUS_CANCEL,
|
||||||
|
}
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class TaskViewModel @Inject constructor(
|
class TaskViewModel @Inject constructor(
|
||||||
@ -61,7 +88,12 @@ class TaskViewModel @Inject constructor(
|
|||||||
/**
|
/**
|
||||||
* 用来确定是否关闭
|
* 用来确定是否关闭
|
||||||
*/
|
*/
|
||||||
val liveDataCloseTask = MutableLiveData<Boolean>()
|
val liveDataCloseTask = MutableLiveData<TaskDelStatus>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用来更新任务
|
||||||
|
*/
|
||||||
|
val liveDataUpdateTask = MutableLiveData<TaskBean>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提示信息
|
* 提示信息
|
||||||
@ -107,7 +139,8 @@ class TaskViewModel @Inject constructor(
|
|||||||
if (currentSelectTaskBean == null) {
|
if (currentSelectTaskBean == null) {
|
||||||
liveDataToastMessage.postValue("还没有开启任何任务")
|
liveDataToastMessage.postValue("还没有开启任何任务")
|
||||||
} else {
|
} else {
|
||||||
val links = realmOperateHelper.queryLink(realm,
|
val links = realmOperateHelper.queryLink(
|
||||||
|
realm,
|
||||||
point = point,
|
point = point,
|
||||||
)
|
)
|
||||||
if (links.isNotEmpty()) {
|
if (links.isNotEmpty()) {
|
||||||
@ -125,7 +158,8 @@ class TaskViewModel @Inject constructor(
|
|||||||
} else {
|
} else {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
val realm = realmOperateHelper.getSelectTaskRealmInstance()
|
val realm = realmOperateHelper.getSelectTaskRealmInstance()
|
||||||
val links = realmOperateHelper.queryLink(realm,
|
val links = realmOperateHelper.queryLink(
|
||||||
|
realm,
|
||||||
point = point,
|
point = point,
|
||||||
)
|
)
|
||||||
if (links.isNotEmpty()) {
|
if (links.isNotEmpty()) {
|
||||||
@ -178,22 +212,34 @@ class TaskViewModel @Inject constructor(
|
|||||||
task.fileSize = item.fileSize
|
task.fileSize = item.fileSize
|
||||||
task.status = item.status
|
task.status = item.status
|
||||||
task.currentSize = item.currentSize
|
task.currentSize = item.currentSize
|
||||||
|
//增加mesh==null兼容性处理
|
||||||
|
for (hadLink in item.hadLinkDvoList) {
|
||||||
|
if (hadLink.mesh == null) {
|
||||||
|
hadLink.mesh = ""
|
||||||
|
Log.e("qj", "${task.id}==null")
|
||||||
|
}
|
||||||
|
}
|
||||||
task.hadLinkDvoList = item.hadLinkDvoList
|
task.hadLinkDvoList = item.hadLinkDvoList
|
||||||
task.syncStatus = item.syncStatus
|
task.syncStatus = item.syncStatus
|
||||||
//已上传后不在更新操作时间
|
//已上传后不在更新操作时间
|
||||||
if (task.syncStatus != FileManager.Companion.FileUploadStatus.DONE) {
|
if (task.syncStatus != FileManager.Companion.FileUploadStatus.DONE) {
|
||||||
//赋值时间,用于查询过滤
|
//赋值时间,用于查询过滤
|
||||||
task.operationTime = DateTimeUtil.getNowDate().time
|
task.operationTime = DateTimeUtil.getNowDate().time
|
||||||
}else{//已上传数据不做更新
|
} else {//已上传数据不做更新
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (hadLink in task.hadLinkDvoList) {
|
for (hadLink in task.hadLinkDvoList) {
|
||||||
hadLink.taskId = task.id
|
hadLink.taskId = task.id
|
||||||
|
if (hadLink.mesh == null) {
|
||||||
|
hadLink.mesh = ""
|
||||||
|
Log.e("qj", "${task.id}==新增==null")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//赋值时间,用于查询过滤
|
//赋值时间,用于查询过滤
|
||||||
task.operationTime = DateTimeUtil.getNowDate().time
|
task.operationTime = DateTimeUtil.getNowDate().time
|
||||||
}
|
}
|
||||||
|
Log.e("qj", "${task.id}")
|
||||||
realm.copyToRealmOrUpdate(task)
|
realm.copyToRealmOrUpdate(task)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,7 +459,7 @@ class TaskViewModel @Inject constructor(
|
|||||||
/**
|
/**
|
||||||
* 重新下载数据任务
|
* 重新下载数据任务
|
||||||
*/
|
*/
|
||||||
fun resetDownload(context: Context, taskBean: TaskBean){
|
fun resetDownload(context: Context, taskBean: TaskBean) {
|
||||||
val mDialog = FirstDialog(context)
|
val mDialog = FirstDialog(context)
|
||||||
mDialog.setTitle("提示?")
|
mDialog.setTitle("提示?")
|
||||||
mDialog.setMessage("是否重置下载状态,请确认!")
|
mDialog.setMessage("是否重置下载状态,请确认!")
|
||||||
@ -421,58 +467,55 @@ class TaskViewModel @Inject constructor(
|
|||||||
"确定"
|
"确定"
|
||||||
) { dialog, _ ->
|
) { dialog, _ ->
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
|
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_BEGIN)
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
//删除已下载的数据
|
//删除已下载的数据
|
||||||
val fileTemp = File("${Constant.DOWNLOAD_PATH}${taskBean.evaluationTaskName}_${taskBean.dataVersion}.zip")
|
val fileTemp =
|
||||||
if(fileTemp.exists()){
|
File("${Constant.DOWNLOAD_PATH}${taskBean.evaluationTaskName}_${taskBean.dataVersion}.zip")
|
||||||
|
if (fileTemp.exists()) {
|
||||||
fileTemp.delete()
|
fileTemp.delete()
|
||||||
}
|
}
|
||||||
val taskFileTemp = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
|
val taskFileTemp = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
|
||||||
//重命名
|
//重命名
|
||||||
if(taskFileTemp.exists()){
|
if (taskFileTemp.exists()) {
|
||||||
var currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
|
/* var currentSelectTaskFolder = File(Constant.USER_DATA_PATH + "/${taskBean.id}")
|
||||||
var currentSelectTaskConfig =
|
var currentSelectTaskConfig =
|
||||||
RealmConfiguration.Builder().directory(currentSelectTaskFolder)
|
RealmConfiguration.Builder().directory(currentSelectTaskFolder)
|
||||||
.name("OMQS.realm").encryptionKey(Constant.PASSWORD).allowQueriesOnUiThread(true)
|
.name("OMQS.realm").encryptionKey(Constant.PASSWORD)
|
||||||
|
.allowQueriesOnUiThread(true)
|
||||||
.schemaVersion(2).build()
|
.schemaVersion(2).build()
|
||||||
//删除已有所有数据
|
Realm.getInstance(currentSelectTaskConfig).executeTransaction { r ->
|
||||||
Realm.getInstance(currentSelectTaskConfig).deleteAll()
|
//删除已有所有数据
|
||||||
Realm.getInstance(currentSelectTaskConfig).refresh()
|
r.delete(RenderEntity::class.java)
|
||||||
Realm.getInstance(currentSelectTaskConfig).close()
|
r.delete(ReferenceEntity::class.java)
|
||||||
|
}
|
||||||
|
Realm.getInstance(currentSelectTaskConfig).close()*/
|
||||||
}
|
}
|
||||||
//将下载状态修改已下载
|
//将下载状态修改已下载
|
||||||
val realm = realmOperateHelper.getRealmDefaultInstance()
|
val realm = realmOperateHelper.getRealmDefaultInstance()
|
||||||
taskBean.syncStatus = FileManager.Companion.FileUploadStatus.NONE
|
taskBean.syncStatus = FileManager.Companion.FileUploadStatus.NONE
|
||||||
taskBean.status = FileManager.Companion.FileDownloadStatus.NONE
|
taskBean.status = FileManager.Companion.FileDownloadStatus.NONE
|
||||||
realm.executeTransaction { r ->
|
realm.beginTransaction()
|
||||||
r.copyToRealmOrUpdate(taskBean)
|
realm.copyToRealmOrUpdate(taskBean)
|
||||||
}
|
realm.commitTransaction()
|
||||||
val nowTime: Long = DateTimeUtil.getNowDate().time
|
|
||||||
val beginNowTime: Long = nowTime - 90 * 3600 * 24 * 1000L
|
|
||||||
val syncUpload: Int = FileManager.Companion.FileUploadStatus.DONE
|
|
||||||
val objects =
|
|
||||||
realm.where(TaskBean::class.java).notEqualTo("syncStatus", syncUpload).or()
|
|
||||||
.between("operationTime", beginNowTime, nowTime)
|
|
||||||
.equalTo("syncStatus", syncUpload).findAll()
|
|
||||||
val taskList = realm.copyFromRealm(objects)
|
|
||||||
for (item in taskList) {
|
|
||||||
FileManager.checkOMDBFileInfo(item)
|
|
||||||
}
|
|
||||||
liveDataTaskList.postValue(taskList)
|
|
||||||
realm.close()
|
realm.close()
|
||||||
|
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_SUCCESS)
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
if(taskBean.id== currentSelectTaskBean?.id ?: 0){
|
if (taskBean.id == currentSelectTaskBean?.id ?: 0) {
|
||||||
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
mapController.layerManagerHandler.updateOMDBVectorTileLayer()
|
||||||
}else{
|
} else {
|
||||||
setSelectTaskBean(taskBean)
|
setSelectTaskBean(taskBean)
|
||||||
}
|
}
|
||||||
|
realmOperateHelper.getRealmDefaultInstance().refresh()
|
||||||
|
//重新加载数据
|
||||||
|
getLocalTaskList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mDialog.setNegativeButton(
|
mDialog.setNegativeButton(
|
||||||
"取消"
|
"取消"
|
||||||
) { _, _ ->
|
) { _, _ ->
|
||||||
liveDataCloseTask.postValue(false)
|
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_CANCEL)
|
||||||
mDialog.dismiss()
|
mDialog.dismiss()
|
||||||
}
|
}
|
||||||
mDialog.show()
|
mDialog.show()
|
||||||
@ -489,7 +532,9 @@ class TaskViewModel @Inject constructor(
|
|||||||
"确定"
|
"确定"
|
||||||
) { dialog, _ ->
|
) { dialog, _ ->
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
|
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_BEGIN)
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_LOADING)
|
||||||
val realm = realmOperateHelper.getRealmDefaultInstance()
|
val realm = realmOperateHelper.getRealmDefaultInstance()
|
||||||
realm.executeTransaction {
|
realm.executeTransaction {
|
||||||
val objects =
|
val objects =
|
||||||
@ -523,14 +568,14 @@ class TaskViewModel @Inject constructor(
|
|||||||
FileManager.checkOMDBFileInfo(item)
|
FileManager.checkOMDBFileInfo(item)
|
||||||
}
|
}
|
||||||
liveDataTaskList.postValue(taskList)
|
liveDataTaskList.postValue(taskList)
|
||||||
liveDataCloseTask.postValue(true)
|
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_SUCCESS)
|
||||||
realm.close()
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mDialog.setNegativeButton(
|
mDialog.setNegativeButton(
|
||||||
"取消"
|
"取消"
|
||||||
) { _, _ ->
|
) { _, _ ->
|
||||||
liveDataCloseTask.postValue(false)
|
liveDataCloseTask.postValue(TaskDelStatus.TASK_DEL_STATUS_CANCEL)
|
||||||
mDialog.dismiss()
|
mDialog.dismiss()
|
||||||
}
|
}
|
||||||
mDialog.show()
|
mDialog.show()
|
||||||
@ -641,7 +686,7 @@ class TaskViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
//根据Link数据查询对应数据上要素,对要素进行显示重置
|
//根据Link数据查询对应数据上要素,对要素进行显示重置
|
||||||
data.properties["linkPid"]?.let {
|
data.properties["linkPid"]?.let {
|
||||||
realmOperateHelper.queryLinkToMutableRenderEntityList(realm,it)
|
realmOperateHelper.queryLinkToMutableRenderEntityList(realm, it)
|
||||||
?.forEach { renderEntity ->
|
?.forEach { renderEntity ->
|
||||||
if (renderEntity.enable != 1) {
|
if (renderEntity.enable != 1) {
|
||||||
renderEntity.enable = 1
|
renderEntity.enable = 1
|
||||||
@ -696,7 +741,10 @@ class TaskViewModel @Inject constructor(
|
|||||||
|
|
||||||
//重置数据为隐藏
|
//重置数据为隐藏
|
||||||
if (hadLinkDvoBean.linkStatus == 2) {
|
if (hadLinkDvoBean.linkStatus == 2) {
|
||||||
realmOperateHelper.queryLinkToMutableRenderEntityList(realm,hadLinkDvoBean.linkPid)
|
realmOperateHelper.queryLinkToMutableRenderEntityList(
|
||||||
|
realm,
|
||||||
|
hadLinkDvoBean.linkPid
|
||||||
|
)
|
||||||
?.forEach { renderEntity ->
|
?.forEach { renderEntity ->
|
||||||
if (renderEntity.enable == 1) {
|
if (renderEntity.enable == 1) {
|
||||||
renderEntity.enable = 0
|
renderEntity.enable = 0
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.navinfo.collect.library.data.entity
|
package com.navinfo.collect.library.data.entity
|
||||||
|
|
||||||
|
import com.navinfo.collect.library.utils.GeometryTools
|
||||||
|
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||||
import io.realm.RealmObject
|
import io.realm.RealmObject
|
||||||
import io.realm.annotations.PrimaryKey
|
import io.realm.annotations.PrimaryKey
|
||||||
|
|
||||||
@ -12,11 +14,13 @@ open class HadLinkDvoBean @JvmOverloads constructor(
|
|||||||
* 图幅号
|
* 图幅号
|
||||||
*/
|
*/
|
||||||
var mesh: String = "",
|
var mesh: String = "",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* linkPid
|
* linkPid
|
||||||
*/
|
*/
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
var linkPid: String = "",
|
var linkPid: String = "",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (几何)加偏后
|
* (几何)加偏后
|
||||||
*/
|
*/
|
||||||
@ -31,10 +35,12 @@ open class HadLinkDvoBean @JvmOverloads constructor(
|
|||||||
* 1:源库link,2:选择link 3:现场新增
|
* 1:源库link,2:选择link 3:现场新增
|
||||||
*/
|
*/
|
||||||
var linkStatus: Int = 1,
|
var linkStatus: Int = 1,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 详细属性
|
* 详细属性
|
||||||
*/
|
*/
|
||||||
var linkInfo: LinkInfoBean? = null,
|
var linkInfo: LinkInfoBean? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 长度(米)
|
* 长度(米)
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user