更新imei phone sn 方法,更新RTKConfigDao方法; 加入kotlin支持 project .gradle app.build.gradle
| | |
| | | apply plugin: 'com.android.application' |
| | | apply plugin: 'kotlin-android-extensions' |
| | | apply plugin: 'kotlin-android' |
| | | |
| | | android { |
| | | compileSdkVersion 28 |
| | |
| | | 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() |
| | | } |
| | |
| | | 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"; |
| | | } |
| | |
| | | |
| | | @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); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | 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() |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | private String lastStr; |
| | | private String lastSn; |
| | | @Override |
| | | public void callBackMsg(final int cmd, String json) { |
| | | String strConent = String.format("收到命令[%d],Json内容为%s", cmd, json); |
| | |
| | | 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: |
| | |
| | | @Override |
| | | public void onDetach() { |
| | | super.onDetach(); |
| | | CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_MCUINFO_TOPIC); |
| | | CEventCenter.onBindEvent(false,icEventListener,Constant.BIND_MCUINFO_TOPIC); |
| | | } |
| | | } |
| | |
| | | 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; |
| | | |
| | |
| | | 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()); |
| | | |
| | | 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); |
| | |
| | | @Override |
| | | public void onDetach() { |
| | | super.onDetach(); |
| | | CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_MCUINFO_TOPIC); |
| | | CEventCenter.onBindEvent(false,icEventListener,Constant.BIND_MCUINFO_TOPIC); |
| | | } |
| | | } |
| | |
| | | // 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() |
| | |
| | | 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 |