[3.2.0]调整漫游按钮背景

This commit is contained in:
xuxinchao
2023-05-22 18:21:30 +08:00
parent b80b5092d9
commit 03470a195e
6 changed files with 145 additions and 8 deletions

View File

@@ -0,0 +1,98 @@
package com.mogo.eagle.core.function.hmi.ui.widget
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.appcompat.content.res.AppCompatResources
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.function.api.map.roma.IMoGoRomaListener
import com.mogo.eagle.core.function.call.map.CallerMapIdentifyManager.romaTrigger
import com.mogo.eagle.core.function.call.map.CallerMapRomaListener
import com.mogo.eagle.core.function.hmi.R
import kotlinx.android.synthetic.main.view_roma_bus_bg.view.ivRomaView
import kotlinx.android.synthetic.main.view_roma_bus_bg.view.ll_roma_bg
class RomaBusView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoRomaListener {
companion object{
private const val TAG = "RomaView"
}
@Volatile
private var romaMode = false
@Volatile
private var click = true
private val normalRes: Int
private val openRes: Int
init{
LayoutInflater.from(context).inflate(R.layout.view_roma_bus_bg, this, true)
val a = context.obtainStyledAttributes(
attrs,
R.styleable.RomaView,
defStyleAttr,
0
)
normalRes = a.getResourceId(
R.styleable.RomaView_roma_close_bg,
R.drawable.romabg_normal_select
)
openRes = a.getResourceId(
R.styleable.RomaView_roma_open_bg,
R.drawable.romabg_press_select_bg
)
a.recycle()
if(normalRes!=0){
ll_roma_bg.background = AppCompatResources.getDrawable(context, normalRes)
}
setOnClickListener {
if(!click){
return@setOnClickListener
}
click = false
romaMode = !romaMode
//司机屏不控制乘客屏漫游,独自漫游
romaTrigger(romaMode)
}
}
override fun romaStatus(status: Boolean) {
click = true
if (status) {
romaMode = true
if(openRes!=0){
ll_roma_bg.setBackgroundResource(openRes)
}else{
ll_roma_bg.setBackgroundResource(R.drawable.romabg_press_select_bg)
}
ivRomaView.setBackgroundResource(R.drawable.roma_press_select_bg)
} else {
romaMode = false
if(normalRes!=0){
ll_roma_bg.setBackgroundResource(normalRes)
}else{
ll_roma_bg.setBackgroundResource(R.drawable.roma_bg_selector)
}
ivRomaView.setBackgroundResource(R.drawable.romafront_select_bg)
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
CallerMapRomaListener.addListener(TAG, this)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
CallerMapRomaListener.removeListener(TAG)
}
}

View File

@@ -9,9 +9,10 @@ import com.mogo.eagle.core.function.api.map.roma.IMoGoRomaListener
import com.mogo.eagle.core.function.call.map.CallerMapIdentifyManager.romaTrigger
import com.mogo.eagle.core.function.call.map.CallerMapRomaListener
import com.mogo.eagle.core.function.hmi.R
import kotlinx.android.synthetic.main.view_roma_bg.view.*
import kotlinx.android.synthetic.main.view_roma_taxi_bg.view.ivRomaView
import kotlinx.android.synthetic.main.view_roma_taxi_bg.view.ll_roma_bg
class RomaView @JvmOverloads constructor(
class RomaTaxiView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
@@ -31,7 +32,7 @@ class RomaView @JvmOverloads constructor(
private val openRes: Int
init {
LayoutInflater.from(context).inflate(R.layout.view_roma_bg, this, true)
LayoutInflater.from(context).inflate(R.layout.view_roma_taxi_bg, this, true)
val a = context.obtainStyledAttributes(
attrs,
R.styleable.RomaView,

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cl_roma_bg"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/ll_roma_bg"
android:layout_width="@dimen/dp_102"
android:layout_height="@dimen/dp_102"
android:layout_margin="40dp"
android:background="@drawable/roma_bg_selector"
android:elevation="@dimen/dp_10"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
>
</LinearLayout>
<ImageView
android:id="@+id/ivRomaView"
android:layout_width="@dimen/dp_80"
android:layout_height="@dimen/dp_80"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:src="@drawable/romafront_select_bg"
android:elevation="@dimen/dp_10"
/>
</androidx.constraintlayout.widget.ConstraintLayout>