[feedback]添加主动场景内置并优化数据加载逻辑
This commit is contained in:
@@ -14,6 +14,7 @@ import androidx.lifecycle.lifecycleScope
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.utilcode.kotlin.PX
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.kotlin.lifecycleOwner
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
@@ -251,7 +252,12 @@ internal object BadCaseManager : LifecycleEventObserver {
|
||||
val context = viewHolder?.get()?.context ?: Utils.getApp()
|
||||
BadCaseView(context).also { itx ->
|
||||
itx.register(record, onDismiss, onSelect)
|
||||
hideFloat = CallerHmiManager.showFloatWindow("BadCaseFloat", floatView = itx, WindowManager.LayoutParams().also { it.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE})
|
||||
CallerHmiManager.showFloatWindow("BadCaseFloat", floatView = itx, WindowManager.LayoutParams().also {
|
||||
it.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
|
||||
}
|
||||
).also {
|
||||
hideFloat = it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ internal class BadCaseView: ConstraintLayout {
|
||||
LayoutInflater.from(context).inflate(R.layout.layout_badcase_collect, this, true)
|
||||
background = ColorDrawable(Color.parseColor("#F0151D41"))
|
||||
isClickable = true
|
||||
layoutParams = ViewGroup.LayoutParams(960.PX, 1528.PX)
|
||||
layoutParams = ViewGroup.LayoutParams(960.PX, 1600.PX)
|
||||
close?.onClick {
|
||||
onDismiss?.invoke()
|
||||
}
|
||||
|
||||
@@ -26,7 +26,21 @@ internal class Repository {
|
||||
}
|
||||
|
||||
suspend fun loadBadCases(isDriven: Boolean): List<Reason> {
|
||||
return net.get()?.data?.takeIf { it.isNotEmpty() }?.also { store.updateRecords(it, isDriven) } ?: store.records(isDriven).takeIf { it.isNotEmpty() } ?: getBuildIn(isDriven)
|
||||
return mutableListOf<Reason>().also { itx ->
|
||||
net.get(if (isDriven) "被动" else "主动", itx, 1)
|
||||
itx
|
||||
.takeIf { it.isNotEmpty() }
|
||||
?.also {
|
||||
store.updateRecords(it, isDriven)
|
||||
}
|
||||
?:
|
||||
store
|
||||
.records(isDriven)
|
||||
.takeIf {
|
||||
it.isNotEmpty()
|
||||
}
|
||||
?: getBuildIn(isDriven)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun uploadLastModified(timestamp: Long) {
|
||||
@@ -34,7 +48,6 @@ internal class Repository {
|
||||
}
|
||||
|
||||
suspend fun getLastModified(): Long {
|
||||
CallerLogger.d("$M_DEVA${BadCaseManager.TAG}", " --- 3 ----")
|
||||
return store.getLastModified()
|
||||
}
|
||||
|
||||
@@ -45,37 +58,84 @@ internal class Repository {
|
||||
data += Reason().also {
|
||||
it.id = "1"
|
||||
it.reason = "变道有干扰"
|
||||
it.channel = "被动"
|
||||
}
|
||||
data += Reason().also {
|
||||
it.id = "2"
|
||||
it.reason = "遇红绿灯未停车"
|
||||
it.channel = "被动"
|
||||
}
|
||||
data += Reason().also {
|
||||
it.id = "3"
|
||||
it.reason = "遇障碍物未停车"
|
||||
it.channel = "被动"
|
||||
}
|
||||
data += Reason().also {
|
||||
it.id = "4"
|
||||
it.reason = "无法绕行"
|
||||
it.channel = "被动"
|
||||
}
|
||||
data += Reason().also {
|
||||
it.id = "5"
|
||||
it.reason = "画龙"
|
||||
it.channel = "被动"
|
||||
}
|
||||
data += Reason().also {
|
||||
it.id = "6"
|
||||
it.reason = "转弯过于靠近路侧"
|
||||
it.channel = "被动"
|
||||
}
|
||||
data += Reason().also {
|
||||
it.id = "7"
|
||||
it.reason = "无故退出自动驾驶"
|
||||
it.channel = "被动"
|
||||
}
|
||||
data += Reason().also {
|
||||
it.id = "8"
|
||||
it.reason = "其它"
|
||||
it.channel = "被动"
|
||||
}
|
||||
} else {
|
||||
TODO()
|
||||
data += Reason().also {
|
||||
it.id = "1"
|
||||
it.reason = "定位异常"
|
||||
it.channel = "主动"
|
||||
}
|
||||
data += Reason().also {
|
||||
it.id = "2"
|
||||
it.reason = "画龙"
|
||||
it.channel = "主动"
|
||||
}
|
||||
data += Reason().also {
|
||||
it.id = "3"
|
||||
it.reason = "红绿灯不识别"
|
||||
it.channel = "主动"
|
||||
}
|
||||
data += Reason().also {
|
||||
it.id = "4"
|
||||
it.reason = "地图异常"
|
||||
it.channel = "主动"
|
||||
}
|
||||
data += Reason().also {
|
||||
it.id = "5"
|
||||
it.reason = "感知异常"
|
||||
it.channel = "主动"
|
||||
}
|
||||
data += Reason().also {
|
||||
it.id = "6"
|
||||
it.reason = "业务异常"
|
||||
it.channel = "主动"
|
||||
}
|
||||
data += Reason().also {
|
||||
it.id = "7"
|
||||
it.reason = "显示异常"
|
||||
it.channel = "主动"
|
||||
}
|
||||
data += Reason().also {
|
||||
it.id = "8"
|
||||
it.reason = "其它"
|
||||
it.channel = "主动"
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -5,28 +5,37 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.BadCaseManager
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.repository.net.api.BadCaseApi
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.repository.net.api.entity.BadCaseResponse
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.repository.net.api.entity.UploadResult
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.consts.BadCaseHost
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.repository.net.api.entity.BadCaseResponse.Reason
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
internal class BadCaseNetModel {
|
||||
|
||||
suspend fun get(): BadCaseResponse? = try {
|
||||
CallerLogger.d("$M_DEVA${BadCaseManager.TAG}", "-- load cases from net -- 1 --")
|
||||
MoGoRetrofitFactory
|
||||
.getInstance(BadCaseHost.getHost())
|
||||
.create(BadCaseApi::class.java)
|
||||
.get()
|
||||
.takeIf {
|
||||
val body = it.body()
|
||||
it.isSuccessful && body != null && (body.code == 0 || body.code == 200)
|
||||
}
|
||||
?.body()?.also {
|
||||
CallerLogger.d("$M_DEVA${BadCaseManager.TAG}", "-- load cases from net -- 2 --")
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
CallerLogger.d("$M_DEVA${BadCaseManager.TAG}", "-- load cases from net -- 3 --")
|
||||
null
|
||||
suspend fun get(channel: String?, result: MutableList<Reason>, pageNo: Int) {
|
||||
try {
|
||||
MoGoRetrofitFactory
|
||||
.getInstance(BadCaseHost.getHost())
|
||||
.create(BadCaseApi::class.java)
|
||||
.get(channel ?: "", pageNo)
|
||||
.takeIf {
|
||||
val body = it.body()
|
||||
it.isSuccessful && body != null && (body.code == 0 || body.code == 200)
|
||||
}
|
||||
?.body()?.also {
|
||||
val data = it.data
|
||||
if (data == null || it.total <= result.size) {
|
||||
return@also
|
||||
}
|
||||
result += data
|
||||
withContext(coroutineContext) {
|
||||
get(channel, result, pageNo + 1)
|
||||
}
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
CallerLogger.d("$M_DEVA${BadCaseManager.TAG}", "-- load cases from net error: $t")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun upload(map: Map<String, String>): UploadResult? = try {
|
||||
|
||||
@@ -3,10 +3,7 @@ package com.zhjt.mogo_core_function_devatools.badcase.repository.net.api
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.repository.net.api.entity.BadCaseResponse
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.repository.net.api.entity.UploadResult
|
||||
import retrofit2.Response
|
||||
import retrofit2.http.FieldMap
|
||||
import retrofit2.http.FormUrlEncoded
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.*
|
||||
|
||||
internal interface BadCaseApi {
|
||||
|
||||
@@ -15,5 +12,5 @@ internal interface BadCaseApi {
|
||||
suspend fun post(@FieldMap map: Map<String, String>): Response<UploadResult>
|
||||
|
||||
@GET("/yycp-vehicle-management-service/tool/badcase/reasons")
|
||||
suspend fun get(): Response<BadCaseResponse>
|
||||
suspend fun get(@Query("channel", encoded = true) channel: String, @Query("pageNo") pageNo: Int): Response<BadCaseResponse>
|
||||
}
|
||||
@@ -8,16 +8,13 @@ internal class BadCaseResponse {
|
||||
var code: Int = -1
|
||||
var data: List<Reason>? = null
|
||||
var msg: String? = null
|
||||
var success: Boolean = false
|
||||
var total: Int = -1
|
||||
|
||||
@Expose(serialize = false, deserialize = false)
|
||||
var isBuildIn: Boolean = false
|
||||
|
||||
@Keep
|
||||
class Reason {
|
||||
var id: String? = null
|
||||
var reason: String? = null
|
||||
var channel: String? = null
|
||||
|
||||
/**
|
||||
* 业务字段,不参与序列化和反序列化
|
||||
@@ -25,21 +22,8 @@ internal class BadCaseResponse {
|
||||
@Expose(deserialize = false, serialize = false)
|
||||
var isChecked: Boolean = false
|
||||
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (javaClass != other?.javaClass) return false
|
||||
other as Reason
|
||||
if (id != other.id) return false
|
||||
if (reason != other.reason) return false
|
||||
if (isChecked != other.isChecked) return false
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = id?.hashCode() ?: 0
|
||||
result = 31 * result + (reason?.hashCode() ?: 0)
|
||||
result = 31 * result + isChecked.hashCode()
|
||||
return result
|
||||
override fun toString(): String {
|
||||
return "Reason(id=$id, reason=$reason, channel=$channel, isChecked=$isChecked)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ internal object BadCaseStore {
|
||||
get() = BadCauses.getDefaultInstance()
|
||||
|
||||
override suspend fun readFrom(input: InputStream): BadCauses = suspendCancellableCoroutine {
|
||||
CallerLogger.d("$M_DEVA${BadCaseManager.TAG}", "--- readFrom ---")
|
||||
it.invokeOnCancellation {
|
||||
Thread.currentThread().interrupt()
|
||||
}
|
||||
@@ -65,6 +64,7 @@ internal object BadCaseStore {
|
||||
data += Cause.newBuilder().let {
|
||||
it.id = itx.id
|
||||
it.reason = itx.reason
|
||||
it.channel = itx.channel
|
||||
it.build()
|
||||
}
|
||||
}
|
||||
@@ -78,14 +78,12 @@ internal object BadCaseStore {
|
||||
}
|
||||
|
||||
suspend fun updateLastModified(timestamp: Long): BadCauses {
|
||||
CallerLogger.d("$M_DEVA${BadCaseManager.TAG}", "--- updateLastModified ---")
|
||||
return store.updateData { itx ->
|
||||
itx.toBuilder().setLastModified(timestamp).build()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getLastModified(): Long {
|
||||
CallerLogger.d("$M_DEVA${BadCaseManager.TAG}", " --- 4 ----")
|
||||
return store
|
||||
.data
|
||||
.catch {
|
||||
@@ -107,6 +105,7 @@ internal object BadCaseStore {
|
||||
Reason().also { itx ->
|
||||
itx.id = it.id
|
||||
itx.reason = it.reason
|
||||
itx.channel = it.channel
|
||||
}
|
||||
}?.fold(mutableListOf()) { acc, reason ->
|
||||
acc += reason
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.zhjt.mogo_core_function_devatools.feedback
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.widget.TextView
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
@@ -11,10 +12,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onDetach
|
||||
import com.mogo.eagle.core.utilcode.kotlin.safeCancel
|
||||
import com.mogo.eagle.core.utilcode.kotlin.scope
|
||||
import com.mogo.eagle.core.utilcode.kotlin.toast
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.zhjt.mogo_core_function_devatools.R
|
||||
@@ -47,7 +45,7 @@ internal object FeedbackManager {
|
||||
|
||||
|
||||
fun showFeedbackWindow(ctx: Context) {
|
||||
CallerHmiManager.showFloatWindow("FeedbackWindow", FeedBackView(ctx).also { itx ->
|
||||
CallerHmiManager.showFloatWindow("Feedback", FeedBackView(ctx).also { itx ->
|
||||
itx.registerCallback(object : IFeedbackCallback {
|
||||
override fun onClose() {
|
||||
hideFloat?.invoke()
|
||||
@@ -130,7 +128,10 @@ internal object FeedbackManager {
|
||||
}
|
||||
}
|
||||
})
|
||||
}, WindowManager.LayoutParams().also { it.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN }).also { hideFloat = it }
|
||||
}, WindowManager.LayoutParams().also {
|
||||
it.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN
|
||||
}
|
||||
).also { hideFloat = it }
|
||||
}
|
||||
|
||||
private fun startRecordLog(record: AutoPilotRecord) {
|
||||
|
||||
@@ -47,7 +47,7 @@ internal class FeedBackView : ConstraintLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
layoutParams = ViewGroup.LayoutParams(960.PX, 1528.PX)
|
||||
layoutParams = ViewGroup.LayoutParams(960.PX, 1600.PX)
|
||||
close.onClick {
|
||||
cb?.onClose()
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ internal class BadCaseFBViewHolder(cb: IFeedbackCallback?, parent: ViewGroup): F
|
||||
view.onClick {
|
||||
cb?.onBadCaseItemClicked(itx)
|
||||
}
|
||||
view.layoutParams = FlexboxLayout.LayoutParams(FlexboxLayout.LayoutParams.MATCH_PARENT, FlexboxLayout.LayoutParams.WRAP_CONTENT).also {
|
||||
view.layoutParams = FlexboxLayout.LayoutParams(FlexboxLayout.LayoutParams.WRAP_CONTENT, FlexboxLayout.LayoutParams.WRAP_CONTENT).also {
|
||||
it.flexBasisPercent = 0.5f
|
||||
}
|
||||
addView(view)
|
||||
|
||||
@@ -14,6 +14,7 @@ message BadCauses {
|
||||
message Cause {
|
||||
string id = 1;
|
||||
string reason = 2;
|
||||
string channel = 3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_marginBottom="120px"/>
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/close"
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.eagle.core.function.hmi.notification.anim
|
||||
import android.animation.Animator
|
||||
import android.animation.ValueAnimator
|
||||
import android.graphics.Rect
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import com.mogo.eagle.core.data.enums.SidePattern
|
||||
@@ -49,7 +50,9 @@ open class DefaultAnimator : OnFloatAnimator {
|
||||
if (triple.third) params.x = value else params.y = value
|
||||
// 动画执行过程中页面关闭,出现异常
|
||||
windowManager.updateViewLayout(view, params)
|
||||
Log.d("XXX", "update ---> ${it.animatedValue}, ${it.animatedFraction}, $value")
|
||||
} catch (e: Exception) {
|
||||
Log.d("XXX", "exception ---> $e")
|
||||
cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
|
||||
.setAnimator(object : DefaultAnimator() {
|
||||
override fun enterAnim(
|
||||
view: View,
|
||||
params: WindowManager.LayoutParams,
|
||||
params:LayoutParams,
|
||||
windowManager: WindowManager,
|
||||
sidePattern: SidePattern
|
||||
): Animator? =
|
||||
|
||||
Reference in New Issue
Block a user