[6.7.0][启自驾] feat: 增加启自驾父容器 View;
feat: 增驾调用 Och 自定义 view 接口&provider ;
This commit is contained in:
@@ -8,6 +8,6 @@ class FacadeConst {
|
||||
// OCH arouter 路由path
|
||||
const val DRIVER_PATH = "/driver/api"
|
||||
const val PASSENGER_PATH = "/passenger/api"
|
||||
|
||||
const val OCH_VIEW_PATH = "/och/view/api"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.mogo.och.facade.view
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.function.api.och.IOchCustomViewProvider
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.och.facade.constant.FacadeConst
|
||||
import kotlin.random.Random
|
||||
|
||||
@Route(path = FacadeConst.OCH_VIEW_PATH)
|
||||
class OchCustomViewProvider : IOchCustomViewProvider {
|
||||
|
||||
companion object {
|
||||
const val TAG = "OchCustomViewProvider"
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
CallerLogger.d(TAG, "init")
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 Och业务层 自定义View
|
||||
*/
|
||||
override fun createOchBusinessView(context: Context?): View? {
|
||||
return context?.let {
|
||||
TextView(it).apply {
|
||||
text = "业务自定义View"
|
||||
gravity = Gravity.CENTER
|
||||
setBackgroundColor(
|
||||
Color.rgb(
|
||||
Random.nextInt(256),
|
||||
Random.nextInt(256),
|
||||
Random.nextInt(256)
|
||||
)
|
||||
)
|
||||
}
|
||||
} ?: null
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 自动自动驾驶 自定义 View
|
||||
*/
|
||||
override fun createStartAutopilotView(context: Context?): View? {
|
||||
return context?.let {
|
||||
TextView(it).apply {
|
||||
text = "启动自动驾驶"
|
||||
gravity = Gravity.CENTER
|
||||
setBackgroundColor(
|
||||
Color.rgb(
|
||||
Random.nextInt(256),
|
||||
Random.nextInt(256),
|
||||
Random.nextInt(256)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,16 @@ import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.mogo.eagle.core.function.call.och.CallerOchCustomViewManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.bone.status.StartAutoPilotStatusView
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.zhjt.mogo_core_function_devatools.status.StatusManager
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.SpeedStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.Status
|
||||
import kotlinx.android.synthetic.main.view_bone_top_status.view.speed_custom
|
||||
import kotlinx.android.synthetic.main.view_bone_top_status.view.startAutoPilotContainer
|
||||
import kotlinx.android.synthetic.main.view_bone_top_status.view.topStatusContainer
|
||||
|
||||
class BoneTopStatusLayout @JvmOverloads constructor(
|
||||
@@ -24,6 +28,24 @@ class BoneTopStatusLayout @JvmOverloads constructor(
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_bone_top_status, this, true)
|
||||
addStartAutoPilotView()
|
||||
}
|
||||
|
||||
private fun addStartAutoPilotView() {
|
||||
if (context == null) {
|
||||
CallerLogger.e(TAG, "addStartAutoPilotView context==null")
|
||||
return
|
||||
}
|
||||
kotlin.runCatching {
|
||||
startAutoPilotContainer?.also { container ->
|
||||
container.removeAllViews()
|
||||
val view = CallerOchCustomViewManager.getAutopilotView(context)
|
||||
Logger.d(TAG, "$view ${Thread.currentThread().name}")
|
||||
view?.also {
|
||||
container.addView(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.call.och.CallerOchCustomViewManager
|
||||
import com.mogo.eagle.core.function.call.setting.CallerRequestActivityHandleManager
|
||||
import com.mogo.eagle.core.function.call.startup.CallerStartUpManager.initStageTwo
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
@@ -80,6 +81,7 @@ open class MainActivity : MvpActivity<MainView?, MainPresenter?>(), MainView,
|
||||
window.setBackgroundDrawable(null)
|
||||
initConnectInfoRV()
|
||||
CallerHmiManager.init(this)
|
||||
CallerOchCustomViewManager.init(this)
|
||||
|
||||
// 检查是否有悬浮窗权限
|
||||
if (Settings.canDrawOverlays(this)) {
|
||||
|
||||
@@ -18,9 +18,18 @@
|
||||
<com.mogo.eagle.core.function.hmi.bone.status.StartAutoPilotStatusView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dp_59"
|
||||
android:layout_marginStart="@dimen/dp_39"
|
||||
android:layout_marginBottom="@dimen/dp_59"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"/>
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/startAutoPilotContainer"
|
||||
android:layout_width="@dimen/dp_226"
|
||||
android:layout_height="@dimen/dp_226"
|
||||
android:layout_marginTop="@dimen/dp_44"
|
||||
android:layout_marginRight="@dimen/dp_68"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -117,4 +117,7 @@ public class MogoServicePaths {
|
||||
@Keep
|
||||
public static final String PATH_UPGRADE_TYPE_API = "/upgrade/type/api";
|
||||
|
||||
@Keep
|
||||
public static final String PATH_OCH_CUSTOM_VIEW_API = "/och/view/api";
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mogo.eagle.core.function.api.och
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import com.alibaba.android.arouter.facade.template.IProvider
|
||||
|
||||
/**
|
||||
* @author aibingbing
|
||||
*
|
||||
* Och业务层自定义View Provider 接口定义
|
||||
*/
|
||||
interface IOchCustomViewProvider : IProvider {
|
||||
|
||||
/**
|
||||
* Interface Tag
|
||||
*/
|
||||
val TAG: String
|
||||
get() = "IOchCustomViewProvider"
|
||||
|
||||
/**
|
||||
* 创建 Och业务层 自定义View
|
||||
*/
|
||||
fun createOchBusinessView(context: Context?): View?
|
||||
|
||||
/**
|
||||
* 创建 自动自动驾驶 自定义 View
|
||||
*/
|
||||
fun createStartAutopilotView(context: Context?): View?
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.mogo.eagle.core.function.call.och
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.function.api.och.IOchCustomViewProvider
|
||||
|
||||
/**
|
||||
* @author aibingbing
|
||||
*
|
||||
* Och自定义View调用者管理类,用来获取 Och提供的自定义 View, 然后放入到底层框架
|
||||
*/
|
||||
object CallerOchCustomViewManager {
|
||||
const val TAG = "CallerOchCustomViewManager"
|
||||
|
||||
private val ochCustomViewProviderApi
|
||||
get() = ARouter.getInstance().build(MogoServicePaths.PATH_OCH_CUSTOM_VIEW_API)
|
||||
.navigation() as? IOchCustomViewProvider
|
||||
|
||||
fun init(context: Context) {
|
||||
ochCustomViewProviderApi?.init(context)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 Och业务层 自定义View
|
||||
*/
|
||||
fun getOchBusinessView(context: Context?): View? {
|
||||
return ochCustomViewProviderApi?.createOchBusinessView(context)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 自动自动驾驶 自定义 View
|
||||
*/
|
||||
fun getAutopilotView(context: Context?): View? {
|
||||
return ochCustomViewProviderApi?.createStartAutopilotView(context)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user