From 0a43ee1a7a7eaf2c4c8da5a55ca3c810bcd292ba Mon Sep 17 00:00:00 2001 From: hanxueqing <1045352474@qq.com> Date: Mon, 6 Jan 2020 18:23:18 +0800 Subject: [PATCH 1/2] Merge branch 'master' of http://bdgit.educoder.net/p01643725/paz2s9bc5 # Conflicts: # cmkg/pom.xml # cmkg/src/main/java/com/cmkg/cmkg/CmkgApplication.java # cmkg/src/main/java/com/cmkg/cmkg/Controller/QuestionController.java # cmkg/src/main/java/com/cmkg/cmkg/database/ReturnData.java # cmkg/src/main/java/com/cmkg/cmkg/node/medicine.java # cmkg/src/main/java/com/cmkg/cmkg/process/ModelProcess.java # cmkg/src/main/java/com/cmkg/cmkg/repository/MedicineRespository.java # cmkg/src/main/java/com/cmkg/cmkg/repository/QuestionRespository.java # cmkg/src/main/java/com/cmkg/cmkg/server/QuestionService.java # cmkg/src/main/java/com/cmkg/cmkg/server/impl/QuestionServiceImpl.java # cmkg/src/main/resources/application.properties --- .../SearchCenter/SearchEntryActivity.java | 22 ++++++++++++++----- app/src/main/res/layout/cmkg_item.xml | 2 +- app/src/main/res/layout/cmkg_list_item.xml | 1 - 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/example/SearchCenter/SearchEntryActivity.java b/app/src/main/java/com/example/SearchCenter/SearchEntryActivity.java index 5f53066..27af9d1 100644 --- a/app/src/main/java/com/example/SearchCenter/SearchEntryActivity.java +++ b/app/src/main/java/com/example/SearchCenter/SearchEntryActivity.java @@ -80,7 +80,6 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV //获取response后,将这个json数据解析 ReturnData response = (ReturnData) bundle.getSerializable("msg"); - System.out.println("code=!!!!!!!!1"+response.getCode()); Log.i("response+++++",response+"返回值"); try { @@ -130,9 +129,11 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV */ List list = new LinkedList<>(); - String data=(String)response.getData(); - JSONObject jo=new JSONObject(data); - String medicine_symptom=jo.getString("symptom"); +// JSONObject jo=new JSONObject(response.getData().toString()); + String str=(String)response.getData(); + System.out.println("返回的数据事:"+str); + JSONObject jo=new JSONObject(str.toString()); + String medicine_symptom=jo.getString("fuction"); list.add(new ContentData(medicine_symptom)); lists.add(list); String disease_names=new String(jo.getString("name")); @@ -183,20 +184,25 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV * 药——作用 联想搜索:nhm能治什么病,nhm的证候,nhm的功能 */ TextView asscoiate_text=findViewById(R.id.asscoiate_text);//显示文本“你可能感兴趣” - String[] texts=new String[3];//存放listView中的显示的数据 +// String[] texts=new String[3];//存放listView中的显示的数据,只针对 +// String[] new_texts=new String[1]; +// String[] + String[] texts; if(response.getCode()==DiseaseToSymptom){ /** * 病——症状 nm能吃什么药 */ + texts=new String[1]; texts[0]=response.getMsg()+"应该吃什么药"; - model_Text=Model_Symptom; + model_Text=Model_Medicines; }else if(response.getCode()==DiseaseToMedicines){ /** * 病——药 nhm能指什么病,nhm能治什么病,nhm能治什么病 * 随机选三种药品 */ Random r=new Random(); + texts=new String[3]; for(int i=0;i<3;i++) { index[i] = r.nextInt(9) + 1; texts[i]=content.get(index[i])+"能治什么病症"; @@ -207,6 +213,7 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV * 药——操作方法 * nhm能治什么病 */ + texts=new String[1]; texts[0]=response.getMsg()+"能治什么病"; model_Text=Model_Function; }else { @@ -214,6 +221,7 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV *药——作用,能治什么病 * nhm 操作方法 */ + texts=new String[1]; texts[0]=response.getMsg()+"的用法"; model_Text=Model_Operation; } @@ -246,6 +254,8 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV } }); listView.setAdapter(view_adapter); + for(int i:new_color) + System.out.println("i="+i); adapter.updateData(Arrays.asList(new_color),lists); } } diff --git a/app/src/main/res/layout/cmkg_item.xml b/app/src/main/res/layout/cmkg_item.xml index 3972085..79efe0b 100644 --- a/app/src/main/res/layout/cmkg_item.xml +++ b/app/src/main/res/layout/cmkg_item.xml @@ -2,7 +2,7 @@ Date: Mon, 6 Jan 2020 20:19:36 +0800 Subject: [PATCH 2/2] Merge branch 'master' of http://bdgit.educoder.net/p01643725/paz2s9bc5 # Conflicts: # cmkg/pom.xml # cmkg/src/main/java/com/cmkg/cmkg/CmkgApplication.java # cmkg/src/main/java/com/cmkg/cmkg/Controller/QuestionController.java # cmkg/src/main/java/com/cmkg/cmkg/database/ReturnData.java # cmkg/src/main/java/com/cmkg/cmkg/node/medicine.java # cmkg/src/main/java/com/cmkg/cmkg/process/ModelProcess.java # cmkg/src/main/java/com/cmkg/cmkg/repository/MedicineRespository.java # cmkg/src/main/java/com/cmkg/cmkg/repository/QuestionRespository.java # cmkg/src/main/java/com/cmkg/cmkg/server/QuestionService.java # cmkg/src/main/java/com/cmkg/cmkg/server/impl/QuestionServiceImpl.java # cmkg/src/main/resources/application.properties --- .../SearchCenter/CMKGStackAdapter.java | 10 +- .../SearchCenter/SearchEntryActivity.java | 19 +-- .../java/com/example/Util/ConditionCode.java | 6 +- .../main/res/layout/activity_search_entry.xml | 141 ++++++++++++------ app/src/main/res/layout/cmkg_item.xml | 21 ++- app/src/main/res/layout/cmkg_list_item.xml | 2 +- app/src/main/res/values/styles.xml | 2 +- 7 files changed, 129 insertions(+), 72 deletions(-) diff --git a/app/src/main/java/com/example/SearchCenter/CMKGStackAdapter.java b/app/src/main/java/com/example/SearchCenter/CMKGStackAdapter.java index 0dc4a84..6ae0fa0 100644 --- a/app/src/main/java/com/example/SearchCenter/CMKGStackAdapter.java +++ b/app/src/main/java/com/example/SearchCenter/CMKGStackAdapter.java @@ -109,13 +109,19 @@ public class CMKGStackAdapter extends StackAdapter implements Condition * * 药-用法:标题是药的名字,内容是药的用法 * * 药-作用:标题是药的名字,内容是药的用法 */ - if(returnData.getCode()==DiseaseToSymptom||returnData.getCode()==MedicineToOperation||returnData.getCode()==MedicineToSymptom){ + if(returnData.getCode()==DiseaseToSymptom||returnData.getCode()==MedicineToOperation){ //对应病症,那么标题只有一个就是病的名字 titleText.setText(returnData.getMsg()); - }else { + }else if(returnData.getCode()==DiseaseToMedicines){ //对应治疗方法,那么标题就要有多个 titleText.setText(SearchEntryActivity.content.get(title_num)); title_num++; + }else{ + if(title_num==0) { + titleText.setText(returnData.getMsg()); + title_num++; + } + else titleText.setText("可以治疗的病症"); } cardTitle.getBackground().setColorFilter(ContextCompat.getColor(getContext(),backgroundColorId), PorterDuff.Mode.SRC_IN);//传入的int值,其实是一个颜色,在这里改变头部的颜色 diff --git a/app/src/main/java/com/example/SearchCenter/SearchEntryActivity.java b/app/src/main/java/com/example/SearchCenter/SearchEntryActivity.java index 27af9d1..0ddd7b6 100644 --- a/app/src/main/java/com/example/SearchCenter/SearchEntryActivity.java +++ b/app/src/main/java/com/example/SearchCenter/SearchEntryActivity.java @@ -109,6 +109,7 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV List list=new LinkedList<>(); list.add(new ContentData("我是您的用法哦~请您看看我嘞\n我无比的期待您的光临嘞\n我们没有连数据呢,马上就有嘞!")); content.add((String) jsonArray.get(i)); + System.out.println("content.size="+content.size()); lists.add(list); } new_color=new Integer[jsonArray.length()]; @@ -129,21 +130,21 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV */ List list = new LinkedList<>(); -// JSONObject jo=new JSONObject(response.getData().toString()); String str=(String)response.getData(); - System.out.println("返回的数据事:"+str); JSONObject jo=new JSONObject(str.toString()); - String medicine_symptom=jo.getString("fuction"); - list.add(new ContentData(medicine_symptom)); + String function=jo.getString("function"); + list.add(new ContentData(function)); lists.add(list); - String disease_names=new String(jo.getString("name")); + String disease_names=new String(jo.getString("disease")); JSONArray ja=new JSONArray(disease_names); + List list_1=new LinkedList<>(); for(int i=0;i list_1=new LinkedList<>(); - list_1.add(new ContentData(content.get(i))); - lists.add(list); +// list_1=new LinkedList<>(); + list_1.add(new ContentData(ja.get(i).toString())); + System.out.println("病症有这些!="+ja.get(i).toString()); } - new_color=new Integer[1]; + lists.add(list_1); + new_color=new Integer[2]; } for(int i=0;i - - - - - - - - - - \ No newline at end of file + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:scrollbars="vertical" + android:fadingEdge="vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/cmkg_item.xml b/app/src/main/res/layout/cmkg_item.xml index 79efe0b..293c55f 100644 --- a/app/src/main/res/layout/cmkg_item.xml +++ b/app/src/main/res/layout/cmkg_item.xml @@ -4,7 +4,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:padding="16dp" > + android:layout_height="468dp"> - + android:background="#ffffff"> diff --git a/app/src/main/res/layout/cmkg_list_item.xml b/app/src/main/res/layout/cmkg_list_item.xml index df70e0d..c8b332e 100644 --- a/app/src/main/res/layout/cmkg_list_item.xml +++ b/app/src/main/res/layout/cmkg_list_item.xml @@ -100,7 +100,7 @@ wrap_content wrap_content - 12sp + 20sp @color/text_black