diff --git a/app/src/main/java/com/linwankaifa/linwancunyi/ui/back/doctor_list.java b/app/src/main/java/com/linwankaifa/linwancunyi/ui/back/doctor_list.java index 66d3fe3b0746443c628b4880480d0486694cacfd..47179d7c6f6fa30d2f4d8daf2491300211a2f79d 100644 --- a/app/src/main/java/com/linwankaifa/linwancunyi/ui/back/doctor_list.java +++ b/app/src/main/java/com/linwankaifa/linwancunyi/ui/back/doctor_list.java @@ -4,6 +4,7 @@ import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; +import android.view.KeyEvent; import android.view.View; import android.widget.AdapterView; import android.widget.EditText; @@ -37,6 +38,7 @@ public class doctor_list extends AppCompatActivity { private ListView doctorListView; private doctorAdapter adapter; private List inflictlist; + private EditText search_content; @Override protected void onCreate(Bundle savedInstanceState) { @@ -44,6 +46,8 @@ public class doctor_list extends AppCompatActivity { setContentView(R.layout.activity_doctor_list); initList(); + search_content = (EditText) findViewById(R.id.doctorlistsearch); + search_content.setOnKeyListener(onKey); } public void back(View view) { @@ -101,34 +105,48 @@ public class doctor_list extends AppCompatActivity { }); } - public void search(View view) { - inflictlist = new ArrayList<>(); - DoctorBean doctorBeantest = new DoctorBean(); - Field[] fields = doctorBeantest.getClass().getDeclaredFields(); - - for (DoctorBean doctorBean : doctors) { - for (Field field : fields) { - try { - String name = field.getName(); - name = field.getName().substring(0, 1).toUpperCase() + name.substring(1); - Method m = doctorBean.getClass().getMethod("get" + name); - String value = String.valueOf(m.invoke(doctorBean)); - Log.e("name", String.valueOf(field.getName())); - - Log.e("value", String.valueOf(value)); - if (value != null && value.contains(((EditText) findViewById(R.id.doctorlistsearch)).getText().toString())) { - inflictlist.add(doctorBean); - break; + View.OnKeyListener onKey = new View.OnKeyListener() { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + // TODO Auto-generated method stub + if (event.getAction() == KeyEvent.ACTION_DOWN) { + if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER + || keyCode == KeyEvent.KEYCODE_ENTER) { + + inflictlist = new ArrayList<>(); + DoctorBean doctorBeantest = new DoctorBean(); + Field[] fields = doctorBeantest.getClass().getDeclaredFields(); + + for (DoctorBean doctorBean : doctors) { + for (Field field : fields) { + try { + String name = field.getName(); + name = field.getName().substring(0, 1).toUpperCase() + name.substring(1); + Method m = doctorBean.getClass().getMethod("get" + name); + String value = String.valueOf(m.invoke(doctorBean)); + Log.e("name", String.valueOf(field.getName())); + + Log.e("value", String.valueOf(value)); + if (value != null && value.contains(((EditText) findViewById(R.id.doctorlistsearch)).getText().toString())) { + inflictlist.add(doctorBean); + break; + } + } catch (Exception e) { + continue; + } + + } + } - } catch (Exception e) { - continue; - } + adapter = new doctorAdapter(doctor_list.this, R.layout.item_doctor, inflictlist); + doctorListView = (ListView) findViewById(R.id.back_doctor_list_view); + doctorListView.setAdapter(adapter); + return true; + } } + return false; } - adapter = new doctorAdapter(doctor_list.this, R.layout.item_doctor, inflictlist); - doctorListView = (ListView) findViewById(R.id.back_doctor_list_view); - doctorListView.setAdapter(adapter); - } -} + }; +} \ No newline at end of file diff --git a/app/src/main/java/com/linwankaifa/linwancunyi/ui/back/patient_list.java b/app/src/main/java/com/linwankaifa/linwancunyi/ui/back/patient_list.java index fba3b6488e323cb1ed195b8f3eec536831df76c0..7c4b337787a343522d47bf6dc17f87ebf321c91a 100644 --- a/app/src/main/java/com/linwankaifa/linwancunyi/ui/back/patient_list.java +++ b/app/src/main/java/com/linwankaifa/linwancunyi/ui/back/patient_list.java @@ -4,6 +4,7 @@ import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; +import android.view.KeyEvent; import android.view.View; import android.widget.AdapterView; import android.widget.EditText; @@ -33,11 +34,16 @@ public class patient_list extends AppCompatActivity { private ListView inflictlistView; private patientAdapter adapter; private List inflictlist; + private EditText search_content; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_patient_list); + + search_content = (EditText) findViewById(R.id.patientlistsearch); + search_content.setOnKeyListener(onKey); + OkHttpClient client = new OkHttpClient(); final PatientBean patient = new PatientBean(); Log.e("dynamic", JsonTransformation.objectToJson(patient)); @@ -145,4 +151,48 @@ public class patient_list extends AppCompatActivity { inflictlistView = (ListView) findViewById(R.id.ct_patient_list); inflictlistView.setAdapter(adapter); } + + View.OnKeyListener onKey = new View.OnKeyListener() { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + // TODO Auto-generated method stub + if (event.getAction() == KeyEvent.ACTION_DOWN) { + if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER + || keyCode == KeyEvent.KEYCODE_ENTER) { + + inflictlist = new ArrayList<>(); + PatientBean patientBeantest = new PatientBean(); + Field[] fields = patientBeantest.getClass().getDeclaredFields(); + + for (PatientBean patientBean : patientBeanList) { + for (Field field : fields) { + try { + String name = field.getName(); + name = field.getName().substring(0, 1).toUpperCase() + name.substring(1); + Method m = patientBean.getClass().getMethod("get" + name); + String value = String.valueOf(m.invoke(patientBean)); + Log.e("name", String.valueOf(field.getName())); + + Log.e("value", String.valueOf(value)); + if (value != null && value.contains(((EditText) findViewById(R.id.patientlistsearch)).getText().toString())) { + inflictlist.add(patientBean); + break; + } + } catch (Exception e) { + continue; + } + + } + + } + adapter = new patientAdapter(patient_list.this, R.layout.item_patient, inflictlist); + inflictlistView = (ListView) findViewById(R.id.ct_patient_list); + inflictlistView.setAdapter(adapter); + + return true; + } + } + return false; + } + }; } diff --git a/app/src/main/java/com/linwankaifa/linwancunyi/ui/doctor/DoctorChat.java b/app/src/main/java/com/linwankaifa/linwancunyi/ui/doctor/DoctorChat.java index d4068471cb18cc67c4412fa9695185c7f91849c5..6adb4450abfb60a0859f7a54c5c82258ebbc1410 100644 --- a/app/src/main/java/com/linwankaifa/linwancunyi/ui/doctor/DoctorChat.java +++ b/app/src/main/java/com/linwankaifa/linwancunyi/ui/doctor/DoctorChat.java @@ -8,6 +8,7 @@ import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.EditText; import android.widget.ListView; +import android.widget.TextView; import android.widget.Toast; import com.linwankaifa.linwancunyi.R; @@ -42,6 +43,8 @@ public class DoctorChat extends AppCompatActivity { int chatnumber; Timer timer; TimerTask timerTask; + TextView name; + TextView sex; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -52,6 +55,10 @@ public class DoctorChat extends AppCompatActivity { chatnumber = 0; + name = (TextView) findViewById(R.id.name); + sex = (TextView) findViewById(R.id.sex); + name.setText(Data_whole.getPatientBean().getPatientname()); + sex.setText(Data_whole.getPatientBean().getPatientsex()); init(); diff --git a/app/src/main/java/com/linwankaifa/linwancunyi/ui/doctor/DoctorReplyList.java b/app/src/main/java/com/linwankaifa/linwancunyi/ui/doctor/DoctorReplyList.java index cf046cbf0c3c82009038b5dcc67f001f16512ea0..aa75249db54c8900f6b32bd1776782d726c159ec 100644 --- a/app/src/main/java/com/linwankaifa/linwancunyi/ui/doctor/DoctorReplyList.java +++ b/app/src/main/java/com/linwankaifa/linwancunyi/ui/doctor/DoctorReplyList.java @@ -4,6 +4,7 @@ import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; +import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.ListView; @@ -35,6 +36,8 @@ import static android.widget.Toast.makeText; public class DoctorReplyList extends AppCompatActivity { private ListView patientListView; private ChatPatientAdapter adapter; + List patientList; + @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -79,7 +82,7 @@ public class DoctorReplyList extends AppCompatActivity { if (isSuccess.equals("404")) makeText(getApplicationContext(), "错误请求404", Toast.LENGTH_SHORT).show(); else { - final List patientList = JsonTransformation.jsonToList(isSuccess, PatientBean.class); + patientList = JsonTransformation.jsonToList(isSuccess, PatientBean.class); adapter = new ChatPatientAdapter(DoctorReplyList.this, R.layout.item_chat_patient, patientList); patientListView = (ListView) findViewById(R.id.chat_patient_list_view); patientListView.setAdapter(adapter); @@ -89,6 +92,7 @@ public class DoctorReplyList extends AppCompatActivity { public void onItemClick(AdapterView adapterView, View view, int i, long l) { PatientBean patient = patientList.get(i); Data_whole.setPatientBean(patient); + Log.e("replylist", Data_whole.getPatientBean().toString()); Intent intent = new Intent(DoctorReplyList.this, DoctorChat.class); startActivity(intent); } diff --git a/app/src/main/java/com/linwankaifa/linwancunyi/ui/patient/PatientFindDoctor.java b/app/src/main/java/com/linwankaifa/linwancunyi/ui/patient/PatientFindDoctor.java index 5ec0be278d32d23ef8843b053b02e08644982256..29bbc6fbffc9faef3fc8dafa0ca01b8080bb272a 100644 --- a/app/src/main/java/com/linwankaifa/linwancunyi/ui/patient/PatientFindDoctor.java +++ b/app/src/main/java/com/linwankaifa/linwancunyi/ui/patient/PatientFindDoctor.java @@ -3,6 +3,7 @@ package com.linwankaifa.linwancunyi.ui.patient; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; +import android.view.KeyEvent; import android.view.View; import android.widget.AdapterView; import android.widget.EditText; @@ -34,6 +35,7 @@ public class PatientFindDoctor extends AppCompatActivity { List inflitDoctros; private ListView doctorListView; private doctorAdapter adapter; + private EditText search_content; @Override protected void onCreate(Bundle savedInstanceState) { @@ -41,6 +43,8 @@ public class PatientFindDoctor extends AppCompatActivity { setContentView(R.layout.activity_patient_finddoctor); initList(); + search_content = (EditText) findViewById(R.id.searchdoctor); + search_content.setOnKeyListener(onKey); } public void choose_search_doctor(View view) { @@ -103,15 +107,29 @@ public class PatientFindDoctor extends AppCompatActivity { }); } - public void search(View view) { - inflitDoctros = new ArrayList<>(); - for (DoctorBean doctorBean : doctors) { - - if (doctorBean.getDoctorname() != null && doctorBean.getDoctorname().contains(((EditText) findViewById(R.id.searchdoctor)).getText().toString())) - inflitDoctros.add(doctorBean); + View.OnKeyListener onKey = new View.OnKeyListener() { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + // TODO Auto-generated method stub + if (event.getAction() == KeyEvent.ACTION_DOWN) { + if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER + || keyCode == KeyEvent.KEYCODE_ENTER) { + + inflitDoctros = new ArrayList<>(); + for (DoctorBean doctorBean : doctors) { + + if (doctorBean.getDoctorname() != null && doctorBean.getDoctorname().contains(((EditText) findViewById(R.id.searchdoctor)).getText().toString())) + inflitDoctros.add(doctorBean); + } + adapter = new doctorAdapter(PatientFindDoctor.this, R.layout.item_doctor, inflitDoctros); + doctorListView = (ListView) findViewById(R.id.find_doctor_list_view); + doctorListView.setAdapter(adapter); + + return true; + } + } + + return false; } - adapter = new doctorAdapter(PatientFindDoctor.this, R.layout.item_doctor, inflitDoctros); - doctorListView = (ListView) findViewById(R.id.find_doctor_list_view); - doctorListView.setAdapter(adapter); - } + }; } diff --git a/app/src/main/java/com/linwankaifa/linwancunyi/ui/patient/PatientFindHospital.java b/app/src/main/java/com/linwankaifa/linwancunyi/ui/patient/PatientFindHospital.java index 1468075009fece363e2d06311ccb0e46eea739af..38675a71016aee9d33b7b40dea2313eeb1ff4e0e 100644 --- a/app/src/main/java/com/linwankaifa/linwancunyi/ui/patient/PatientFindHospital.java +++ b/app/src/main/java/com/linwankaifa/linwancunyi/ui/patient/PatientFindHospital.java @@ -3,6 +3,7 @@ package com.linwankaifa.linwancunyi.ui.patient; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; +import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.widget.EditText; @@ -32,12 +33,16 @@ public class PatientFindHospital extends AppCompatActivity { EditText editText; private Map hospitalIdMap = new HashMap<>(); private List hospitalBeanList; + private EditText search_content; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_patient_findhospital); + search_content = (EditText) findViewById(R.id.hospitalinput); + search_content.setOnKeyListener(onKey); + OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url("http://49.234.4.35:8080/patient/gethospitalinfolist") @@ -138,42 +143,56 @@ public class PatientFindHospital extends AppCompatActivity { this.finish(); } - public void search(View view) { - editText = (EditText) findViewById(R.id.hospitalinput); - String searchstr = editText.getText().toString(); - // 界面适配器 - LayoutInflater inflater = getLayoutInflater(); - // 将要做容器的线性布局 - LinearLayout rly = (LinearLayout) findViewById(R.id.hospital_list); - rly.removeAllViews(); - TextView textView; - TextView textview1; - TextView textview2; - int i = 0; - for (HospitalBean hospitalBean : hospitalBeanList) { - if (hospitalBean.getHospitalname().contains(searchstr)) { - view = inflater.inflate(R.layout.list_hospital, null, false); - rly.addView(view); - - // 每次获取一个textview 修改之后,改变id - textView = (TextView) findViewById(R.id.ggb_hospital_name); - textView.setText(hospitalBean.getHospitalname()); - textView.setId(IdiUtils.generateViewId()); - - textview1 = (TextView) findViewById(R.id.ggb_hospital_city); - textview1.setText(hospitalBean.getArea()); - textview1.setId(IdiUtils.generateViewId()); - - textview2 = (TextView) findViewById(R.id.ggb_hospital_content); - textview2.setText(hospitalBean.getIntroduction()); - textview2.setId(IdiUtils.generateViewId()); - - int id = IdiUtils.generateViewId(); - view.setId(id); - hospitalIdMap.put(id, i); - i++; + View.OnKeyListener onKey = new View.OnKeyListener() { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + // TODO Auto-generated method stub + if (event.getAction() == KeyEvent.ACTION_DOWN) { + if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER + || keyCode == KeyEvent.KEYCODE_ENTER) { + + editText = (EditText) findViewById(R.id.hospitalinput); + String searchstr = editText.getText().toString(); + // 界面适配器 + LayoutInflater inflater = getLayoutInflater(); + // 将要做容器的线性布局 + LinearLayout rly = (LinearLayout) findViewById(R.id.hospital_list); + rly.removeAllViews(); + TextView textView; + TextView textview1; + TextView textview2; + int i = 0; + for (HospitalBean hospitalBean : hospitalBeanList) { + if (hospitalBean.getHospitalname().contains(searchstr)) { + v = inflater.inflate(R.layout.list_hospital, null, false); + rly.addView(v); + + // 每次获取一个textview 修改之后,改变id + textView = (TextView) findViewById(R.id.ggb_hospital_name); + textView.setText(hospitalBean.getHospitalname()); + textView.setId(IdiUtils.generateViewId()); + + textview1 = (TextView) findViewById(R.id.ggb_hospital_city); + textview1.setText(hospitalBean.getArea()); + textview1.setId(IdiUtils.generateViewId()); + + textview2 = (TextView) findViewById(R.id.ggb_hospital_content); + textview2.setText(hospitalBean.getIntroduction()); + textview2.setId(IdiUtils.generateViewId()); + + int id = IdiUtils.generateViewId(); + v.setId(id); + hospitalIdMap.put(id, i); + i++; + } + } + + return true; + } } + + return false; } - } + }; } diff --git a/app/src/main/res/layout/activity_doctor_chat.xml b/app/src/main/res/layout/activity_doctor_chat.xml index 17c4d8aa4253862412b4734273e94ca6b45629d7..26c127d347ee697bf8739d246aa103b86c7898ef 100644 --- a/app/src/main/res/layout/activity_doctor_chat.xml +++ b/app/src/main/res/layout/activity_doctor_chat.xml @@ -63,6 +63,7 @@ android:layout_height="wrap_content"> - - -