Merge remote-tracking branch 'origin/master'

master
ongbo 5 years ago
commit dd207daf39

@ -109,13 +109,19 @@ public class CMKGStackAdapter extends StackAdapter<Integer> implements Condition
* * - * * -
* * - * * -
*/ */
if(returnData.getCode()==DiseaseToSymptom||returnData.getCode()==MedicineToOperation||returnData.getCode()==MedicineToSymptom){ if(returnData.getCode()==DiseaseToSymptom||returnData.getCode()==MedicineToOperation){
//对应病症,那么标题只有一个就是病的名字 //对应病症,那么标题只有一个就是病的名字
titleText.setText(returnData.getMsg()); titleText.setText(returnData.getMsg());
}else { }else if(returnData.getCode()==DiseaseToMedicines){
//对应治疗方法,那么标题就要有多个 //对应治疗方法,那么标题就要有多个
titleText.setText(SearchEntryActivity.content.get(title_num)); titleText.setText(SearchEntryActivity.content.get(title_num));
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值其实是一个颜色在这里改变头部的颜色 cardTitle.getBackground().setColorFilter(ContextCompat.getColor(getContext(),backgroundColorId), PorterDuff.Mode.SRC_IN);//传入的int值其实是一个颜色在这里改变头部的颜色

@ -80,7 +80,6 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
//获取response后将这个json数据解析 //获取response后将这个json数据解析
ReturnData response = (ReturnData) bundle.getSerializable("msg"); ReturnData response = (ReturnData) bundle.getSerializable("msg");
System.out.println("code=!!!!!!!!1"+response.getCode());
Log.i("response+++++",response+"返回值"); Log.i("response+++++",response+"返回值");
try { try {
@ -110,6 +109,7 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
List<ContentData> list=new LinkedList<>(); List<ContentData> list=new LinkedList<>();
list.add(new ContentData("我是您的用法哦~请您看看我嘞\n我无比的期待您的光临嘞\n我们没有连数据呢马上就有嘞")); list.add(new ContentData("我是您的用法哦~请您看看我嘞\n我无比的期待您的光临嘞\n我们没有连数据呢马上就有嘞"));
content.add((String) jsonArray.get(i)); content.add((String) jsonArray.get(i));
System.out.println("content.size="+content.size());
lists.add(list); lists.add(list);
} }
new_color=new Integer[jsonArray.length()]; new_color=new Integer[jsonArray.length()];
@ -130,19 +130,21 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
*/ */
List<ContentData> list = new LinkedList<>(); List<ContentData> list = new LinkedList<>();
String data=(String)response.getData(); String str=(String)response.getData();
JSONObject jo=new JSONObject(data); JSONObject jo=new JSONObject(str.toString());
String medicine_symptom=jo.getString("symptom"); String function=jo.getString("function");
list.add(new ContentData(medicine_symptom)); list.add(new ContentData(function));
lists.add(list); 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); JSONArray ja=new JSONArray(disease_names);
List<ContentData> list_1=new LinkedList<>();
for(int i=0;i<ja.length();i++){ for(int i=0;i<ja.length();i++){
List<ContentData> list_1=new LinkedList<>(); // list_1=new LinkedList<>();
list_1.add(new ContentData(content.get(i))); list_1.add(new ContentData(ja.get(i).toString()));
lists.add(list); 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<new_color.length;i++){ for(int i=0;i<new_color.length;i++){
@ -183,20 +185,25 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
* nhmnhmnhm * nhmnhmnhm
*/ */
TextView asscoiate_text=findViewById(R.id.asscoiate_text);//显示文本“你可能感兴趣” 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){ if(response.getCode()==DiseaseToSymptom){
/** /**
* nm * nm
*/ */
texts=new String[1];
texts[0]=response.getMsg()+"应该吃什么药"; texts[0]=response.getMsg()+"应该吃什么药";
model_Text=Model_Symptom; model_Text=Model_Medicines;
}else if(response.getCode()==DiseaseToMedicines){ }else if(response.getCode()==DiseaseToMedicines){
/** /**
* nhmnhmnhm * nhmnhmnhm
* *
*/ */
Random r=new Random(); Random r=new Random();
texts=new String[3];
for(int i=0;i<3;i++) { for(int i=0;i<3;i++) {
index[i] = r.nextInt(9) + 1; index[i] = r.nextInt(9) + 1;
texts[i]=content.get(index[i])+"能治什么病症"; texts[i]=content.get(index[i])+"能治什么病症";
@ -207,6 +214,7 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
* *
* nhm * nhm
*/ */
texts=new String[1];
texts[0]=response.getMsg()+"能治什么病"; texts[0]=response.getMsg()+"能治什么病";
model_Text=Model_Function; model_Text=Model_Function;
}else { }else {
@ -214,6 +222,7 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
* *
* nhm * nhm
*/ */
texts=new String[1];
texts[0]=response.getMsg()+"的用法"; texts[0]=response.getMsg()+"的用法";
model_Text=Model_Operation; model_Text=Model_Operation;
} }
@ -246,6 +255,8 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
} }
}); });
listView.setAdapter(view_adapter); listView.setAdapter(view_adapter);
for(int i:new_color)
System.out.println("i="+i);
adapter.updateData(Arrays.asList(new_color),lists); adapter.updateData(Arrays.asList(new_color),lists);
} }
} }

@ -6,12 +6,12 @@ public interface ConditionCode {
* DiseaseToSymptom * DiseaseToSymptom
* DiseaseToMedeicines * DiseaseToMedeicines
* MedicineToOperation * MedicineToOperation
* MedicineToSympton * MedicineToFunction
*/ */
public final int DiseaseToSymptom=100; public final int DiseaseToSymptom=100;
public final int DiseaseToMedicines=200; public final int DiseaseToMedicines=200;
public final int MedicineToOperation=300; public final int MedicineToOperation=300;
public final int MedicineToSymptom=400; public final int MedicineToFunction=400;
/*** /***
*Model_Symptom *Model_Symptom
* Model_Medicines * Model_Medicines
@ -19,7 +19,7 @@ public interface ConditionCode {
* Model_Function * Model_Function
*/ */
public final String Model_Symptom="的症状"; public final String Model_Symptom="的症状";
public final String Model_Medicines="治疗方法"; public final String Model_Medicines="吃什么药";
public final String Model_Operation="用法"; public final String Model_Operation="用法";
public final String Model_Function="作用"; public final String Model_Function="作用";

@ -1,46 +1,99 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="fill_parent"
android:orientation="vertical" android:scrollbars="vertical"
tools:context=".SearchEntryActivity"> android:fadingEdge="vertical">
<LinearLayout
android:orientation="vertical"
<com.loopeer.cardstack.CardStackView android:layout_width="fill_parent"
android:id="@+id/cardStackView" android:layout_height="fill_parent"
android:layout_width="match_parent" tools:context=".MainActivity">
android:layout_height="299dp"></com.loopeer.cardstack.CardStackView>
<com.loopeer.cardstack.CardStackView
<TextView android:id="@+id/cardStackView"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="500dp"></com.loopeer.cardstack.CardStackView>
android:textSize="24sp"
android:text="你可能感兴趣" <TextView
android:textStyle="bold" android:layout_width="wrap_content"
android:paddingLeft="100dp" android:layout_height="wrap_content"
android:paddingTop="150dp" android:textSize="24sp"
android:id="@+id/asscoiate_text" android:text="你可能感兴趣"
/> android:textStyle="bold"
<TextView android:paddingLeft="100dp"
android:layout_width="wrap_content" android:paddingTop="150dp"
android:layout_height="wrap_content" android:id="@+id/asscoiate_text"
android:paddingLeft="20dp" />
android:id="@+id/asscoiate_entry" <TextView
/> android:layout_width="wrap_content"
<ListView android:layout_height="wrap_content"
android:layout_width="match_parent" android:paddingLeft="20dp"
android:layout_height="wrap_content" android:id="@+id/asscoiate_entry"
android:paddingTop="40dp" />
android:paddingLeft="20dp" <ListView
android:divider="@null" android:layout_width="match_parent"
android:id="@+id/listview_group" android:layout_height="wrap_content"
android:textSize="16sp" android:paddingTop="40dp"
android:textColor="#ff000000" android:paddingLeft="20dp"
android:shadowDx="4" android:divider="@null"
android:shadowDy="4" android:id="@+id/listview_group"
android:shadowRadius="2" android:textSize="16sp"
/> android:textColor="#ff000000"
android:shadowDx="4"
</LinearLayout> android:shadowDy="4"
android:shadowRadius="2"
/>
</LinearLayout>
</ScrollView>
<!--<?xml version="1.0" encoding="utf-8"?>-->
<!--<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"-->
<!-- xmlns:app="http://schemas.android.com/apk/res-auto"-->
<!-- xmlns:tools="http://schemas.android.com/tools"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="vertical"-->
<!-- tools:context=".SearchEntryActivity">-->
<!-- <com.loopeer.cardstack.CardStackView-->
<!-- android:id="@+id/cardStackView"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"></com.loopeer.cardstack.CardStackView>-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:textSize="24sp"-->
<!-- android:text="你可能感兴趣"-->
<!-- android:textStyle="bold"-->
<!-- android:paddingLeft="100dp"-->
<!-- android:paddingTop="150dp"-->
<!-- android:id="@+id/asscoiate_text"-->
<!-- />-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:paddingLeft="20dp"-->
<!-- android:id="@+id/asscoiate_entry"-->
<!-- />-->
<!-- <ListView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:paddingTop="40dp"-->
<!-- android:paddingLeft="20dp"-->
<!-- android:divider="@null"-->
<!-- android:id="@+id/listview_group"-->
<!-- android:textSize="16sp"-->
<!-- android:textColor="#ff000000"-->
<!-- android:shadowDx="4"-->
<!-- android:shadowDy="4"-->
<!-- android:shadowRadius="2"-->
<!-- />-->
<!--</LinearLayout>-->

@ -2,9 +2,8 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="250dp" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:padding="16dp" android:padding="16dp"
> >
<!-- <!--
@ -18,32 +17,30 @@
android:background="#ffffff" android:background="#ffffff"
android:id="@+id/card_title" android:id="@+id/card_title"
> >
<TextView <TextView
android:layout_width="match_parent" android:id="@+id/card_title_text"
android:layout_width="340dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="16dp" android:layout_margin="16dp"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="#ffffff" android:textColor="#ffffff"
android:id="@+id/card_title_text" android:textSize="20sp"
/> android:textStyle="bold" />
</FrameLayout> </FrameLayout>
<!-- android:text="2016-2017-2学期"--> <!-- android:text="2016-2017-2学期"-->
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="468dp">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:id="@+id/scores_list" android:id="@+id/scores_list"
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
> android:background="#ffffff"></androidx.recyclerview.widget.RecyclerView>
</androidx.recyclerview.widget.RecyclerView>
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>

@ -100,8 +100,7 @@
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="80dp"
android:id="@+id/search_content" android:id="@+id/search_content"
style="@style/scores_item_style" style="@style/scores_item_style"
android:paddingLeft="10dp" android:paddingLeft="10dp"

@ -49,7 +49,7 @@
<style name="scores_item_style"> <style name="scores_item_style">
<item name="android:layout_width">wrap_content</item> <item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:textSize">12sp</item> <item name="android:textSize">20sp</item>
<item name="android:textColor">@color/text_black</item> <item name="android:textColor">@color/text_black</item>
</style> </style>

Loading…
Cancel
Save