| | |
| | | |
| | | 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 { |
| | | |
| | |
| | | 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 |
| | |
| | | }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); |
| | | } |
| | | } |
| | | }; |
| | |
| | | mRTKConfig = rtkConfig; |
| | | } |
| | | }); |
| | | |
| | | rtkConnAndLoginViewModel= ViewModelProviders.of(this).get(RTKConnAndLoginViewModel.class); |
| | | rtkConnAndLogin = new RTKConnAndLogin(); |
| | | |
| | | |
| | | mPermissionsManager = new PermissionManager(this) { |
| | |
| | | loadRootFragment(R.id.fl_container,HomeFragment.newInstance()); |
| | | } |
| | | |
| | | CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_RTKCONFIG_TOPIC); |
| | | CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_RTKCONFIG_TOPIC);//发送rtk配置消息 |
| | | CEventCenter.onBindEvent(true,icEventListener, Constant.BIND_CONNECT_RTK_TOPIC);//收到rtk连接 登录结果 |
| | | |
| | | } |
| | | |
| | |
| | | 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: "); |
| | | } |
| | | |