| | |
| | | import safeluck.drive.evaluation.DB.failitems.FailedProj; |
| | | import safeluck.drive.evaluation.DB.failitems.FailedProj_select; |
| | | import safeluck.drive.evaluation.R; |
| | | import safeluck.drive.evaluation.im.IMSClientBootstrap; |
| | | import safeluck.drive.evaluation.im.MessageProcessor; |
| | | import safeluck.drive.evaluation.tcp.ConnectThread; |
| | | |
| | | /** |
| | |
| | | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | | View view = inflater.inflate(R.layout.layout_tcpclient, container, false); |
| | | initView(view); |
| | | workViewModel =ViewModelProviders.of(this).get(CriteriaIViewModel.class); |
| | | // workViewModel =ViewModelProviders.of(this).get(CriteriaIViewModel.class); |
| | | |
| | | |
| | | return view; |
| | |
| | | public void onClick(View v) { |
| | | switch (v.getId()){ |
| | | case R.id.btn_connect: |
| | | |
| | | // String serverIp = ip.getText().toString().trim(); |
| | | // String serverPort = port.getText().toStrirng().trim(); |
| | | // connectThread = new ConnectThread(serverIp,Integer.parseInt(serverPort)); |
| | | // connectThread.start(); |
| | | Random random = new Random(); |
| | | r = random.nextInt(30)+1; |
| | | Log.i(TAG, "onClick: 随机数="+r); |
| | | WorkRoomDataBase.dataBaseWriteExecutor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | |
| | | WorkRoomDataBase.getWorkRoomDataBase(getContext().getApplicationContext()).getFailProjDao().insert(new FailedProj(flag?1:2, r,flag?1001:1000)); |
| | | flag = !flag; |
| | | } |
| | | }); |
| | | /**======================以下用于测试数据库==================*/ |
| | | // Random random = new Random(); |
| | | // r = random.nextInt(30)+1; |
| | | // Log.i(TAG, "onClick: 随机数="+r); |
| | | // WorkRoomDataBase.dataBaseWriteExecutor.execute(new Runnable() { |
| | | // @Override |
| | | // public void run() { |
| | | // |
| | | // WorkRoomDataBase.getWorkRoomDataBase(getContext().getApplicationContext()).getFailProjDao().insert(new FailedProj(flag?1:2, r,flag?1001:1000)); |
| | | // flag = !flag; |
| | | // } |
| | | // }); |
| | | /**======================测试数据库结束==================*/ |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | String userId = "100002"; |
| | | String token = "token_" + userId; |
| | | String hosts = "[{\"host\":\"192.168.10.234\", \"port\":8855}]"; |
| | | |
| | | IMSClientBootstrap.getInstance().init(userId,token,hosts,1); |
| | | break; |
| | | case R.id.btn_send: |
| | | // if (connectThread != null){ |
| | |
| | | //// sendEditText.getText().clear(); |
| | | //// } |
| | | |
| | | |
| | | |
| | | MessageProcessor.getInstance().sendMessage(sendEditText.getText().toString().trim()); |
| | | |
| | | break; |
| | | } |
| | | } |