更新imei phone sn 方法,更新RTKConfigDao方法; 加入kotlin支持 project .gradle  app.build.gradle
7个文件已修改
1个文件已添加
137 ■■■■ 已修改文件
app/build.gradle 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/DB/Constant.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKConfigDao.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKConfigUpdateWorker.kt 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/app.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/BaseDatasFragment.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
build.gradle 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/build.gradle
@@ -1,4 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
android {
    compileSdkVersion 28
@@ -59,4 +61,10 @@
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'com.facebook.stetho:stetho:1.5.0'
    implementation project(path: ':im_lib')
    implementation "androidx.core:core-ktx:+"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
    mavenCentral()
}
app/src/main/java/safeluck/drive/evaluation/DB/Constant.java
@@ -9,4 +9,8 @@
public class Constant {
    public static final String CRITERIAFOR_I_JSON = "criteria_I.json";
    public static final String CRITERIAFOR_II_JSON = "criteria_II.json";
    public static final String RTK_CONFIG_UPDATE_JSON = "RTK_CONFIG_UPDATE_JSON";
    public static final String RTK_CONFIG_PHONE = "RTK_CONFIG_PHONE";
    public static final String RTK_CONFIG_IMEI = "RTK_CONFIG_IMEI";
    public static final String RTK_CONFIG_SN = "sn";
}
app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKConfigDao.java
@@ -18,6 +18,8 @@
    @Update
    void update(RTKConfig rtkConfig);
    @Query("Update rtkconfig_table SET sn=:sn ,imei=:imei ,phone=:phone where _id =0")
    void update(String sn,String imei,String phone);
}
app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKConfigUpdateWorker.kt
New file
@@ -0,0 +1,38 @@
package safeluck.drive.evaluation.DB.rtktb
import android.content.Context
import android.text.TextUtils
import android.util.Log
import androidx.work.Worker
import androidx.work.WorkerParameters
import org.json.JSONObject
import safeluck.drive.evaluation.DB.Constant
import safeluck.drive.evaluation.DB.WorkRoomDataBase
class RTKConfigUpdateWorker(context:Context, workerParams: WorkerParameters) :Worker(context, workerParams){
    val TAG:String = "RTKConfigUpdateWorker"
    override fun doWork(): Result {
        var data = inputData.getString(Constant.RTK_CONFIG_UPDATE_JSON)
        Log.i(TAG,"更新RTK_config imei phone sn="+data)
        var imei:String=""
        var phone:String=""
        var sn:String=""
        if (!TextUtils.isEmpty(data)){
            var jsonObject: JSONObject? = null
            jsonObject = JSONObject(data)
            sn = jsonObject.getString(Constant.RTK_CONFIG_SN)
            Log.i(TAG,"sn="+sn)
            imei = sn
            phone = sn
        }
        var rtkConfigDao = WorkRoomDataBase.getWorkRoomDataBase(applicationContext).rtkConfigDao.also {
            it.update(sn, imei, phone)
        }
        return Result.success()
    }
}
app/src/main/java/safeluck/drive/evaluation/app.java
@@ -46,6 +46,7 @@
import safeluck.drive.evaluation.DB.failitems.FailedProj_select;
import safeluck.drive.evaluation.DB.gps.GpsInfoWorker;
import safeluck.drive.evaluation.DB.rtktb.RTKConfig;
import safeluck.drive.evaluation.DB.rtktb.RTKConfigUpdateWorker;
import safeluck.drive.evaluation.DB.rtktb.RTKWorkRepository;
import safeluck.drive.evaluation.bean.ExamPlatformData;
import safeluck.drive.evaluation.cEventCenter.CEvent;
@@ -140,6 +141,7 @@
    }
    private String lastStr;
    private String lastSn;
    @Override
    public void callBackMsg(final int cmd, String json) {
        String strConent = String.format("收到命令[%d],Json内容为%s", cmd, json);
@@ -264,6 +266,22 @@
                CEventCenter.dispatchEvent(Constant.BIND_DEBUG_TXT,cmd,0,json);
                break;
            case Constant.MCU_SN:
                String sn = null;
                try {
                    JSONObject rtkConfigUpdtea = new JSONObject(json);
                    sn = rtkConfigUpdtea.getString("sn");
                    sn = rtkConfigUpdtea.put(safeluck.drive.evaluation.DB.Constant.RTK_CONFIG_SN,sn).toString();
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                if (sn.equalsIgnoreCase(lastSn)){
                }else{
                    lastSn = sn;
                    Data data = new Data.Builder().putString(safeluck.drive.evaluation.DB.Constant.RTK_CONFIG_UPDATE_JSON,sn).build();
                    OneTimeWorkRequest rtkConfigUpdateWorker= new OneTimeWorkRequest.Builder(RTKConfigUpdateWorker.class).setInputData(data).build();
                    WorkManager.getInstance(getAppContext()).enqueue(rtkConfigUpdateWorker);
                }
                CEventCenter.dispatchEvent(Constant.BIND_MCUINFO_TOPIC,cmd,0,json);
                break;
            case Constant.IC_ID:
app/src/main/java/safeluck/drive/evaluation/fragment/BaseDatasFragment.java
@@ -204,6 +204,6 @@
    @Override
    public void onDetach() {
        super.onDetach();
        CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_MCUINFO_TOPIC);
        CEventCenter.onBindEvent(false,icEventListener,Constant.BIND_MCUINFO_TOPIC);
    }
}
app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java
@@ -16,6 +16,7 @@
import androidx.appcompat.widget.Toolbar;
import androidx.databinding.DataBindingUtil;
import com.anyun.exam.lib.MyLog;
import com.anyun.im_lib.util.ByteUtil;
import com.google.gson.Gson;
@@ -46,49 +47,55 @@
    private TextView textView_turnLight,tv_speed,tv_engine;
    private Toolbar toolbar;
    private Gson gson= new Gson();
    private Handler handler = new Handler();
    private LayoutCheckSignalBinding bingding;
    private List<Integer> gpios = new ArrayList<>();
    Drawable leftGreen ;
    Drawable leftGray ;
    private int  index =0 ;
    private ICEventListener icEventListener = new ICEventListener() {
        @Override
        public void onCEvent(String topic, int msgCode, int resultCode, Object obj) {
            if (msgCode==Constant.MCU_SN){
                final MCUInfo mcuInfo = gson.fromJson((String)obj, MCUInfo.class);
                if (mcuInfo != null){
                    bingding.getRoot().post(new Runnable() {
                        @Override
                        public void run() {
                        gpios.clear();
                            for (int i = 0; i < 16; i++) {
                                gpios.add(      ByteUtil.getBitStatus(mcuInfo.getGpio(),i));
                            }
                            MyLog.i("mcu info gpio"+mcuInfo.getGpio());
                            bingding.tvRoateSpeed.setText(String.valueOf(mcuInfo.getEngine()));
                            bingding.tvDangweiNum.setText(String.valueOf(mcuInfo.getSpeed()));
                    handler.post(new Runnable() {
                                @Override
                                public void run() {
                                    bingding.tvRoateSpeed.setText(String.valueOf(mcuInfo.getEngine()));
                                    bingding.tvDangweiNum.setText(String.valueOf(mcuInfo.getSpeed()));
                                    for (int i = 0; i < gpios.size(); i++) {
                                        Log.i(TAG, "run: gpio["+i+"]="+gpios.get(i));
                                    }
                                    bingding.inpsetSignalSlice.tvSeatBelt.setCompoundDrawablesWithIntrinsicBounds(gpios.get(0)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvTrunLeft.setCompoundDrawablesWithIntrinsicBounds(gpios.get(1)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvTurnRight.setCompoundDrawablesWithIntrinsicBounds(gpios.get(2)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvParkingBrake.setCompoundDrawablesWithIntrinsicBounds(gpios.get(3)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvFootBrake.setCompoundDrawablesWithIntrinsicBounds(gpios.get(4)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvLowLamp.setCompoundDrawablesWithIntrinsicBounds(gpios.get(5)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvHighBeam.setCompoundDrawablesWithIntrinsicBounds(gpios.get(6)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvSeatBelt.setCompoundDrawablesWithIntrinsicBounds(gpios.get(0)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvTrunLeft.setCompoundDrawablesWithIntrinsicBounds(gpios.get(1)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvTurnRight.setCompoundDrawablesWithIntrinsicBounds(gpios.get(2)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvParkingBrake.setCompoundDrawablesWithIntrinsicBounds(gpios.get(3)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvFootBrake.setCompoundDrawablesWithIntrinsicBounds(gpios.get(4)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvLowLamp.setCompoundDrawablesWithIntrinsicBounds(gpios.get(5)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvHighBeam.setCompoundDrawablesWithIntrinsicBounds(gpios.get(6)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvGateLock.setCompoundDrawablesWithIntrinsicBounds(gpios.get(7)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvNullEngine.setCompoundDrawablesWithIntrinsicBounds(gpios.get(8)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvGearOne.setCompoundDrawablesWithIntrinsicBounds(gpios.get(9)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvGearTwo.setCompoundDrawablesWithIntrinsicBounds(gpios.get(10)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvGearThree.setCompoundDrawablesWithIntrinsicBounds(gpios.get(11)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvGearFour.setCompoundDrawablesWithIntrinsicBounds(gpios.get(12)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvGearFive.setCompoundDrawablesWithIntrinsicBounds(gpios.get(13)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvWindingOne.setCompoundDrawablesWithIntrinsicBounds(gpios.get(14)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            bingding.inpsetSignalSlice.tvWindingTwo.setCompoundDrawablesWithIntrinsicBounds(gpios.get(15)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvGateLock.setCompoundDrawablesWithIntrinsicBounds(gpios.get(7)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvNullEngine.setCompoundDrawablesWithIntrinsicBounds(gpios.get(8)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvGearOne.setCompoundDrawablesWithIntrinsicBounds(gpios.get(9)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvGearTwo.setCompoundDrawablesWithIntrinsicBounds(gpios.get(10)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvGearThree.setCompoundDrawablesWithIntrinsicBounds(gpios.get(11)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvGearFour.setCompoundDrawablesWithIntrinsicBounds(gpios.get(12)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvGearFive.setCompoundDrawablesWithIntrinsicBounds(gpios.get(13)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvWindingOne.setCompoundDrawablesWithIntrinsicBounds(gpios.get(14)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvWindingTwo.setCompoundDrawablesWithIntrinsicBounds(gpios.get(15)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                }
                            });
                        }
                    });
                }
            }
        }
    };
@@ -132,6 +139,6 @@
    @Override
    public void onDetach() {
        super.onDetach();
        CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_MCUINFO_TOPIC);
        CEventCenter.onBindEvent(false,icEventListener,Constant.BIND_MCUINFO_TOPIC);
    }
}
build.gradle
@@ -1,6 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = '1.3.70'
    repositories {
        google()
        jcenter()
@@ -12,8 +13,9 @@
        lifecycleVersion = '2.1.0'
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }