[fix]
[实时系统 处理错误]
This commit is contained in:
yangyakun
2024-11-01 19:23:19 +08:00
parent a8329efb83
commit fb591a551a
7 changed files with 106 additions and 3 deletions

View File

@@ -0,0 +1,64 @@
package com.mogo.och.common.module.wigets.commonview
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.utilcode.kotlin.onClick
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.map.listener.IMogoMapListener
import com.mogo.och.common.module.R
import com.mogo.och.common.module.utils.ResourcesUtils
import kotlinx.android.synthetic.main.common_error_view.view.tv_error_msg
class ErrorView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr),IMogoMapListener {
companion object {
const val TAG = "LoadingMapStatusView"
}
private var emptyTitle:String = ""
var reloadLIstener:ReloadLIstener?=null
init {
LayoutInflater.from(context).inflate(R.layout.common_error_view, this, true)
try {
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ErrorView)
emptyTitle = typedArray.getString(R.styleable.ErrorView_error_title)?:ResourcesUtils.getString(R.string.common_error_data)
typedArray.recycle()
} catch (e: Exception) {
e.printStackTrace()
}
tv_error_msg.text = emptyTitle
tv_error_msg.onClick {
reloadLIstener?.reload()
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
CallerLogger.d(TAG,"onAttachedToWindow")
}
override fun onVisibilityAggregated(isVisible: Boolean) {
super.onVisibilityAggregated(isVisible)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
CallerLogger.d(TAG,"onDetachedFromWindow")
}
interface ReloadLIstener{
fun reload()
}
}

View File

@@ -19,6 +19,11 @@
</declare-styleable>
<declare-styleable name="ErrorView">
<attr name="error_title" format="string" />
</declare-styleable>
<!--阴影布局 -->
<declare-styleable name="ShadowLayout">
<!-- 阴影颜色-->

View File

@@ -32,4 +32,5 @@
<string name="common_biz_loading">加载中……</string>
<string name="common_empty_data">暂无数据</string>
<string name="common_error_data">重新加载</string>
</resources>

View File

@@ -220,7 +220,15 @@ object LineModel {
override fun onError(e: Throwable) {
d(TAG, "commitSwitchLineId onError${e.printStackTrace()}")
if (e is DataException) {
if(RepositoryManager.supportDb()) {
if (e is DataException) {
OchChainLogManager.writeChainLog("开始任务", "${e.message}")
ToastUtils.showShort("选择任务失败:${e.message}")
mBusLinesCallbackMap.forEach {
it.value.onChangeLineIdFail()
}
}
}else{
OchChainLogManager.writeChainLog("开始任务", "${e.message}")
ToastUtils.showShort("选择任务失败:${e.message}")
mBusLinesCallbackMap.forEach {

View File

@@ -20,6 +20,7 @@ import com.mogo.och.common.module.manager.loop.BizLoopManager
import com.mogo.och.common.module.utils.ResourcesUtils
import com.mogo.och.common.module.wigets.WindowRelativeLayout
import com.mogo.och.common.module.wigets.WrapContentLinearLayoutManager
import com.mogo.och.common.module.wigets.commonview.ErrorView
import com.mogo.och.shuttle.weaknet.R
import com.mogo.och.weaknet.model.LineModel
import com.mogo.och.weaknet.repository.RepositoryManager
@@ -29,6 +30,7 @@ import kotlinx.android.synthetic.main.shuttle_wadk_task_running.view.no_order_da
import kotlinx.android.synthetic.main.shuttle_weak_switch_line.view.aciv_refresh_task
import kotlinx.android.synthetic.main.shuttle_weak_switch_line.view.actv_last_refresh_date
import kotlinx.android.synthetic.main.shuttle_weak_switch_line.view.include_empty
import kotlinx.android.synthetic.main.shuttle_weak_switch_line.view.include_errorview
import kotlinx.android.synthetic.main.shuttle_weak_switch_line.view.switch_line_rv
import me.jessyan.autosize.utils.AutoSizeUtils
@@ -99,6 +101,12 @@ class SwitchLineView: WindowRelativeLayout, SwtichLineModel.SwtichLineViewCallba
}
animator?.start()
}
include_errorview.reloadLIstener = object :ErrorView.ReloadLIstener{
override fun reload() {
viewbizModel?.showSwitchLineInfo()
}
}
}
/**
@@ -151,6 +159,7 @@ class SwitchLineView: WindowRelativeLayout, SwtichLineModel.SwtichLineViewCallba
*/
private fun showNoData(b: Boolean) {
BizLoopManager.runInMainThread{
include_errorview.visibility = View.GONE
if (b) {
switch_line_rv.visibility = View.GONE
include_empty.visibility = View.VISIBLE
@@ -173,8 +182,12 @@ class SwitchLineView: WindowRelativeLayout, SwtichLineModel.SwtichLineViewCallba
}
override fun onBusLinesChangeFaile() {
include_errorview.visibility = View.VISIBLE
switch_line_rv.visibility = View.GONE
include_empty.visibility = View.GONE
viewbizModel?.showSwitchLineInfoResult()
}
}

View File

@@ -57,6 +57,7 @@ class SwtichLineModel : ViewModel(), IBusLinesCallback {
override fun onError(e: Throwable) {
d(LineModel.TAG, "queryBusLines onError${e.printStackTrace()}")
viewCallback?.onBusLinesChangeFaile()
}
override fun onComplete() {
@@ -93,6 +94,7 @@ class SwtichLineModel : ViewModel(), IBusLinesCallback {
fun startTaskState(success: Boolean)
fun onBusLinesChange(data: MutableList<LineDataBean>?,show:Boolean)
fun refreshDate(formatLongToString: String?)
fun onBusLinesChangeFaile()
}
override fun onRefreshSuccess(currentTimeStamp: Long) {

View File

@@ -60,4 +60,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<com.mogo.och.common.module.wigets.commonview.ErrorView
android:id="@+id/include_errorview"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.constraintlayout.widget.ConstraintLayout>