From 1c6b112a32c0986904abd714f8b651c3b44cbcac Mon Sep 17 00:00:00 2001 From: lizhanwei <Dana_Lee1016@126.com> Date: 星期五, 10 一月 2020 15:07:13 +0800 Subject: [PATCH] 1,暂时删除驾校信息页;2,删除输入密码页,直接打开设置 ;3,写了一个viewmodel用来监听连接状态,结果不能跨页面传递,observe到数据变化 --- app/src/main/java/safeluck/drive/evaluation/MainActivity.java | 39 +++++++++++++++++++++++++++++++++++++-- 1 files changed, 37 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/safeluck/drive/evaluation/MainActivity.java b/app/src/main/java/safeluck/drive/evaluation/MainActivity.java index 282cd33..6c43669 100644 --- a/app/src/main/java/safeluck/drive/evaluation/MainActivity.java +++ b/app/src/main/java/safeluck/drive/evaluation/MainActivity.java @@ -36,6 +36,8 @@ import safeluck.drive.evaluation.util.PermissionManager; import safeluck.drive.evaluation.viewmodels.MainViewModel; +import safeluck.drive.evaluation.viewmodels.RTKConnAndLogin; +import safeluck.drive.evaluation.viewmodels.RTKConnAndLoginViewModel; public class MainActivity extends SupportActivity { @@ -46,7 +48,8 @@ private RTKConfig mRTKConfig;//RTK閰嶇疆淇℃伅 private Gson gson = new Gson(); String[] PERMISSIONS = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.CAMERA}; - + RTKConnAndLoginViewModel rtkConnAndLoginViewModel; + RTKConnAndLogin rtkConnAndLogin; private ICEventListener icEventListener = new ICEventListener() { @Override @@ -70,6 +73,32 @@ }else{ MyLog.d(TAG,"RTKConfig鏈彇鍒版暟鎹�"); } + } + if (msgCode == Constant.RTK_PLATFORM_CONNECT_STATUS||msgCode== Constant.RTK_PLATFORM_REGISTER_RESULT){ + if (msgCode == Constant.RTK_PLATFORM_REGISTER_RESULT){ + try { + JSONObject jsonObject3 = new JSONObject((String) obj); + int loginCode = jsonObject3.getInt("login_code"); + MyLog.d(TAG,"RTK骞冲彴鐧诲綍缁撴灉锛�"+loginCode); + rtkConnAndLogin.setLogin_code(loginCode); + + } catch (JSONException e) { + e.printStackTrace(); + } + + }else{ + try { + JSONObject jsonObject3 = new JSONObject((String) obj); + int connect_status = jsonObject3.getInt("connected"); + MyLog.i(TAG,"RTK骞冲彴杩炴帴鐘舵�侊細"+connect_status); + rtkConnAndLogin.setLogin_code(connect_status); + + } catch (JSONException e) { + e.printStackTrace(); + } + + } + rtkConnAndLoginViewModel.getRtkConnAndLogin().postValue(rtkConnAndLogin); } } }; @@ -100,6 +129,9 @@ mRTKConfig = rtkConfig; } }); + + rtkConnAndLoginViewModel= ViewModelProviders.of(this).get(RTKConnAndLoginViewModel.class); + rtkConnAndLogin = new RTKConnAndLogin(); mPermissionsManager = new PermissionManager(this) { @@ -147,7 +179,8 @@ loadRootFragment(R.id.fl_container,HomeFragment.newInstance()); } - CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_RTKCONFIG_TOPIC); + CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_RTKCONFIG_TOPIC);//鍙戦�乺tk閰嶇疆娑堟伅 + CEventCenter.onBindEvent(true,icEventListener, Constant.BIND_CONNECT_RTK_TOPIC);//鏀跺埌rtk杩炴帴 鐧诲綍缁撴灉 } @@ -155,6 +188,8 @@ protected void onDestroy() { super.onDestroy(); CEventCenter.onBindEvent(false,icEventListener,Constant.BIND_RTKCONFIG_TOPIC); + + CEventCenter.onBindEvent(false,icEventListener, Constant.BIND_CONNECT_RTK_TOPIC); Log.i(TAG, "onDestroy: "); } -- Gitblit v1.8.0