Merge branch 'master' of https://gitlab.navinfo.com/CollectVehicle/OneMapQS
This commit is contained in:
commit
53ae5ab043
@ -9,6 +9,7 @@ import com.blankj.utilcode.util.FileIOUtils
|
||||
import com.blankj.utilcode.util.ZipUtils
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navinfo.collect.library.data.entity.ReferenceEntity
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.bean.ImportConfig
|
||||
@ -16,6 +17,7 @@ import com.navinfo.omqs.hilt.OMDBDataBaseHiltFactory
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedInject
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmQuery
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
@ -131,8 +133,9 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
// 开始解压zip文件
|
||||
val unZipFiles = ZipUtils.unzipFile(omdbZipFile, unZipFolder)
|
||||
// 将listResult数据插入到Realm数据库中
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.beginTransaction()
|
||||
try {
|
||||
Realm.getDefaultInstance().beginTransaction()
|
||||
// 遍历解压后的文件,读取该数据返回
|
||||
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
||||
val currentConfig = currentEntry.value
|
||||
@ -147,11 +150,16 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
if (list != null) {
|
||||
// 将list数据转换为map
|
||||
for ((index, line) in list.withIndex()) {
|
||||
Log.d("ImportOMDBHelper", "解析第:${index+1}行")
|
||||
val map = gson.fromJson<Map<String, Any>>(line, object:TypeToken<Map<String, Any>>(){}.getType())
|
||||
Log.d("ImportOMDBHelper", "解析第:${index + 1}行")
|
||||
val map = gson.fromJson<Map<String, Any>>(
|
||||
line,
|
||||
object : TypeToken<Map<String, Any>>() {}.getType()
|
||||
)
|
||||
.toMutableMap()
|
||||
map["qi_table"] = currentConfig.table
|
||||
map["qi_name"] = currentConfig.name
|
||||
map["qi_code"] =
|
||||
if (currentConfig.code == 0) currentConfig.code else currentEntry.key
|
||||
map["qi_code"] = if (currentConfig.code == 0) currentConfig.code else currentEntry.key
|
||||
map["qi_zoomMin"] = currentConfig.zoomMin
|
||||
map["qi_zoomMax"] = currentConfig.zoomMax
|
||||
@ -171,16 +179,22 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
for ((key, value) in map) {
|
||||
when (value) {
|
||||
is String -> renderEntity.properties.put(key, value)
|
||||
is Int -> renderEntity.properties.put(key, value.toInt().toString())
|
||||
is Double -> renderEntity.properties.put(key, value.toDouble().toString())
|
||||
is Int -> renderEntity.properties.put(
|
||||
key,
|
||||
value.toInt().toString()
|
||||
)
|
||||
is Double -> renderEntity.properties.put(
|
||||
key,
|
||||
value.toDouble().toString()
|
||||
)
|
||||
else -> renderEntity.properties.put(key, value.toString())
|
||||
}
|
||||
}
|
||||
listResult.add(renderEntity)
|
||||
// 对renderEntity做预处理后再保存
|
||||
val resultEntity = importConfig.transformProperties(renderEntity)
|
||||
if (resultEntity!=null) {
|
||||
Realm.getDefaultInstance().insert(renderEntity)
|
||||
if (resultEntity != null) {
|
||||
realm.insert(renderEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -189,12 +203,14 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
emit("${index + 1}/${importConfig.tableMap.size}")
|
||||
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||
if (currentConfig.table == "OMDB_RD_LINK") {
|
||||
importConfig.preProcess.cacheRdLink = listResult.associateBy { it.properties["linkPid"] }
|
||||
importConfig.preProcess.cacheRdLink =
|
||||
listResult.associateBy { it.properties["linkPid"] }
|
||||
}
|
||||
}
|
||||
Realm.getDefaultInstance().commitTransaction()
|
||||
realm.commitTransaction()
|
||||
realm.close()
|
||||
} catch (e: Exception) {
|
||||
Realm.getDefaultInstance().cancelTransaction()
|
||||
realm.cancelTransaction()
|
||||
throw e
|
||||
}
|
||||
emit("finish")
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.navinfo.omqs.http.taskdownload
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.Observer
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
@ -17,7 +18,7 @@ import java.util.concurrent.ConcurrentHashMap
|
||||
class TaskDownloadManager constructor(
|
||||
val importFactory: ImportOMDBHiltFactory,
|
||||
val netApi: RetrofitNetworkServiceAPI,
|
||||
val mapController:NIMapController
|
||||
val mapController: NIMapController
|
||||
) {
|
||||
|
||||
lateinit var context: Context
|
||||
@ -41,6 +42,7 @@ class TaskDownloadManager constructor(
|
||||
ConcurrentHashMap<Int, TaskDownloadScope>()
|
||||
}
|
||||
|
||||
|
||||
fun init(context: Context) {
|
||||
this.context = context
|
||||
}
|
||||
@ -103,7 +105,7 @@ class TaskDownloadManager constructor(
|
||||
|
||||
fun addTask(taskBean: TaskBean) {
|
||||
if (!scopeMap.containsKey(taskBean.id)) {
|
||||
scopeMap[taskBean.id] = TaskDownloadScope( this, taskBean)
|
||||
scopeMap[taskBean.id] = TaskDownloadScope(this, taskBean)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,16 @@
|
||||
package com.navinfo.omqs.http.taskdownload
|
||||
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.Observer
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.db.ImportOMDBHelper
|
||||
import com.navinfo.omqs.tools.FileManager
|
||||
import com.navinfo.omqs.tools.FileManager.Companion.FileDownloadStatus
|
||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
import com.navinfo.omqs.util.DateTimeUtil
|
||||
import io.realm.Realm
|
||||
import kotlinx.coroutines.*
|
||||
@ -21,7 +23,7 @@ class TaskDownloadScope(
|
||||
private val downloadManager: TaskDownloadManager,
|
||||
val taskBean: TaskBean,
|
||||
) :
|
||||
CoroutineScope by CoroutineScope(Dispatchers.IO + CoroutineName("OfflineMapDownLoad")) {
|
||||
CoroutineScope by CoroutineScope(Dispatchers.IO + CoroutineName("TaskMapDownLoad")) {
|
||||
|
||||
/**
|
||||
*下载任务,用来取消的
|
||||
@ -31,8 +33,8 @@ class TaskDownloadScope(
|
||||
/**
|
||||
* 管理观察者,同时只有一个就行了
|
||||
*/
|
||||
private val observer = Observer<Any> {}
|
||||
// private var lifecycleOwner: LifecycleOwner? = null
|
||||
// private val observer = Observer<Any> {}
|
||||
private var lifecycleOwner: LifecycleOwner? = null
|
||||
|
||||
/**
|
||||
*通知UI更新
|
||||
@ -92,6 +94,7 @@ class TaskDownloadScope(
|
||||
* @param status [OfflineMapCityBean.Status]
|
||||
*/
|
||||
private suspend fun change(status: Int, message: String = "") {
|
||||
|
||||
if (taskBean.status != status || status == FileDownloadStatus.LOADING || status == FileDownloadStatus.IMPORTING) {
|
||||
taskBean.status = status
|
||||
taskBean.message = message
|
||||
@ -111,8 +114,9 @@ class TaskDownloadScope(
|
||||
* 添加下载任务观察者
|
||||
*/
|
||||
fun observer(owner: LifecycleOwner, ob: Observer<TaskBean>) {
|
||||
|
||||
removeObserver()
|
||||
// this.lifecycleOwner = owner
|
||||
this.lifecycleOwner = owner
|
||||
downloadData.observe(owner, ob)
|
||||
}
|
||||
|
||||
@ -234,10 +238,17 @@ class TaskDownloadScope(
|
||||
}
|
||||
|
||||
fun removeObserver() {
|
||||
downloadData.observeForever(observer)
|
||||
// lifecycleOwner?.let {
|
||||
downloadData.removeObserver(observer)
|
||||
// null
|
||||
// }
|
||||
// downloadData.observeForever(observer)
|
||||
//// lifecycleOwner?.let {
|
||||
// downloadData.removeObserver(observer)
|
||||
//// null
|
||||
//// }
|
||||
if (lifecycleOwner != null) {
|
||||
Log.e(
|
||||
"jingo",
|
||||
"移除的上一个监听者 ${lifecycleOwner.hashCode()} ${(lifecycleOwner as BaseViewHolder).tag}"
|
||||
)
|
||||
downloadData.removeObservers(lifecycleOwner!!)
|
||||
}
|
||||
}
|
||||
}
|
@ -99,6 +99,10 @@ class LoginActivity : CheckPermissionsActivity() {
|
||||
LoginStatus.LOGIN_STATUS_NET_OFFLINE_MAP -> {
|
||||
loginDialog("检查离线地图...")
|
||||
}
|
||||
LoginStatus.LOGIN_STATUS_NET_GET_TASK_LIST -> {
|
||||
loginDialog("获取任务列表...")
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,6 +117,7 @@ class LoginActivity : CheckPermissionsActivity() {
|
||||
*/
|
||||
private fun loginDialog(message: String) {
|
||||
if (loginDialog == null) {
|
||||
Log.e("jingo", "登录dialog显示")
|
||||
loginDialog = MaterialAlertDialogBuilder(
|
||||
this, com.google.android.material.R.style.MaterialAlertDialog_Material3
|
||||
).setTitle("登录").setMessage(message).show()
|
||||
|
@ -9,6 +9,7 @@ import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.blankj.utilcode.util.ResourceUtils
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.bean.LoginUserBean
|
||||
import com.navinfo.omqs.bean.SysUserBean
|
||||
@ -17,6 +18,7 @@ import com.navinfo.omqs.http.DefaultResponse
|
||||
import com.navinfo.omqs.http.NetResult
|
||||
import com.navinfo.omqs.http.NetworkService
|
||||
import com.navinfo.omqs.tools.FileManager
|
||||
import com.navinfo.omqs.util.DateTimeUtil
|
||||
import com.navinfo.omqs.util.NetUtils
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import io.realm.Realm
|
||||
@ -37,6 +39,11 @@ enum class LoginStatus {
|
||||
*/
|
||||
LOGIN_STATUS_NET_OFFLINE_MAP,
|
||||
|
||||
/**
|
||||
* 访问任务列表
|
||||
*/
|
||||
LOGIN_STATUS_NET_GET_TASK_LIST,
|
||||
|
||||
/**
|
||||
* 初始化文件夹
|
||||
*/
|
||||
@ -108,11 +115,12 @@ class LoginViewModel @Inject constructor(
|
||||
val userCodeCache = sharedPreferences?.getString("userCode", null)
|
||||
val userRealName = sharedPreferences?.getString("userRealName", null)
|
||||
//增加缓存记录,不用每次连接网络登录
|
||||
if (userNameCache != null && passwordCache != null && userCodeCache != null&&userRealName!=null) {
|
||||
if (userNameCache != null && passwordCache != null && userCodeCache != null && userRealName != null) {
|
||||
if (userNameCache == userName && passwordCache == password) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
createUserFolder(context, userCodeCache,userRealName)
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_SUCCESS)
|
||||
createUserFolder(context, userCodeCache, userRealName)
|
||||
getOfflineCityList(context)
|
||||
// loginStatus.postValue(LoginStatus.LOGIN_STATUS_SUCCESS)
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -156,6 +164,14 @@ class LoginViewModel @Inject constructor(
|
||||
} else {
|
||||
userCode = defaultUserResponse.obj?.userCode.toString()
|
||||
userRealName = defaultUserResponse.obj?.userName.toString()
|
||||
folderInit(
|
||||
context = context,
|
||||
userName = userName,
|
||||
password = password,
|
||||
userCode = userCode,
|
||||
userRealName = userRealName
|
||||
)
|
||||
getOfflineCityList(context)
|
||||
}
|
||||
} else {
|
||||
withContext(Dispatchers.Main) {
|
||||
@ -197,21 +213,13 @@ class LoginViewModel @Inject constructor(
|
||||
else -> {}
|
||||
}
|
||||
|
||||
//文件夹初始化
|
||||
try {
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_FOLDER_INIT)
|
||||
sharedPreferences?.edit()?.putString("userName", userName)?.commit()
|
||||
sharedPreferences?.edit()?.putString("passWord", password)?.commit()
|
||||
sharedPreferences?.edit()?.putString("userCode", userCode)?.commit()
|
||||
sharedPreferences?.edit()?.putString("userRealName", userRealName)?.commit()
|
||||
}
|
||||
|
||||
createUserFolder(context, userCode,userRealName)
|
||||
} catch (e: IOException) {
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_FOLDER_FAILURE)
|
||||
}
|
||||
/**
|
||||
* 获取离线地图
|
||||
*/
|
||||
private suspend fun getOfflineCityList(context: Context) {
|
||||
|
||||
//假装解压文件等
|
||||
delay(1000)
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_NET_OFFLINE_MAP)
|
||||
when (val result = networkService.getOfflineMapCityList()) {
|
||||
is NetResult.Success -> {
|
||||
@ -222,6 +230,7 @@ class LoginViewModel @Inject constructor(
|
||||
}
|
||||
roomAppDatabase.getOfflineMapDao().insertOrUpdate(result.data)
|
||||
}
|
||||
getTaskList(context)
|
||||
}
|
||||
|
||||
is NetResult.Error<*> -> {
|
||||
@ -229,6 +238,7 @@ class LoginViewModel @Inject constructor(
|
||||
Toast.makeText(context, "${result.exception.message}", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
getTaskList(context)
|
||||
}
|
||||
|
||||
is NetResult.Failure<*> -> {
|
||||
@ -236,18 +246,101 @@ class LoginViewModel @Inject constructor(
|
||||
Toast.makeText(context, "${result.code}:${result.msg}", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
getTaskList(context)
|
||||
}
|
||||
|
||||
is NetResult.Loading -> {}
|
||||
else -> {}
|
||||
}
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_SUCCESS)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务列表
|
||||
*/
|
||||
private suspend fun getTaskList(context: Context) {
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_NET_GET_TASK_LIST)
|
||||
when (val result = networkService.getTaskList(Constant.USER_ID)) {
|
||||
is NetResult.Success -> {
|
||||
if (result.data != null) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.executeTransaction {
|
||||
result.data.obj?.let { list ->
|
||||
for (index in list.indices) {
|
||||
val task = list[index]
|
||||
val item = realm.where(TaskBean::class.java).equalTo(
|
||||
"id", task.id
|
||||
).findFirst()
|
||||
if (item != null) {
|
||||
task.fileSize = item.fileSize
|
||||
task.status = item.status
|
||||
task.currentSize = item.currentSize
|
||||
task.hadLinkDvoList = item.hadLinkDvoList
|
||||
//已上传后不在更新操作时间
|
||||
if (task.syncStatus != FileManager.Companion.FileUploadStatus.DONE) {
|
||||
//赋值时间,用于查询过滤
|
||||
task.operationTime = DateTimeUtil.getNowDate().time
|
||||
}
|
||||
} else {
|
||||
//赋值时间,用于查询过滤
|
||||
task.operationTime = DateTimeUtil.getNowDate().time
|
||||
}
|
||||
realm.copyToRealmOrUpdate(task)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_SUCCESS)
|
||||
}
|
||||
|
||||
is NetResult.Error<*> -> {
|
||||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(context, "${result.exception.message}", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_SUCCESS)
|
||||
}
|
||||
|
||||
is NetResult.Failure<*> -> {
|
||||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(context, "${result.code}:${result.msg}", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_SUCCESS)
|
||||
}
|
||||
|
||||
is NetResult.Loading -> {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化文件夹
|
||||
*/
|
||||
private fun folderInit(
|
||||
context: Context,
|
||||
userName: String,
|
||||
password: String,
|
||||
userCode: String,
|
||||
userRealName: String
|
||||
) {
|
||||
//文件夹初始化
|
||||
try {
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_FOLDER_INIT)
|
||||
sharedPreferences?.edit()?.putString("userName", userName)?.commit()
|
||||
sharedPreferences?.edit()?.putString("passWord", password)?.commit()
|
||||
sharedPreferences?.edit()?.putString("userCode", userCode)?.commit()
|
||||
sharedPreferences?.edit()?.putString("userRealName", userRealName)?.commit()
|
||||
|
||||
createUserFolder(context, userCode, userRealName)
|
||||
} catch (e: IOException) {
|
||||
loginStatus.postValue(LoginStatus.LOGIN_STATUS_FOLDER_FAILURE)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建用户目录
|
||||
*/
|
||||
private fun createUserFolder(context: Context, userId: String,userRealName:String) {
|
||||
private fun createUserFolder(context: Context, userId: String, userRealName: String) {
|
||||
Constant.IS_VIDEO_SPEED = false
|
||||
Constant.USER_ID = userId
|
||||
Constant.USER_REAL_NAME = userRealName
|
||||
|
@ -59,6 +59,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.locationtech.jts.geom.Point
|
||||
import org.oscim.core.GeoPoint
|
||||
import org.oscim.core.MapPosition
|
||||
import org.oscim.layers.marker.MarkerItem
|
||||
@ -222,6 +223,8 @@ class MainViewModel @Inject constructor(
|
||||
//线选择状态
|
||||
if (bSelectRoad) {
|
||||
captureLink(point)
|
||||
} else {
|
||||
captureItem(point)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,10 +392,11 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
}
|
||||
|
||||
location.taskId = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1).toString()
|
||||
location.taskId =
|
||||
sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1).toString()
|
||||
|
||||
//判断如果是连接状态并处于录像模式,标记为有效点
|
||||
if (shareUtil?.connectstate == true&&shareUtil?.takeCameraMode==0) {
|
||||
if (shareUtil?.connectstate == true && shareUtil?.takeCameraMode == 0) {
|
||||
location.media = 1
|
||||
}
|
||||
var disance = 0.0
|
||||
@ -439,6 +443,23 @@ class MainViewModel @Inject constructor(
|
||||
mapController.layerManagerHandler.showNiLocationLayer()
|
||||
}
|
||||
|
||||
/**
|
||||
* 捕捉要素数据
|
||||
*/
|
||||
private suspend fun captureItem(point: GeoPoint) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
val itemList = realmOperateHelper.queryElement(
|
||||
GeometryTools.createPoint(
|
||||
point.longitude,
|
||||
point.latitude
|
||||
)
|
||||
)
|
||||
|
||||
if(itemList.size == 1){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 捕获道路和面板
|
||||
|
@ -6,8 +6,10 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.View.OnClickListener
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.transition.AutoTransition
|
||||
import androidx.transition.Scene
|
||||
import androidx.transition.TransitionManager
|
||||
@ -15,11 +17,8 @@ import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.FragmentConsoleBinding
|
||||
import com.navinfo.omqs.ui.activity.map.MainActivity
|
||||
import com.navinfo.omqs.ui.fragment.BaseFragment
|
||||
import com.navinfo.omqs.ui.fragment.evaluationresult.EvaluationResultFragment
|
||||
import com.navinfo.omqs.ui.fragment.layermanager.LayerManagerFragment
|
||||
import com.navinfo.omqs.ui.fragment.offlinemap.OfflineMapFragment
|
||||
import com.navinfo.omqs.ui.fragment.personalcenter.PersonalCenterFragment
|
||||
import com.navinfo.omqs.ui.fragment.qsrecordlist.QsRecordListFragment
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
@ -33,6 +32,8 @@ class ConsoleFragment : BaseFragment(), OnClickListener {
|
||||
private var mFragment: Fragment? = null
|
||||
private val fragmentId = R.id.console_fragment
|
||||
|
||||
private val viewModel by viewModels<ConsoleViewModel>()
|
||||
|
||||
// 创建a场景
|
||||
private val aScene by lazy {
|
||||
Scene.getSceneForLayout(
|
||||
@ -72,6 +73,7 @@ class ConsoleFragment : BaseFragment(), OnClickListener {
|
||||
|
||||
override fun onTransitionEnd(transition: androidx.transition.Transition) {
|
||||
initOnClickListener()
|
||||
initLiveData()
|
||||
}
|
||||
|
||||
override fun onTransitionCancel(transition: androidx.transition.Transition) {
|
||||
@ -95,6 +97,7 @@ class ConsoleFragment : BaseFragment(), OnClickListener {
|
||||
|
||||
override fun onTransitionEnd(transition: androidx.transition.Transition) {
|
||||
initOnClickListener()
|
||||
initLiveData()
|
||||
}
|
||||
|
||||
override fun onTransitionCancel(transition: androidx.transition.Transition) {
|
||||
@ -108,8 +111,26 @@ class ConsoleFragment : BaseFragment(), OnClickListener {
|
||||
|
||||
})
|
||||
initOnClickListener()
|
||||
|
||||
initLiveData()
|
||||
}
|
||||
|
||||
private fun initLiveData(){
|
||||
/**
|
||||
* 任务数量统计
|
||||
*/
|
||||
viewModel.liveDataTaskCount.observe(viewLifecycleOwner) {
|
||||
binding.consoleRoot.findViewById<TextView>(R.id.console_task_count_text).text =
|
||||
"共 ${it} 条"
|
||||
}
|
||||
/**
|
||||
* 评测数据数量统计
|
||||
*/
|
||||
viewModel.liveDataEvaluationResultCount.observe(viewLifecycleOwner) {
|
||||
binding.consoleRoot.findViewById<TextView>(R.id.console_evaluation_count_text).text =
|
||||
"共 ${it} 条"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置点击事件
|
||||
@ -193,12 +214,13 @@ class ConsoleFragment : BaseFragment(), OnClickListener {
|
||||
R.id.console_personal_center_bg, R.id.console_personal_center_icon_bg -> {
|
||||
if (sceneFlag) {
|
||||
mFragment = PersonalCenterFragment {
|
||||
if(it){
|
||||
if (it) {
|
||||
activity?.let { a ->
|
||||
a.supportFragmentManager.beginTransaction().remove(this).commit()
|
||||
a.supportFragmentManager.beginTransaction().remove(this)
|
||||
.commit()
|
||||
(a as MainActivity).showIndoorDataLayout()
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
TransitionManager.go(aScene, aTransition)
|
||||
}
|
||||
|
||||
@ -208,12 +230,13 @@ class ConsoleFragment : BaseFragment(), OnClickListener {
|
||||
} else {
|
||||
if (mFragment !is PersonalCenterFragment) {
|
||||
mFragment = PersonalCenterFragment {
|
||||
if(it){
|
||||
if (it) {
|
||||
activity?.let { a ->
|
||||
a.supportFragmentManager.beginTransaction().remove(this).commit()
|
||||
a.supportFragmentManager.beginTransaction().remove(this)
|
||||
.commit()
|
||||
(a as MainActivity).showIndoorDataLayout()
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
TransitionManager.go(aScene, aTransition)
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
package com.navinfo.omqs.ui.fragment.console
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.omqs.tools.FileManager
|
||||
import com.navinfo.omqs.util.DateTimeUtil
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import io.realm.Realm
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class ConsoleViewModel @Inject constructor() : ViewModel() {
|
||||
/**
|
||||
* 当前任务量统计
|
||||
*/
|
||||
val liveDataTaskCount = MutableLiveData(0)
|
||||
|
||||
/**
|
||||
* 作业数据统计
|
||||
*/
|
||||
val liveDataEvaluationResultCount = MutableLiveData(0)
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val nowTime: Long = DateTimeUtil.getNowDate().time
|
||||
val beginNowTime: Long = nowTime - 90 * 3600 * 24 * 1000L
|
||||
val syncUpload: Int = FileManager.Companion.FileUploadStatus.DONE
|
||||
val count =
|
||||
realm.where(TaskBean::class.java).notEqualTo("syncStatus", syncUpload).or()
|
||||
.between("operationTime", beginNowTime, nowTime)
|
||||
.equalTo("syncStatus", syncUpload).count()
|
||||
liveDataTaskCount.postValue(count.toInt())
|
||||
val count2 = realm.where(QsRecordBean::class.java).count()
|
||||
liveDataEvaluationResultCount.postValue(count2.toInt())
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
|
||||
interface TaskAdapterCallback {
|
||||
fun itemOnClick(bean: HadLinkDvoBean)
|
||||
fun editOnclick(position: Int, bean: HadLinkDvoBean)
|
||||
fun editOnClick(position: Int, bean: HadLinkDvoBean)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,7 +54,7 @@ class TaskAdapter(
|
||||
}
|
||||
binding.taskEdit.isSelected = bean.reason != ""
|
||||
binding.taskEdit.setOnClickListener {
|
||||
callback.editOnclick(position, bean)
|
||||
callback.editOnClick(position, bean)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class TaskFragment : BaseFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun editOnclick(position: Int, bean: HadLinkDvoBean) {
|
||||
override fun editOnClick(position: Int, bean: HadLinkDvoBean) {
|
||||
showLinkEditDialog(position, bean)
|
||||
}
|
||||
})
|
||||
|
@ -7,6 +7,10 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
@ -19,6 +23,7 @@ import com.navinfo.omqs.tools.FileManager.Companion.FileDownloadStatus
|
||||
import com.navinfo.omqs.tools.FileManager.Companion.FileUploadStatus
|
||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
import com.navinfo.omqs.ui.other.OnLifecycleStateListener
|
||||
import com.navinfo.omqs.ui.widget.LeftDeleteView
|
||||
|
||||
/**
|
||||
@ -115,6 +120,7 @@ class TaskListAdapter(
|
||||
override fun onViewRecycled(holder: BaseViewHolder) {
|
||||
super.onViewRecycled(holder)
|
||||
//页面滑动时会用holder重构页面,但是对进度条的监听回调会一直返回,扰乱UI,所以当当前holder去重构的时候,移除监听
|
||||
//这里 BaseViewHolder 的LifecycleOwner 状态很早就DESTROYED 了,这个回调比较晚,起到的作用很小
|
||||
downloadManager.removeObserver(holder.tag.toInt())
|
||||
}
|
||||
|
||||
@ -122,7 +128,7 @@ class TaskListAdapter(
|
||||
holder: BaseViewHolder,
|
||||
@SuppressLint("RecyclerView") position: Int
|
||||
) {
|
||||
Log.e("jingo", "TaskListAdapter onBindViewHolder $position ")
|
||||
|
||||
val binding: AdapterTaskListBinding =
|
||||
holder.viewBinding as AdapterTaskListBinding
|
||||
val taskBean = data[position]
|
||||
@ -141,8 +147,22 @@ class TaskListAdapter(
|
||||
//tag 方便onclick里拿到数据
|
||||
holder.tag = taskBean.id.toString()
|
||||
changeViews(binding, taskBean)
|
||||
holder.addObserver(object : OnLifecycleStateListener {
|
||||
override fun onState(tag: String, state: Lifecycle.State) {
|
||||
when (state) {
|
||||
Lifecycle.State.STARTED ->
|
||||
downloadManager.observer(
|
||||
taskBean.id,
|
||||
holder,
|
||||
DownloadObserver(taskBean.id, holder)
|
||||
)
|
||||
Lifecycle.State.DESTROYED ->
|
||||
downloadManager.removeObserver(tag.toInt())
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
})
|
||||
downloadManager.addTask(taskBean)
|
||||
downloadManager.observer(taskBean.id, holder, DownloadObserver(taskBean.id, holder))
|
||||
uploadManager.addTask(taskBean)
|
||||
uploadManager.observer(taskBean.id, holder, UploadObserver(taskBean.id, binding))
|
||||
if (taskBean.status == FileDownloadStatus.NONE) {
|
||||
@ -195,9 +215,10 @@ class TaskListAdapter(
|
||||
binding.taskDeleteLayout.setOnClickListener {
|
||||
//重置状态
|
||||
leftDeleteView?.resetDeleteStatus()
|
||||
if(taskBean.syncStatus != FileUploadStatus.DONE){
|
||||
Toast.makeText(binding.taskUploadBtn.context, "数据未上传,不允许关闭!", Toast.LENGTH_SHORT).show()
|
||||
}else{
|
||||
if (taskBean.syncStatus != FileUploadStatus.DONE) {
|
||||
Toast.makeText(binding.taskUploadBtn.context, "数据未上传,不允许关闭!", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
} else {
|
||||
itemListener?.invoke(position, ItemClickStatus.DELETE_LAYOUT_CLICK, taskBean)
|
||||
}
|
||||
}
|
||||
|
@ -95,55 +95,6 @@ class TaskViewModel @Inject constructor(
|
||||
fun getTaskList(context: Context) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
|
||||
when (val result = networkService.getTaskList(Constant.USER_ID)) {
|
||||
is NetResult.Success -> {
|
||||
if (result.data != null) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.executeTransaction {
|
||||
result.data.obj?.let { list ->
|
||||
for (index in list.indices) {
|
||||
val task = list[index]
|
||||
val item = realm.where(TaskBean::class.java).equalTo(
|
||||
"id", task.id
|
||||
).findFirst()
|
||||
if (item != null) {
|
||||
task.fileSize = item.fileSize
|
||||
task.status = item.status
|
||||
task.currentSize = item.currentSize
|
||||
task.hadLinkDvoList = item.hadLinkDvoList
|
||||
//已上传后不在更新操作时间
|
||||
if (task.syncStatus != FileManager.Companion.FileUploadStatus.DONE) {
|
||||
//赋值时间,用于查询过滤
|
||||
task.operationTime = DateTimeUtil.getNowDate().time
|
||||
}
|
||||
} else {
|
||||
//赋值时间,用于查询过滤
|
||||
task.operationTime = DateTimeUtil.getNowDate().time
|
||||
}
|
||||
realm.copyToRealmOrUpdate(task)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is NetResult.Error<*> -> {
|
||||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(context, "${result.exception.message}", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
is NetResult.Failure<*> -> {
|
||||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(context, "${result.code}:${result.msg}", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
is NetResult.Loading -> {}
|
||||
}
|
||||
getLocalTaskList()
|
||||
}
|
||||
}
|
||||
@ -160,7 +111,7 @@ class TaskViewModel @Inject constructor(
|
||||
val objects =
|
||||
realm.where(TaskBean::class.java).notEqualTo("syncStatus", syncUpload).or()
|
||||
.between("operationTime", beginNowTime, nowTime)
|
||||
.equalTo("syncStatus", syncUpload).findAll()
|
||||
.equalTo("syncStatus", syncUpload).findAll().sort("id")
|
||||
val taskList = realm.copyFromRealm(objects)
|
||||
for (item in taskList) {
|
||||
FileManager.checkOMDBFileInfo(item)
|
||||
|
@ -16,6 +16,8 @@ open class BaseViewHolder(val viewBinding: ViewBinding) :
|
||||
private val lifecycleRegistry = LifecycleRegistry(this)
|
||||
var tag = ""
|
||||
|
||||
private var listener: OnLifecycleStateListener? = null
|
||||
|
||||
init {
|
||||
// dataBinding.lifecycleOwner = this
|
||||
lifecycleRegistry.currentState = Lifecycle.State.INITIALIZED
|
||||
@ -37,19 +39,33 @@ open class BaseViewHolder(val viewBinding: ViewBinding) :
|
||||
fun onStart() {
|
||||
lifecycleRegistry.currentState = Lifecycle.State.STARTED //
|
||||
lifecycleRegistry.currentState = Lifecycle.State.RESUMED // ON_RESUME EVENT
|
||||
listener?.onState(tag,Lifecycle.State.STARTED)
|
||||
}
|
||||
|
||||
fun onStop() {
|
||||
lifecycleRegistry.currentState = Lifecycle.State.STARTED //
|
||||
lifecycleRegistry.currentState = Lifecycle.State.CREATED // ON_STOP EVENT
|
||||
lifecycleRegistry.currentState = Lifecycle.State.CREATED //
|
||||
// listener?.onState(tag,Lifecycle.State.STARTED)// ON_STOP EVENT
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
lifecycleRegistry.currentState = Lifecycle.State.DESTROYED /// ON_DESTROY EVENT
|
||||
listener?.onState(tag,Lifecycle.State.DESTROYED)
|
||||
}
|
||||
|
||||
|
||||
override fun getLifecycle(): Lifecycle {
|
||||
return lifecycleRegistry
|
||||
}
|
||||
|
||||
fun addObserver(listener: OnLifecycleStateListener) {
|
||||
this.listener = listener
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生命周期变化
|
||||
*/
|
||||
interface OnLifecycleStateListener {
|
||||
fun onState(tag:String,state: Lifecycle.State)
|
||||
}
|
@ -234,7 +234,7 @@
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@id/main_activity_geometry"
|
||||
app:layout_constraintBottom_toTopOf="@id/main_activity_bottom_sheet"
|
||||
app:layout_constraintLeft_toLeftOf="@id/main_activity_top_sign_recyclerview" />
|
||||
|
||||
|
||||
@ -387,7 +387,7 @@
|
||||
<View
|
||||
android:id="@+id/main_activity_bottom_sheet"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_height="30dp"
|
||||
android:background="@drawable/baseline_minimize_24"
|
||||
android:onClick="@{()->mainActivity.onSwitchSheet()}"
|
||||
android:paddingBottom="10dp"
|
||||
|
@ -338,7 +338,6 @@
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:gravity="center"
|
||||
android:text="共 387 条"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/console_task_count_bg"
|
||||
@ -384,7 +383,6 @@
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:gravity="center"
|
||||
android:text="共 387 条"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/console_evaluation_count_bg"
|
||||
|
@ -343,7 +343,6 @@
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:gravity="center"
|
||||
android:text="共 387 条"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/console_task_count_bg"
|
||||
@ -390,7 +389,6 @@
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:gravity="center"
|
||||
android:text="共 387 条"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/console_evaluation_count_bg"
|
||||
|
@ -41,7 +41,7 @@
|
||||
app:layout_constraintRight_toRightOf="@id/task_list_search"
|
||||
app:layout_constraintTop_toTopOf="@id/task_list_search" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
<com.yanzhenjie.recyclerview.SwipeRecyclerView
|
||||
android:id="@+id/task_list_recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
@ -217,6 +217,13 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
|
||||
vectorNiLocationTileLayer.isEnabled = false
|
||||
labelNiLocationLayer.isEnabled = false
|
||||
}
|
||||
|
||||
fun omdbLayersUpdate(){
|
||||
// omdbVectorTileLayer
|
||||
// omdbReferenceTileLayer.
|
||||
omdbLabelLayer.update()
|
||||
omdbReferenceLabelLayer.update()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
2
vtm
2
vtm
@ -1 +1 @@
|
||||
Subproject commit d7552c34ffdff6724b5e4ddcec461f81f1e0b669
|
||||
Subproject commit c74bcd29c24cddf395fa9654ef0b69d0c88ac3ad
|
Loading…
x
Reference in New Issue
Block a user