[2.15.0]fix bug of roma which click has no react and multi obj problem
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.TypedArray
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.eagle.core.data.multidisplay.TelematicConstant
|
||||
import com.mogo.eagle.core.function.api.map.roma.IMoGoRomaListener
|
||||
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener
|
||||
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.call.telematic.CallerTelematicListenerManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
|
||||
@@ -15,7 +16,7 @@ class RomaPassengerView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), IReceivedMsgListener {
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), IReceivedMsgListener, IMoGoRomaListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "RomaPassengerView"
|
||||
@@ -29,9 +30,10 @@ class RomaPassengerView @JvmOverloads constructor(
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_roma_passenger_bg, this, true)
|
||||
val a = context.obtainStyledAttributes(attrs, R.styleable.RomaPassengerView, defStyleAttr, 0)
|
||||
openRes = a.getResourceId(R.styleable.RomaPassengerView_roma_open,0)
|
||||
normalRes = a.getResourceId(R.styleable.RomaPassengerView_roma_close,0)
|
||||
val a =
|
||||
context.obtainStyledAttributes(attrs, R.styleable.RomaPassengerView, defStyleAttr, 0)
|
||||
openRes = a.getResourceId(R.styleable.RomaPassengerView_roma_open, 0)
|
||||
normalRes = a.getResourceId(R.styleable.RomaPassengerView_roma_close, 0)
|
||||
a.recycle()
|
||||
setOnClickListener {
|
||||
romaMode = !romaMode
|
||||
@@ -42,6 +44,7 @@ class RomaPassengerView @JvmOverloads constructor(
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
CallerTelematicListenerManager.addListener(TAG, this)
|
||||
CallerMapRomaListener.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {
|
||||
@@ -49,25 +52,34 @@ class RomaPassengerView @JvmOverloads constructor(
|
||||
TelematicConstant.OPEN_ROMA_STATUS -> {
|
||||
when (String(byteArray)) {
|
||||
"0" -> {
|
||||
romaMode = true
|
||||
if(openRes != 0){
|
||||
setBackgroundResource(openRes)
|
||||
}
|
||||
romaStatus(true)
|
||||
}
|
||||
"1" -> {
|
||||
romaMode = false
|
||||
if(normalRes != 0){
|
||||
setBackgroundResource(normalRes)
|
||||
}
|
||||
romaStatus(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun romaStatus(status: Boolean) {
|
||||
if (status) {
|
||||
romaMode = true
|
||||
if (openRes != 0) {
|
||||
setBackgroundResource(openRes)
|
||||
}
|
||||
} else {
|
||||
romaMode = false
|
||||
if (normalRes != 0) {
|
||||
setBackgroundResource(normalRes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
CallerTelematicListenerManager.removeListener(TAG)
|
||||
CallerMapRomaListener.removeListener(TAG)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user