| | |
| | | import androidx.lifecycle.ViewModelProviders; |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | import androidx.work.WorkManager; |
| | | |
| | | import com.anyun.exam.lib.AYSdk; |
| | | import com.anyun.exam.lib.MyLog; |
| | | import com.anyun.exam.lib.util.ByteUtil; |
| | | import com.google.gson.Gson; |
| | | import com.safeluck.aykj.utils.BytesUtils; |
| | | |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | |
| | | import safeluck.drive.evaluation.cEventCenter.ICEventListener; |
| | | import safeluck.drive.evaluation.util.CThreadPoolExecutor; |
| | | import safeluck.drive.evaluation.util.FileUtil; |
| | | import safeluck.drive.evaluation.util.SPUtils; |
| | | |
| | | /** |
| | | * 设置所有参数 |
| | |
| | | private int request_code = REQUEST_CODE_MAP; |
| | | private Button btn_config_signal; |
| | | private Button btn_mcu_upgrade,btn_map_select; |
| | | private EditText et_ip,et_port; |
| | | private EditText et_ip,et_port,et_simulte_ip,et_simulate_port; |
| | | private Gson gson = new Gson(); |
| | | private EditText et_ip_rtk,et_port_rtk,et_city_id,et_city_province,et_phone; |
| | | private RTKConfigViewModel rtkConfigViewModel; |
| | | private RTKConfig mRtkConfig; |
| | | private Toolbar toolbar; |
| | | private boolean needSendRtk = false; |
| | | |
| | | public static SetArgumentsFragment newInstance() { |
| | | return new SetArgumentsFragment(); |
| | |
| | | et_city_province.setText(String.valueOf(rtkConfig.getProvince())); |
| | | et_port_rtk.setText(String.valueOf(rtkConfig.getPort())); |
| | | et_phone.setText(rtkConfig.getPhone()); |
| | | ExamPlatformData.getInstance().setRTKPort(rtkConfig.getPort()); |
| | | ExamPlatformData.getInstance().setRTKIP(rtkConfig.getIp()); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | return view; |
| | | } |
| | | |
| | | private void sendRtkConfigInfo(RTKConfig mRTKConfig) { |
| | | if (mRTKConfig != null) { |
| | | String rtkjson = gson.toJson(mRTKConfig); |
| | | |
| | | //去除id字段 |
| | | JSONObject jsonObject = null; |
| | | try { |
| | | jsonObject = new JSONObject(rtkjson); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | jsonObject.remove("_id"); |
| | | rtkjson = null; |
| | | rtkjson = jsonObject.toString(); |
| | | MyLog.i( "need resend RTK配置信息:" + rtkjson+"标志位:"+needSendRtk); |
| | | AYSdk.getInstance().sendCmd(Constant.PUSH_RTK_PLATFORM_INFO, rtkjson); |
| | | } else { |
| | | MyLog.i("RTKConfig未取到数据"); |
| | | } |
| | | needSendRtk = false; |
| | | |
| | | } |
| | | private void initView(View view) { |
| | | // toolbar =view.findViewById(R.id.toolbar); |
| | |
| | | |
| | | |
| | | et_ip_rtk = view.findViewById(R.id.rtk_addr_ip); |
| | | et_simulte_ip = view.findViewById(R.id.simulate_ip); |
| | | et_city_id = view.findViewById(R.id.et_city_id); |
| | | et_city_province = view.findViewById(R.id.et_provice_id); |
| | | et_phone = view.findViewById(R.id.et_phone); |
| | | et_port_rtk = view.findViewById(R.id.rtk_addr_port); |
| | | et_simulate_port = view.findViewById(R.id.simulate_port); |
| | | |
| | | } |
| | | @Override |
| | |
| | | signalFragment= SignalConfigFragment.newInstance(); |
| | | } |
| | | start(signalFragment); |
| | | // ((BaseSettingFragment)getParentFragment()).startBrotherFragment(SignalConfigFragment.newInstance()); |
| | | break; |
| | | case R.id.btn_mcu_upgrade: |
| | | |
| | |
| | | case R.id.btn_save_platform: |
| | | Toast.makeText(_mActivity, "保存成功", Toast.LENGTH_SHORT).show(); |
| | | if(ExamPlatformData.getInstance().compareIPandPort(et_ip.getText().toString().trim(),Integer.parseInt(et_port.getText().toString().trim()))){ |
| | | SPUtils.put(getActivity(), SPUtils.DES_HEX_PWD,""); |
| | | ((MainActivity)getActivity()).examPlatformModel.getDataChange().postValue(1); |
| | | ExamPlatformData.getInstance().insertPlatformIp(et_ip.getText().toString().trim()); |
| | | ExamPlatformData.getInstance().insertPlatformPort(Integer.parseInt(et_port.getText().toString().trim())); |
| | | } |
| | | |
| | | if (mRtkConfig != null){ |
| | | mRtkConfig.setPort(Integer.parseInt(et_port_rtk.getText().toString().trim())); |
| | | String rtkip = et_ip_rtk.getText().toString().trim(); |
| | | int rtkport = Integer.parseInt(et_port_rtk.getText().toString().trim()); |
| | | |
| | | mRtkConfig.setPort(rtkport); |
| | | mRtkConfig.setCity(Integer.parseInt(et_city_id.getText().toString().trim())); |
| | | mRtkConfig.setProvince(Integer.parseInt(et_city_province.getText().toString().trim())); |
| | | mRtkConfig.setIp(et_ip_rtk.getText().toString().trim()); |
| | | mRtkConfig.setIp(rtkip); |
| | | mRtkConfig.setPhone(et_phone.getText().toString().trim()); |
| | | |
| | | if (ExamPlatformData.getInstance().compareRTKIPandPort(rtkip,rtkport)){ |
| | | mRtkConfig.setRegistered(0); |
| | | MyLog.i("rtk ip和地址有变化"); |
| | | needSendRtk = true; |
| | | sendRtkConfigInfo(mRtkConfig); |
| | | |
| | | } |
| | | rtkConfigViewModel.insertRTKConfig(mRtkConfig); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | _mActivity.onBackPressed(); |
| | | break; |
| | | case R.id.btn_car_select://车辆模型和地图公用一套代码 区别在于REQUEST_CODE |