[6.0.0] finish the roma passenger func
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.Message
|
||||
import android.text.Html
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
@@ -18,13 +21,33 @@ class RomaDistanceView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr) , IMoGoRomaListener {
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoRomaListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "RomaDistanceView"
|
||||
}
|
||||
|
||||
private var disChangeColor = false
|
||||
private var dis: Int = 0
|
||||
private val mHandler = object : Handler(Looper.getMainLooper()) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
super.handleMessage(msg)
|
||||
if (msg.what == 1) {
|
||||
if (dis != 0) {
|
||||
if (romaDistanceBg.visibility == View.GONE) {
|
||||
romaDistanceBg.visibility = View.VISIBLE
|
||||
}
|
||||
if (disChangeColor) {
|
||||
romaDistanceMeter.text =
|
||||
Html.fromHtml("<font color='#293449'>漫游距离</font><font color='#0752C3'>${dis}米</font>")
|
||||
} else {
|
||||
romaDistanceMeter.text = "漫游距离${dis}米"
|
||||
}
|
||||
}
|
||||
}
|
||||
sendEmptyMessageDelayed(1, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_roma_distance, this, true)
|
||||
@@ -34,14 +57,16 @@ class RomaDistanceView @JvmOverloads constructor(
|
||||
defStyleAttr,
|
||||
0
|
||||
)
|
||||
// val distanceBg = a.getResourceId(R.styleable.RomaDistanceView_roma_distance_bg,0)
|
||||
// if(distanceBg != 0){
|
||||
// romaDistanceBg.background = resources.getDrawable(distanceBg)
|
||||
// }
|
||||
val txtSize = a.getInteger(R.styleable.RomaDistanceView_roma_txt_size,35)
|
||||
romaDistanceMeter.setTextSize(TypedValue.COMPLEX_UNIT_PX,
|
||||
AutoSizeUtils.dp2px(getContext(),txtSize.toFloat()).toFloat())
|
||||
val txtDisColor = a.getBoolean(R.styleable.RomaDistanceView_roma_change_dis_color,false)
|
||||
val distanceBg = a.getResourceId(R.styleable.RomaDistanceView_roma_distance_bg, 0)
|
||||
if (distanceBg != 0) {
|
||||
romaDistanceBg.background = resources.getDrawable(distanceBg)
|
||||
}
|
||||
val txtSize = a.getInteger(R.styleable.RomaDistanceView_roma_txt_size, 35)
|
||||
romaDistanceMeter.setTextSize(
|
||||
TypedValue.COMPLEX_UNIT_PX,
|
||||
AutoSizeUtils.dp2px(getContext(), txtSize.toFloat()).toFloat()
|
||||
)
|
||||
val txtDisColor = a.getBoolean(R.styleable.RomaDistanceView_roma_change_dis_color, false)
|
||||
disChangeColor = txtDisColor
|
||||
a.recycle()
|
||||
}
|
||||
@@ -54,22 +79,19 @@ class RomaDistanceView @JvmOverloads constructor(
|
||||
override fun romaStatus(status: Boolean) {
|
||||
super.romaStatus(status)
|
||||
if (status) {
|
||||
romaDistanceBg.visibility = View.VISIBLE
|
||||
mHandler.sendEmptyMessageDelayed(1, 500)
|
||||
} else {
|
||||
mHandler.removeMessages(1)
|
||||
romaDistanceBg.visibility = View.GONE
|
||||
romaDistanceMeter.text = ""
|
||||
dis = 0
|
||||
}
|
||||
}
|
||||
|
||||
override fun romaDistance(distance: String) {
|
||||
super.romaDistance(distance)
|
||||
val dis = distance.toDouble().toInt()
|
||||
Log.i(TAG, "romaDistance:$distance")
|
||||
if(disChangeColor){
|
||||
romaDistanceMeter.text = Html.fromHtml("漫游距离<font color='#0752C3'>${dis}米</font>")
|
||||
}else{
|
||||
romaDistanceMeter.text = "漫游距离${dis}米"
|
||||
}
|
||||
dis = distance.toDouble().toInt()
|
||||
Log.i(TAG, "romaDistance:$dis")
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
android:id="@+id/romaDistanceMeter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:gravity="center"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
|
||||
Reference in New Issue
Block a user