增加室内整理工具反向控制
This commit is contained in:
@@ -185,6 +185,7 @@ class MainActivity : BaseActivity() {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
voiceOnTouchStart()//Do Something
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_UP -> {
|
||||
voiceOnTouchStop()//Do Something
|
||||
}
|
||||
@@ -235,13 +236,18 @@ class MainActivity : BaseActivity() {
|
||||
)
|
||||
}
|
||||
|
||||
//捕捉列表变化回调
|
||||
//捕捉轨迹点
|
||||
viewModel.liveDataNILocationList.observe(this) {
|
||||
if(viewModel.isSelectTrace()){
|
||||
if (viewModel.isSelectTrace()) {
|
||||
//Toast.makeText(this,"轨迹被点击了",Toast.LENGTH_LONG).show()
|
||||
viewModel.showMarker(this,it)
|
||||
val traceVideoBean = TraceVideoBean(command = "videotime?", userid = Constant.USER_ID, time = "${it.time}:000")
|
||||
viewModel.sendServerCommand(this,traceVideoBean)
|
||||
viewModel.showMarker(this, it)
|
||||
viewModel.setCurrentIndexNiLocation(it)
|
||||
val traceVideoBean = TraceVideoBean(
|
||||
command = "videotime?",
|
||||
userid = Constant.USER_ID,
|
||||
time = "${it.time}:000"
|
||||
)
|
||||
viewModel.sendServerCommand(this, traceVideoBean,IndoorToolsCommand.SELECT_POINT)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,6 +327,49 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.liveIndoorToolsResp.observe(this){
|
||||
when(it){
|
||||
IndoorToolsResp.QR_CODE_STATUS_UPDATE_VIDEO_INFO_SUCCESS->{
|
||||
|
||||
if(viewModel.indoorToolsCommand==IndoorToolsCommand.SELECT_POINT){
|
||||
selectPointFinish(true)
|
||||
}
|
||||
|
||||
}
|
||||
IndoorToolsResp.QR_CODE_STATUS_UPDATE_VIDEO_INFO_FAILURE->{
|
||||
if(viewModel.indoorToolsCommand==IndoorToolsCommand.SELECT_POINT){
|
||||
selectPointFinish(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//室内整理工具反向控制
|
||||
viewModel.liveIndoorToolsCommand.observe(this) {
|
||||
when (it) {
|
||||
IndoorToolsCommand.PLAY -> {
|
||||
setPlayStatus()
|
||||
}
|
||||
IndoorToolsCommand.INDEXING -> {
|
||||
pausePlayTrace()
|
||||
}
|
||||
IndoorToolsCommand.SELECT_POINT -> {
|
||||
|
||||
}
|
||||
|
||||
IndoorToolsCommand.NEXT -> {
|
||||
}
|
||||
|
||||
IndoorToolsCommand.REWIND -> {
|
||||
}
|
||||
|
||||
IndoorToolsCommand.STOP -> {
|
||||
//切换为暂停状态
|
||||
pausePlayTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lifecycleScope.launch {
|
||||
// 初始化地图图层控制接收器
|
||||
FlowEventBus.subscribe<List<ImportConfig>>(
|
||||
@@ -551,13 +600,10 @@ class MainActivity : BaseActivity() {
|
||||
viewModel.setSelectTrace(!viewModel.isSelectTrace())
|
||||
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
|
||||
|
||||
if(viewModel.isSelectTrace()){
|
||||
Toast.makeText(this,"请选择轨迹点!",Toast.LENGTH_LONG).show()
|
||||
if (viewModel.isSelectTrace()) {
|
||||
Toast.makeText(this, "请选择轨迹点!", Toast.LENGTH_LONG).show()
|
||||
//调用撤销自动播放
|
||||
binding.mainActivitySnapshotFinish.isEnabled = false
|
||||
binding.mainActivitySnapshotRewind.isEnabled = false
|
||||
binding.mainActivitySnapshotPause.isEnabled = false
|
||||
binding.mainActivitySnapshotNext.isEnabled = false
|
||||
setViewEnable(false)
|
||||
viewModel.cancelTrace()
|
||||
}
|
||||
}
|
||||
@@ -592,13 +638,17 @@ class MainActivity : BaseActivity() {
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
fun rewindTraceOnclick() {
|
||||
pausePlayTrace()
|
||||
val item = mapController.markerHandle.getNILocation(viewModel.currentIndexNiLocation-1)
|
||||
if(item!=null){
|
||||
viewModel.currentIndexNiLocation = viewModel.currentIndexNiLocation-1
|
||||
viewModel.showMarker(this,(item as MarkerItem).uid as NiLocation)
|
||||
val traceVideoBean = TraceVideoBean(command = "videotime?", userid = Constant.USER_ID, time = "${(item.uid as NiLocation).time}:000")
|
||||
viewModel.sendServerCommand(this,traceVideoBean)
|
||||
}else{
|
||||
val item = mapController.markerHandle.getNILocation(viewModel.getCurrentNiLocationIndex() - 1)
|
||||
if (item != null) {
|
||||
viewModel.setCurrentIndexLoction(viewModel.getCurrentNiLocationIndex() - 1)
|
||||
viewModel.showMarker(this, (item as MarkerItem).uid as NiLocation)
|
||||
val traceVideoBean = TraceVideoBean(
|
||||
command = "videotime?",
|
||||
userid = Constant.USER_ID,
|
||||
time = "${(item.uid as NiLocation).time}:000"
|
||||
)
|
||||
viewModel.sendServerCommand(this, traceVideoBean,IndoorToolsCommand.REWIND)
|
||||
} else {
|
||||
dealNoData()
|
||||
}
|
||||
}
|
||||
@@ -612,24 +662,24 @@ class MainActivity : BaseActivity() {
|
||||
binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace()
|
||||
viewModel.setSelectTrace(false)
|
||||
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
|
||||
if(viewModel.isSelectPauseTrace()){
|
||||
if (viewModel.isSelectPauseTrace()) {
|
||||
playVideo()
|
||||
}else{
|
||||
} else {
|
||||
pauseVideo()
|
||||
viewModel.cancelTrace()
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
fun playVideo(){
|
||||
if (mapController.markerHandle.getCurrentMark()==null) {
|
||||
fun playVideo() {
|
||||
if (mapController.markerHandle.getCurrentMark() == null) {
|
||||
BaseToast.makeText(this, "请先选择轨迹点!", BaseToast.LENGTH_SHORT).show()
|
||||
return
|
||||
}
|
||||
viewModel.setSelectTrace(false)
|
||||
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
|
||||
val traceVideoBean = TraceVideoBean(command = "playVideo?", userid = Constant.USER_ID)
|
||||
viewModel.sendServerCommand(this,traceVideoBean)
|
||||
viewModel.sendServerCommand(this, traceVideoBean,IndoorToolsCommand.PLAY)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -644,9 +694,9 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
fun pauseVideo(){
|
||||
fun pauseVideo() {
|
||||
val traceVideoBean = TraceVideoBean(command = "pauseVideo?", userid = Constant.USER_ID)
|
||||
viewModel.sendServerCommand(this,traceVideoBean)
|
||||
viewModel.sendServerCommand(this, traceVideoBean,IndoorToolsCommand.STOP)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -655,13 +705,17 @@ class MainActivity : BaseActivity() {
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
fun nextTraceOnclick() {
|
||||
pausePlayTrace()
|
||||
val item = mapController.markerHandle.getNILocation(viewModel.currentIndexNiLocation+1)
|
||||
if(item!=null){
|
||||
viewModel.currentIndexNiLocation = viewModel.currentIndexNiLocation+1
|
||||
viewModel.showMarker(this,(item as MarkerItem).uid as NiLocation)
|
||||
val traceVideoBean = TraceVideoBean(command = "videotime?", userid = Constant.USER_ID, time = "${(item.uid as NiLocation).time}:000")
|
||||
viewModel.sendServerCommand(this,traceVideoBean)
|
||||
}else{
|
||||
val item = mapController.markerHandle.getNILocation(viewModel.getCurrentNiLocationIndex() + 1)
|
||||
if (item != null) {
|
||||
viewModel.setCurrentIndexLoction(viewModel.getCurrentNiLocationIndex()+1)
|
||||
viewModel.showMarker(this, (item as MarkerItem).uid as NiLocation)
|
||||
val traceVideoBean = TraceVideoBean(
|
||||
command = "videotime?",
|
||||
userid = Constant.USER_ID,
|
||||
time = "${(item.uid as NiLocation).time}:000"
|
||||
)
|
||||
viewModel.sendServerCommand(this, traceVideoBean,IndoorToolsCommand.NEXT)
|
||||
} else {
|
||||
dealNoData()
|
||||
}
|
||||
}
|
||||
@@ -688,6 +742,26 @@ class MainActivity : BaseActivity() {
|
||||
viewModel.cancelTrace()
|
||||
}
|
||||
|
||||
/**
|
||||
* 选点结束
|
||||
* @param value true 选点成功 false 选点失败
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
private fun selectPointFinish(value: Boolean) {
|
||||
if (value) {
|
||||
setViewEnable(true)
|
||||
viewModel.setSelectPauseTrace(false)
|
||||
binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setViewEnable(value: Boolean){
|
||||
binding.mainActivitySnapshotRewind.isEnabled = value
|
||||
binding.mainActivitySnapshotNext.isEnabled = value
|
||||
binding.mainActivitySnapshotPause.isEnabled = value
|
||||
binding.mainActivitySnapshotFinish.isEnabled = value
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 打开或关闭底部导航栏
|
||||
@@ -708,7 +782,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)
|
||||
@@ -769,14 +848,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
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.navinfo.omqs.ui.manager.TakePhotoManager
|
||||
import com.navinfo.omqs.ui.other.BaseToast
|
||||
import com.navinfo.omqs.ui.widget.SignUtil
|
||||
import com.navinfo.omqs.util.DateTimeUtil
|
||||
import com.navinfo.omqs.util.ShareUtil
|
||||
import com.navinfo.omqs.util.SoundMeter
|
||||
import com.navinfo.omqs.util.SpeakMode
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
@@ -74,7 +75,7 @@ class MainViewModel @Inject constructor(
|
||||
private val realmOperateHelper: RealmOperateHelper,
|
||||
private val networkService: NetworkService,
|
||||
private val sharedPreferences: SharedPreferences
|
||||
) : ViewModel(),SocketServer.OnConnectSinsListener{
|
||||
) : ViewModel(), SocketServer.OnConnectSinsListener {
|
||||
|
||||
private var mCameraDialog: CommonDialog? = null
|
||||
|
||||
@@ -130,10 +131,10 @@ class MainViewModel @Inject constructor(
|
||||
val liveDataCenterPoint = MutableLiveData<MapPosition>()
|
||||
|
||||
//状态
|
||||
val qrCodeStatus: MutableLiveData<QrCodeStatus> = MutableLiveData()
|
||||
val liveIndoorToolsResp: MutableLiveData<IndoorToolsResp> = MutableLiveData()
|
||||
|
||||
//状态
|
||||
val indoorToolsStatus: MutableLiveData<IndoorToolsStatus> = MutableLiveData()
|
||||
val liveIndoorToolsCommand: MutableLiveData<IndoorToolsCommand> = MutableLiveData()
|
||||
|
||||
/**
|
||||
* 是不是线选择模式
|
||||
@@ -159,9 +160,11 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
private var lastNiLocaion: NiLocation? = null
|
||||
|
||||
var currentIndexNiLocation: Int = 0
|
||||
private var currentIndexNiLocation: Int = 0
|
||||
|
||||
private var socketServer:SocketServer? = null
|
||||
private var socketServer: SocketServer? = null
|
||||
|
||||
var indoorToolsCommand: IndoorToolsCommand? = null
|
||||
|
||||
init {
|
||||
mapController.mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition ->
|
||||
@@ -208,7 +211,7 @@ class MainViewModel @Inject constructor(
|
||||
initNILocationData()
|
||||
}
|
||||
|
||||
socketServer = SocketServer(mapController,traceDataBase,sharedPreferences)
|
||||
socketServer = SocketServer(mapController, traceDataBase, sharedPreferences)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,6 +280,7 @@ class MainViewModel @Inject constructor(
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
private fun initLocation() {
|
||||
|
||||
val shareUtil = ShareUtil(mapController.mMapView.context, 1)
|
||||
//用于定位点存储到数据库
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
//用于定位点捕捉道路
|
||||
@@ -309,20 +313,20 @@ class MainViewModel @Inject constructor(
|
||||
}
|
||||
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||
location.taskId = id.toString()
|
||||
if (shareUtil.connectstate) {
|
||||
location.media = 1
|
||||
}
|
||||
var disance = 0.0
|
||||
//增加间距判断
|
||||
if (lastNiLocaion != null) {
|
||||
val disance = GeometryTools.getDistance(
|
||||
disance = GeometryTools.getDistance(
|
||||
location.latitude, location.longitude,
|
||||
lastNiLocaion!!.latitude, lastNiLocaion!!.longitude
|
||||
)
|
||||
//相距差距大于2.5米以上进行存储
|
||||
if (disance > 2.5 && disance < 60) {
|
||||
traceDataBase.niLocationDao.insert(location)
|
||||
mapController.markerHandle.addNiLocationMarkerItem(location)
|
||||
mapController.mMapView.vtmMap.updateMap(true)
|
||||
lastNiLocaion = location
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
//室内整理工具时不能进行轨迹存储,判断轨迹间隔要超过2.5并小于60米
|
||||
if (Constant.INDOOR_IP.isEmpty() && (disance == 0.0 || (disance > 2.5 && disance < 60))) {
|
||||
traceDataBase.niLocationDao.insert(location)
|
||||
mapController.markerHandle.addNiLocationMarkerItem(location)
|
||||
mapController.mMapView.vtmMap.updateMap(true)
|
||||
@@ -699,13 +703,19 @@ class MainViewModel @Inject constructor(
|
||||
liveDataSignMoreInfo.value = data
|
||||
}
|
||||
|
||||
fun sendServerCommand(context: Context, traceVideoBean: TraceVideoBean) {
|
||||
fun sendServerCommand(
|
||||
context: Context,
|
||||
traceVideoBean: TraceVideoBean,
|
||||
indoorToolsCommand: IndoorToolsCommand
|
||||
) {
|
||||
|
||||
if (TextUtils.isEmpty(Constant.INDOOR_IP)) {
|
||||
Toast.makeText(context, "获取ip失败!", Toast.LENGTH_LONG).show()
|
||||
return
|
||||
}
|
||||
|
||||
this.indoorToolsCommand = indoorToolsCommand
|
||||
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val url = "http://${Constant.INDOOR_IP}:8080/sensor/service/${traceVideoBean.command}?"
|
||||
|
||||
@@ -728,7 +738,8 @@ class MainViewModel @Inject constructor(
|
||||
"命令成功。",
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
qrCodeStatus.postValue(QrCodeStatus.QR_CODE_STATUS_UPDATE_VIDEO_INFO_SUCCESS)
|
||||
|
||||
liveIndoorToolsResp.postValue(IndoorToolsResp.QR_CODE_STATUS_UPDATE_VIDEO_INFO_SUCCESS)
|
||||
|
||||
//启动双向控制服务
|
||||
|
||||
@@ -750,6 +761,7 @@ class MainViewModel @Inject constructor(
|
||||
)
|
||||
.show()
|
||||
}
|
||||
liveIndoorToolsResp.postValue(IndoorToolsResp.QR_CODE_STATUS_UPDATE_VIDEO_INFO_FAILURE)
|
||||
}
|
||||
|
||||
} catch (e: IOException) {
|
||||
@@ -773,7 +785,7 @@ class MainViewModel @Inject constructor(
|
||||
)
|
||||
.show()
|
||||
}
|
||||
qrCodeStatus.postValue(QrCodeStatus.QR_CODE_STATUS_NET_FAILURE)
|
||||
liveIndoorToolsResp.postValue(IndoorToolsResp.QR_CODE_STATUS_UPDATE_VIDEO_INFO_FAILURE)
|
||||
}
|
||||
|
||||
is NetResult.Failure<*> -> {
|
||||
@@ -785,7 +797,7 @@ class MainViewModel @Inject constructor(
|
||||
)
|
||||
.show()
|
||||
}
|
||||
qrCodeStatus.postValue(QrCodeStatus.QR_CODE_STATUS_NET_FAILURE)
|
||||
liveIndoorToolsResp.postValue(IndoorToolsResp.QR_CODE_STATUS_UPDATE_VIDEO_INFO_FAILURE)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
@@ -814,6 +826,34 @@ class MainViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示索引位置
|
||||
* @param niLocation 轨迹点
|
||||
*/
|
||||
fun setCurrentIndexNiLocation(niLocation: NiLocation) {
|
||||
viewModelScope.launch ( Dispatchers.IO ){
|
||||
Log.e("qj","开始$currentIndexNiLocation")
|
||||
currentIndexNiLocation = mapController.markerHandle.getNILocationIndex(niLocation)!!
|
||||
Log.e("qj","结束$currentIndexNiLocation")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置索引位置
|
||||
* @param index 索引
|
||||
*/
|
||||
fun setCurrentIndexLoction(index: Int) {
|
||||
currentIndexNiLocation = index
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return index 索引
|
||||
*/
|
||||
fun getCurrentNiLocationIndex(): Int {
|
||||
return currentIndexNiLocation
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束自动播放
|
||||
*/
|
||||
@@ -833,22 +873,32 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
override fun onIndexing() {
|
||||
//切换为暂停状态
|
||||
indoorToolsStatus.postValue(IndoorToolsStatus.PAUSE)
|
||||
liveIndoorToolsCommand.postValue(IndoorToolsCommand.INDEXING)
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
TODO("Not yet implemented")
|
||||
liveIndoorToolsCommand.postValue(IndoorToolsCommand.STOP)
|
||||
}
|
||||
|
||||
override fun onPlay() {
|
||||
TODO("Not yet implemented")
|
||||
liveIndoorToolsCommand.postValue(IndoorToolsCommand.PLAY)
|
||||
}
|
||||
|
||||
override fun onParseEnd() {
|
||||
TODO("Not yet implemented")
|
||||
|
||||
}
|
||||
|
||||
override fun onReceiveLocation(mNiLocation: NiLocation?) {
|
||||
TODO("Not yet implemented")
|
||||
if (mNiLocation != null) {
|
||||
setCurrentIndexNiLocation(mNiLocation)
|
||||
showMarker(mapController.mMapView.context, mNiLocation)
|
||||
Log.e("qj","反向控制$currentIndexNiLocation")
|
||||
} else {
|
||||
BaseToast.makeText(
|
||||
mapController.mMapView.context,
|
||||
"没有找到对应轨迹点!",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,11 +24,25 @@ import java.util.Collections
|
||||
import kotlin.math.abs
|
||||
|
||||
|
||||
enum class IndoorToolsStatus {
|
||||
PAUSE,
|
||||
enum class IndoorToolsCommand {
|
||||
PLAY,
|
||||
SELECT_POINT,
|
||||
INDEXING,
|
||||
NEXT,
|
||||
REWIND
|
||||
REWIND,
|
||||
STOP
|
||||
}
|
||||
|
||||
enum class IndoorToolsResp{
|
||||
/**
|
||||
* 信息更新轨迹成功
|
||||
*/
|
||||
QR_CODE_STATUS_UPDATE_VIDEO_INFO_SUCCESS,
|
||||
|
||||
/**
|
||||
* 信息更新轨迹失败
|
||||
*/
|
||||
QR_CODE_STATUS_UPDATE_VIDEO_INFO_FAILURE,
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,6 +278,7 @@ class SocketServer(
|
||||
timeIndex = mTaskList.size - 1
|
||||
val result = parseResult(mTaskList[timeIndex])
|
||||
var resultNiLocation: NiLocation? = null
|
||||
var index: Int = -1
|
||||
if (result != null) {
|
||||
when (result.type) {
|
||||
1 -> {
|
||||
@@ -277,6 +292,9 @@ class SocketServer(
|
||||
val currentTimeStr: String = DateTimeUtil.TimePointSSSToTime(
|
||||
result.data
|
||||
)
|
||||
|
||||
Log.e(TAG, "反向"+result.data)
|
||||
|
||||
val startTime = currentTime - traceTimeBuffer
|
||||
val endTme = currentTime + traceTimeBuffer
|
||||
|
||||
@@ -291,21 +309,23 @@ class SocketServer(
|
||||
endTimeStr
|
||||
)
|
||||
) {
|
||||
|
||||
Log.e(TAG, "getTraceData开始")
|
||||
val list: List<NiLocation>? =
|
||||
getTrackList(startTimeStr, endTimeStr, currentTimeStr)
|
||||
|
||||
val list: List<NiLocation>? = getTrackList(startTimeStr, endTimeStr, currentTimeStr)
|
||||
|
||||
Log.e(TAG, "getTraceData结束")
|
||||
|
||||
if (list != null && list.size > 0) {
|
||||
|
||||
var disTime: Long = 0
|
||||
|
||||
|
||||
//只有一个点不进行判断直接返回结果
|
||||
if (list.size == 1) {
|
||||
resultNiLocation = list[0]
|
||||
} else {
|
||||
|
||||
//遍历集合取最近时间的轨迹点
|
||||
b@ for (nilocation in list) {
|
||||
|
||||
if (!TextUtils.isEmpty(nilocation.time)) {
|
||||
|
||||
//只获取到秒的常量
|
||||
@@ -323,15 +343,13 @@ class SocketServer(
|
||||
//第一次不对比,取当前值
|
||||
if (disTime == 0L) {
|
||||
disTime = disTimeTemp
|
||||
resultNiLocation =
|
||||
nilocation
|
||||
resultNiLocation = nilocation
|
||||
} else {
|
||||
|
||||
//前一个差值大于当前差值则取当前相对小的值
|
||||
if (disTime - disTimeTemp > 0) {
|
||||
disTime = disTimeTemp
|
||||
resultNiLocation =
|
||||
nilocation
|
||||
resultNiLocation = nilocation
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -343,6 +361,9 @@ class SocketServer(
|
||||
val msg1 = Message()
|
||||
msg1.what = 0x11
|
||||
msg1.obj = resultNiLocation
|
||||
if (resultNiLocation != null) {
|
||||
Log.e(TAG, "反向app"+resultNiLocation.time)
|
||||
}
|
||||
mHandler.sendMessage(msg1)
|
||||
}
|
||||
|
||||
@@ -373,6 +394,7 @@ class SocketServer(
|
||||
mHandler.sendMessage(msg2)
|
||||
}
|
||||
}
|
||||
Thread.sleep(10)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
val msg = Message()
|
||||
@@ -407,7 +429,7 @@ class SocketServer(
|
||||
|
||||
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||
|
||||
val list: MutableList<NiLocation> = traceDataBase.niLocationDao.taskIdAndTimeTofindList(id.toString(),startTime,endTime)
|
||||
val list: MutableList<NiLocation> = traceDataBase.niLocationDao.findToTaskIdAll(id.toString())
|
||||
|
||||
if (list.size > 0) return list
|
||||
}
|
||||
@@ -442,6 +464,7 @@ class SocketServer(
|
||||
connectFaild("连接断开")
|
||||
}
|
||||
}
|
||||
Thread.sleep(10)
|
||||
} catch (e: IOException) {
|
||||
connectFaild(e.toString())
|
||||
e.printStackTrace()
|
||||
|
||||
@@ -34,15 +34,6 @@ enum class QrCodeStatus {
|
||||
*/
|
||||
QR_CODE_STATUS_SERVER_INFO_SUCCESS,
|
||||
|
||||
/**
|
||||
* 信息更新轨迹成功
|
||||
*/
|
||||
QR_CODE_STATUS_UPDATE_VIDEO_INFO_SUCCESS,
|
||||
|
||||
/**
|
||||
* 信息更新轨迹失败
|
||||
*/
|
||||
QR_CODE_STATUS_UPDATE_VIDEO_INFO_FAILURE,
|
||||
}
|
||||
|
||||
@HiltViewModel
|
||||
|
||||
@@ -61,12 +61,6 @@ class QrCodeActivity : BaseActivity() {
|
||||
}
|
||||
QrCodeStatus.QR_CODE_STATUS_SERVER_INFO_SUCCESS -> {
|
||||
|
||||
}
|
||||
QrCodeStatus.QR_CODE_STATUS_UPDATE_VIDEO_INFO_SUCCESS -> {
|
||||
|
||||
}
|
||||
QrCodeStatus.QR_CODE_STATUS_UPDATE_VIDEO_INFO_FAILURE -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,10 +116,10 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
|
||||
}
|
||||
R.id.personal_center_menu_test -> {
|
||||
viewModel.readRealmData()
|
||||
//108.91056000267433 34.29635901721207
|
||||
//108.90107116103331 34.29568928574205
|
||||
// 定位到指定位置
|
||||
niMapController.mMapView.vtmMap.animator()
|
||||
.animateTo(GeoPoint( 34.29635901721207, 108.91056000267433))
|
||||
.animateTo(GeoPoint( 34.29568928574205, 108.90107116103331))
|
||||
}
|
||||
// R.id.personal_center_menu_task_list -> {
|
||||
// findNavController().navigate(R.id.TaskManagerFragment)
|
||||
|
||||
Reference in New Issue
Block a user