[fix]
[前台检测是否有执行的任务、loading 超时处理]
This commit is contained in:
yangyakun
2024-11-15 11:07:07 +08:00
parent ac73ef625b
commit 4d89031d22
8 changed files with 641 additions and 1 deletions

View File

@@ -457,6 +457,10 @@ object OrderModel {
ToastUtils.showShort(ResourcesUtils.getString(R.string.shuttle_logout_error))
return@execute
}
if(RepositoryManager.haveRunningTask()){
ToastUtils.showShort(ResourcesUtils.getString(R.string.shuttle_logout_error_running))
return@execute
}
MapMakerManager.removeAllMapMarkerByOwner(TAG)
BusTrajectoryManager.getInstance().stopTrajReqLoop();
LoginStatusManager.loginOut()

View File

@@ -32,6 +32,10 @@ interface IRepository {
fun reportCabinEvent(context: Context?, data: ShuttleEventRequest?, callback: OchCommonServiceCallback<BaseData?>?)
fun haveRunningTask(): Boolean{
return false
}
fun release()
}

View File

@@ -96,6 +96,10 @@ object RepositoryManager {
repository?.queryWriteoffCount(context,taskId,siteId,callback)
}
fun haveRunningTask():Boolean{
return repository?.haveRunningTask()?:false
}
fun haveDataWaitSyn(): Boolean {
if(ProjectUtils.isSaas()&&AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) {

View File

@@ -337,6 +337,14 @@ class WeaknetRepository : IRepository {
weakNetInterface?.reportCabinEvent(context,data,callback)
}
override fun haveRunningTask(): Boolean {
if(LineModel.currentTask==null){
return false
}else{
return true
}
}
override fun release() {
weakNetInterface = null
CallerLogger.d(TAG,"重置 weakNetInterface")

View File

@@ -7,10 +7,13 @@ import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.findViewTreeViewModelStoreOwner
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
import com.mogo.och.common.module.utils.ResourcesUtils
import com.mogo.och.common.module.utils.RxUtils
import com.mogo.och.common.module.wigets.WindowRelativeLayout
import com.mogo.och.shuttle.weaknet.R
import com.mogo.och.weaknet.repository.db.bean.LineDataBean
import io.reactivex.disposables.Disposable
import kotlinx.android.synthetic.main.shuttle_weak_switch_biz.view.loading_biz
import kotlinx.android.synthetic.main.shuttle_weak_switch_biz.view.swtichLine
import kotlinx.android.synthetic.main.shuttle_weak_switch_biz.view.swtichTask
@@ -34,6 +37,8 @@ class SwitchBizView: WindowRelativeLayout, SwtichBizeModel.SwtichLineViewCallbac
private var viewModel: SwtichBizeModel?=null
private var queryTimeout: Disposable? = null
init {
LayoutInflater.from(context).inflate(R.layout.shuttle_weak_switch_biz, this, true)
@@ -57,9 +62,14 @@ class SwitchBizView: WindowRelativeLayout, SwtichBizeModel.SwtichLineViewCallbac
// 展示loading页面
override fun showLoadingView(){
startLoading = System.currentTimeMillis()
CallerLogger.d(TAG,"开始展示 lading 时间:${startLoading}")
loading_biz.visibility = VISIBLE
swtichLine.visibility = GONE
swtichTask.visibility = GONE
queryTimeout = RxUtils.createSubscribe(10_1000) {
OchChainLogManager.writeChainLog("Loading超时","loading 展示了10s")
viewModel?.queryRuningTask()
}
}
@@ -78,8 +88,8 @@ class SwitchBizView: WindowRelativeLayout, SwtichBizeModel.SwtichLineViewCallbac
// 展示选择任务页面
override fun showSwitchTaskInfo() {
RxUtils.disposeSubscribe(queryTimeout)
val endLoading = System.currentTimeMillis()
val dex = (100-(endLoading - startLoading)).takeIf { it>=0 }?:0
CallerLogger.d(TAG,"展示任务 lading 展示了 ${dex}毫秒")
@@ -93,6 +103,7 @@ class SwitchBizView: WindowRelativeLayout, SwtichBizeModel.SwtichLineViewCallbac
// 展示选择线路页面
override fun showSwtichLineView() {
RxUtils.disposeSubscribe(queryTimeout)
val endLoading = System.currentTimeMillis()
val dex = (100-(endLoading - startLoading)).takeIf { it>=0 }?:0
CallerLogger.d(TAG,"展示线路 lading 展示了 ${dex}毫秒")
@@ -106,6 +117,7 @@ class SwitchBizView: WindowRelativeLayout, SwtichBizeModel.SwtichLineViewCallbac
}
// 展示正在进行的任务
override fun loadRunningTask() {
RxUtils.disposeSubscribe(queryTimeout)
val endLoading = System.currentTimeMillis()
val dex = (100-(endLoading - startLoading)).takeIf { it>=0 }?:0
CallerLogger.d(TAG,"展示运行中任务 lading 展示了 ${dex}毫秒")

View File

@@ -36,6 +36,12 @@ class SwtichBizeModel : ViewModel(), IBusLinesCallback {
}
}
fun queryRuningTask(){
ThreadUtils.getIoPool().execute {
OrderModel.queryBusRoutes()
}
}
fun loadingSwitchTask(lineInfo: LineDataBean) {
d(LineModel.TAG, "loadingSwitchTask 查询线路的任务线路信息:${lineInfo}")
viewCallback?.showSwitchTaskByLineInfo(lineInfo)

View File

@@ -47,6 +47,7 @@
<string name="bus_dialog_cancel">取消</string>
<string name="shuttle_logout_error">请在网络良好的区域完成任务信息同步后退出</string>
<string name="shuttle_logout_error_running">请结束任务后再退出登录</string>
<string name="bus_no_task_tip">暂无任务</string>
<string name="shuttle_write_off_count">核销%1$d人</string>