lizhanwei
2020-04-22 ba478cde2b1198b073a8a32bb66f860c64dc10dc
完成查看车载信号输入
7个文件已修改
137 ■■■■■ 已修改文件
app/src/main/java/safeluck/drive/evaluation/customview/MyCustomEditText.kt 60 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/tv_des_bg.xml 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/layout_check_signal.xml 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/layout_mycustom_et.xml 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/layout_signal_config.xml 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/values/attrs.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/customview/MyCustomEditText.kt
@@ -1,11 +1,9 @@
package safeluck.drive.evaluation.customview
import android.content.Context
import android.content.res.TypedArray
import android.os.Parcel
import android.os.Parcelable
import android.text.Editable
import android.util.AttributeSet
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.widget.EditText
@@ -29,10 +27,17 @@
class MyCustomEditText : LinearLayout{
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context,attrs,defStyleAttr,defStyleRes) {
        mcontext = context
        init()
    private val TAG= "MyCustomEditText"
    constructor(context: Context) : this(context, null)
    constructor(context: Context, attributeSet: AttributeSet?) : this(context, attributeSet, 0)
    constructor(context: Context, attributeSet: AttributeSet?, defStyleAttr: Int):super(context,attributeSet,defStyleAttr){
        init(context,attributeSet)
    }
    // true就是显示  false不显示
     var visiblity:Boolean = true
@@ -40,38 +45,57 @@
    var str:String=""
    var desstr:String=""
    var mcontext:Context?= null
    var txtDes:TextView? = null
    var txtDesUnit:TextView? = null
    var et_num:EditText? = null
    var view: View? = null
    override fun onFinishInflate() {
        super.onFinishInflate()
    fun init(context: Context, attributeSet: AttributeSet?){
        Log.i(TAG,"myCustomEditText z自定义---------")
        view = LayoutInflater.from(context).inflate(R.layout.layout_mycustom_et,this,true)
        txtDes = view?.findViewById(R.id.tv_des_et)
        txtDesUnit = view?.findViewById(R.id.tv_unit)
        et_num = view?.findViewById(R.id.et_num)
        var a = context.obtainStyledAttributes(attributeSet,R.styleable.mycustom_et)
        //获取是否要显示单位
        visiblity = a!!.getBoolean(R.styleable.mycustom_et_txt_unit,true)
        str = a!!.getString(R.styleable.mycustom_et_txt)
        desstr = a!!.getString(R.styleable.mycustom_et_txt_des)
        var desunit = a!!.getString(R.styleable.mycustom_et_txt_unit_des)
//        var width = a!!.getString(R.styleable.mycustom_et_view_width)
//        var height = a!!.getString(R.styleable.mycustom_et_view_height)
        Log.i(TAG,"txtDes=$desstr")
        Log.i(TAG,"str=$str")
        Log.i(TAG,"visiblity=$visiblity")
        when(visiblity){
            true->txtDesUnit?.visibility = View.VISIBLE
            true->{
                txtDesUnit?.visibility = View.VISIBLE
                txtDesUnit?.text = desunit
            }
            else-> txtDesUnit?.visibility = View.GONE
        }
        txtDes?.text = desstr
        et_num?.text = Editable.Factory.getInstance().newEditable(str)
        a.recycle()
    }
    fun init(){
        view = LayoutInflater.from(mcontext).inflate(R.layout.layout_mycustom_et,null)
        var attributeSet = mcontext?.obtainStyledAttributes(R.styleable.mycustom_et)
        //获取是否要显示单位
        visiblity = attributeSet?.getBoolean(R.styleable.mycustom_et_txt_unit,true)!!
        str = attributeSet?.getString(R.styleable.mycustom_et_txt)
        desstr = attributeSet?.getString(R.styleable.mycustom_et_txt_des)
    fun updateStr(str:String){
        et_num?.text = Editable.Factory.getInstance().newEditable(str)
        invalidate()
    }
}
app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java
@@ -44,9 +44,6 @@
    private static final String TAG = "InspectSignalFragment";
    private static final int  VALIAD_NUM = 1;//1高电平有效
    private TextView textView_turnLight,tv_speed,tv_engine;
    private Toolbar toolbar;
    private Gson gson= new Gson();
    private Handler handler = new Handler();
    private LayoutCheckSignalBinding bingding;
@@ -70,8 +67,8 @@
                    handler.post(new Runnable() {
                                @Override
                                public void run() {
//                                    bingding.tvRoateSpeed.setText(String.valueOf(mcuInfo.getEngine()));
//                                    bingding.tvDangweiNum.setText(String.valueOf(mcuInfo.getSpeed()/10.0));
                                    bingding.roatespeed.updateStr(String.valueOf(mcuInfo.getEngine()));
                                    bingding.myspeed.updateStr(String.valueOf(mcuInfo.getSpeed()/10.0));
                                    for (int i = 0; i < gpios.size(); i++) {
                                        Log.i(TAG, "run: gpio["+i+"]="+gpios.get(i));
app/src/main/res/drawable/tv_des_bg.xml
@@ -1,6 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
<solid android:color="#ff2b3141"/>
    <corners android:radius="@dimen/ui_margin_5dp"/>
</shape>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
>
    <item>
        <shape android:shape="rectangle">
            <stroke android:color="#11468A" android:width="1dp"/>
            <corners android:bottomLeftRadius="@dimen/ui_margin_5dp" android:topLeftRadius="@dimen/ui_margin_5dp"/>
        </shape>
    </item>
    <item  android:top="1dp" android:left="1dp" android:bottom="1dp">
        <shape     android:shape="rectangle">
            <solid android:color="#ff2b3141"/>
            <corners android:topLeftRadius="@dimen/ui_margin_5dp" android:bottomLeftRadius="@dimen/ui_margin_5dp"/>
        </shape>
    </item>
</layer-list>
app/src/main/res/layout/layout_check_signal.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:lee="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
@@ -27,10 +28,26 @@
                android:padding="10dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
                <include layout="@layout/layout_mycustom_et" android:id="@+id/myspeed"
                    android:layout_width="200dp" android:layout_height="40dp"/>
                <include layout="@layout/layout_mycustom_et" android:id="@+id/myrotatespeed" android:layout_below="@+id/myspeed"
                     android:layout_marginTop="@dimen/ui_margin_20dp"  android:layout_width="237dp" android:layout_height="58dp"/>
                <safeluck.drive.evaluation.customview.MyCustomEditText
                    android:id="@+id/myspeed"
                    lee:txt="121"
                    lee:txt_des="车速"
                    lee:txt_unit="true"
                    lee:txt_unit_des ="km/h"
                    android:layout_height="58dp"
                    android:layout_width="237dp"/>
                <safeluck.drive.evaluation.customview.MyCustomEditText
                    android:layout_marginTop="@dimen/ui_margin_20dp"
                    android:layout_below="@+id/myspeed"
                    lee:txt="1212"
                    lee:txt_des="转速"
                    lee:txt_unit="true"
                    lee:txt_unit_des ="r/min"
                    android:id="@+id/roatespeed"
                    android:layout_height="58dp"
                    android:layout_width="237dp"/>
            </RelativeLayout>
        </FrameLayout>
app/src/main/res/layout/layout_mycustom_et.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal" android:layout_width="237dp"
    android:layout_height="58dp"
    android:gravity="center_vertical"
    android:background="@drawable/input_bg">
<TextView
    android:layout_width="wrap_content"
    android:layout_height="58dp"
    android:layout_height="match_parent"
    android:text="车速"
    android:gravity="center_vertical"
    android:paddingLeft="@dimen/ui_margin_5dp"
@@ -18,7 +18,7 @@
    />
    <EditText
        android:layout_width="100dp"
        android:layout_height="58dp"
        android:layout_height="match_parent"
        android:text="123"
        android:background="@null"
        android:gravity="center"
@@ -28,7 +28,7 @@
        />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="58dp"
        android:layout_height="match_parent"
        android:text="km/h"
        android:gravity="center"
        android:textSize="20sp"
app/src/main/res/layout/layout_signal_config.xml
@@ -3,22 +3,23 @@
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@android:color/white"
    android:id="@+id/ll_container"
    >
    <include layout="@layout/toolbar"/>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="30dp"
    android:padding="5dp"
    android:layout_height="25dp"
    android:layout_marginLeft="@dimen/ui_margin_10dp"
    android:layout_marginRight="10dp"
    android:background="@drawable/stu_score_bg"
    android:orientation="horizontal"
    android:layout_column="8">
<TextView
    android:layout_width="0dp"
    android:layout_weight="1"
    android:layout_height="wrap_content"
    android:textColor="@android:color/black"
    android:textSize="15sp"
    android:textColor="#ff888995"
    android:text="信号名称"/>
    <TextView
        android:layout_width="0dp"
app/src/main/res/values/attrs.xml
@@ -18,5 +18,8 @@
        <attr name="txt" format="string"/>
        <attr name="txt_des" format="string"/>
        <attr name="txt_unit" format="boolean"/>
        <attr name="txt_unit_des" format="string"/>
<!--        <attr name="view_height" format="integer"/>-->
<!--        <attr name="view_width" format="integer"/>-->
    </declare-styleable>
</resources>