feat(servicing): 优化订单详情页面布局和功能
-调整订单信息显示布局,增加订单来源显示 - 优化地图标记添加逻辑,提高地图展示效果 - 改进路径规划功能,优化预计到达时间计算方式- 更新车辆损伤照片加载逻辑,提高数据展示效率 - 修复部分页面样式问题,提升用户体验
This commit is contained in:
@ -2,6 +2,7 @@ package com.za.net
|
||||
|
||||
import android.net.ParseException
|
||||
import com.blankj.utilcode.util.ActivityUtils
|
||||
import com.blankj.utilcode.util.ThreadUtils
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import com.google.gson.JsonParseException
|
||||
import com.za.base.Const
|
||||
@ -22,90 +23,95 @@ import javax.net.ssl.SSLHandshakeException
|
||||
* Created by DoggieX on 2017/7/26.
|
||||
*/
|
||||
abstract class BaseObserver<T> : Observer<BaseResponse<T>> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
// if (!NetworkUtils.isAvailable()) {
|
||||
// doFailure(999, "网络无法使用")
|
||||
// d.dispose()
|
||||
// }
|
||||
}
|
||||
override fun onSubscribe(d : Disposable) { // if (!NetworkUtils.isAvailable()) {
|
||||
// doFailure(999, "网络无法使用")
|
||||
// d.dispose()
|
||||
// }
|
||||
}
|
||||
|
||||
override fun onNext(tBaseResponse: BaseResponse<T>) {
|
||||
if (tBaseResponse.isOk) {
|
||||
doSuccess(tBaseResponse.result)
|
||||
} else {
|
||||
when (tBaseResponse.code) {
|
||||
3, 401 -> handlerTokenExpired()
|
||||
// 4 -> RsaRouter.navigate(context, "/page/Standby")
|
||||
}
|
||||
if (null != tBaseResponse.msg) {
|
||||
doFailure(tBaseResponse.code, tBaseResponse.msg)
|
||||
} else if (null != tBaseResponse.message) {
|
||||
doFailure(tBaseResponse.code, tBaseResponse.message)
|
||||
} else {
|
||||
doFailure(tBaseResponse.code, "error")
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun onNext(tBaseResponse : BaseResponse<T>) {
|
||||
if (tBaseResponse.isOk) {
|
||||
doSuccess(tBaseResponse.result)
|
||||
} else {
|
||||
when (tBaseResponse.code) {
|
||||
3, 401 -> handlerTokenExpired()
|
||||
}
|
||||
val errMsg = if (null != tBaseResponse.msg) {
|
||||
tBaseResponse.msg
|
||||
} else if (null != tBaseResponse.message) {
|
||||
tBaseResponse.message
|
||||
} else {
|
||||
"error"
|
||||
}
|
||||
doFailure(tBaseResponse.code, errMsg)
|
||||
if (errMsg?.contains("请下载新版本app!") == true) {
|
||||
handlerTokenExpired()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
LogUtil.print("net error", e)
|
||||
when (e) {
|
||||
is JsonParseException -> {
|
||||
doFailure(1, "数据解析错误")
|
||||
}
|
||||
override fun onError(e : Throwable) {
|
||||
LogUtil.print("net error", e)
|
||||
when (e) {
|
||||
is JsonParseException -> {
|
||||
doFailure(1, "数据解析错误")
|
||||
}
|
||||
|
||||
is JSONException -> {
|
||||
doFailure(1, "数据解析错误")
|
||||
}
|
||||
is JSONException -> {
|
||||
doFailure(1, "数据解析错误")
|
||||
}
|
||||
|
||||
is ParseException -> {
|
||||
doFailure(1, "数据解析错误")
|
||||
}
|
||||
is ParseException -> {
|
||||
doFailure(1, "数据解析错误")
|
||||
}
|
||||
|
||||
is ConnectException -> {
|
||||
doFailure(Const.NetWorkException, "与服务器断开连接")
|
||||
}
|
||||
is ConnectException -> {
|
||||
doFailure(Const.NetWorkException, "与服务器断开连接")
|
||||
}
|
||||
|
||||
is UnknownHostException -> {
|
||||
doFailure(Const.NetWorkException, "与服务器断开连接")
|
||||
}
|
||||
is UnknownHostException -> {
|
||||
doFailure(Const.NetWorkException, "与服务器断开连接")
|
||||
}
|
||||
|
||||
is SSLHandshakeException -> {
|
||||
doFailure(1, "证书验证失败")
|
||||
LogUtil.print("SSLHandshakeException", e)
|
||||
}
|
||||
is SSLHandshakeException -> {
|
||||
doFailure(1, "证书验证失败")
|
||||
LogUtil.print("SSLHandshakeException", e)
|
||||
}
|
||||
|
||||
is TimeoutException -> {
|
||||
doFailure(Const.NetWorkException, "网络连接超时1")
|
||||
LogUtil.print("TimeoutException", e)
|
||||
}
|
||||
is TimeoutException -> {
|
||||
doFailure(Const.NetWorkException, "网络连接超时1")
|
||||
LogUtil.print("TimeoutException", e)
|
||||
}
|
||||
|
||||
is SocketTimeoutException -> {
|
||||
doFailure(Const.NetWorkException, "网络连接超时2")
|
||||
LogUtil.print("SocketTimeoutException2", e)
|
||||
}
|
||||
else -> {
|
||||
doFailure(1, "error:" + e.message)
|
||||
LogUtil.print("other error", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
is SocketTimeoutException -> {
|
||||
doFailure(Const.NetWorkException, "网络连接超时2")
|
||||
LogUtil.print("SocketTimeoutException2", e)
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
}
|
||||
else -> {
|
||||
doFailure(1, "error:" + e.message)
|
||||
LogUtil.print("other error", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun doSuccess(it: T?)
|
||||
override fun onComplete() {
|
||||
}
|
||||
|
||||
abstract fun doFailure(code: Int, msg: String?)
|
||||
abstract fun doSuccess(it : T?)
|
||||
|
||||
private fun handlerTokenExpired() {
|
||||
ToastUtils.showShort("登陆信息已过期,请重新登录")
|
||||
try {
|
||||
GlobalData.clearUserCache()
|
||||
ZdLocationManager.stopContinuousLocation()
|
||||
ActivityUtils.finishAllActivities()
|
||||
} catch (e: Exception) {
|
||||
LogUtil.print("handlerTokenExpired", e)
|
||||
}
|
||||
}
|
||||
abstract fun doFailure(code : Int, msg : String?)
|
||||
|
||||
private fun handlerTokenExpired() {
|
||||
ThreadUtils.runOnUiThread {
|
||||
try {
|
||||
ToastUtils.showShort("登陆信息已过期,请重新登录")
|
||||
GlobalData.clearUserCache()
|
||||
ZdLocationManager.stopContinuousLocation()
|
||||
ActivityUtils.startLauncherActivity()
|
||||
} catch (e : Exception) {
|
||||
LogUtil.print("handlerTokenExpired", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user