From e01f5a72c7782419f01f01b3453d808a71888cb1 Mon Sep 17 00:00:00 2001
From: endian11 <Dana_Lee1016@126.com>
Date: 星期一, 25 十一月 2019 16:08:11 +0800
Subject: [PATCH] 使用androidx代替support lib;Room加上注解处理器;修改数据库getID;
---
app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java | 30 ++++++++++++++++++++++++++----
1 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java
index 95683d9..0a9a4f8 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java
@@ -1,16 +1,28 @@
package safeluck.drive.evaluation.fragment;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.design.widget.TextInputEditText;
-import android.support.v7.widget.AppCompatEditText;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
+import androidx.appcompat.widget.AppCompatEditText;
+import androidx.lifecycle.LifecycleOwner;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProviders;
+
+import com.google.android.material.textfield.TextInputEditText;
+
+import java.util.List;
+
import me.yokeyword.fragmentation.SupportFragment;
+import safeluck.drive.evaluation.DB.Student;
+import safeluck.drive.evaluation.DB.WokViewModel;
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.tcp.ConnectThread;
@@ -39,6 +51,16 @@
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.getStudents().observe((LifecycleOwner) this, new Observer<List<Student>>() {
+ @Override
+ public void onChanged(List<Student> students) {
+ for (Student student:students){
+ Log.i("Students", "onChanged: "+student.toString());
+ }
+ }
+ });
return view;
}
--
Gitblit v1.8.0