| | |
| | | private Button btn_send; |
| | | private ConnectThread connectThread; |
| | | private AppCompatEditText sendEditText; |
| | | private WokViewModel workViewModel; |
| | | |
| | | public static TcpFragment newInstance() { |
| | | return new TcpFragment(); |
| | |
| | | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | | View view = inflater.inflate(R.layout.layout_tcpclient, container, false); |
| | | initView(view); |
| | | WokViewModel workViewModel =ViewModelProviders.of(this).get(WokViewModel.class); |
| | | workViewModel =ViewModelProviders.of(this).get(WokViewModel.class); |
| | | |
| | | workViewModel.getStudents().observe((LifecycleOwner) this, new Observer<List<Student>>() { |
| | | @Override |
| | |
| | | |
| | | break; |
| | | case R.id.btn_send: |
| | | if (connectThread != null){ |
| | | connectThread.sendMessage(sendEditText.getText().toString().trim()); |
| | | sendEditText.getText().clear(); |
| | | } |
| | | // if (connectThread != null){ |
| | | //// connectThread.sendMessage(sendEditText.getText().toString().trim()); |
| | | //// sendEditText.getText().clear(); |
| | | //// } |
| | | |
| | | workViewModel.insertStudent(new Student(1002,"王五","500107198910124566",1)); |
| | | break; |
| | | } |
| | | } |