|
|
|
@ -3,16 +3,15 @@ package com.example.SearchCenter;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.ArrayAdapter;
|
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
import android.widget.ListView;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
|
|
|
|
|
import com.example.Util.ConditionCode;
|
|
|
|
|
import com.example.Util.ReturnData;
|
|
|
|
|
import com.example.Util.cmkgWebServiceGet;
|
|
|
|
|
import com.example.Util.publicStringUtil;
|
|
|
|
|
import com.example.cmknowledgegraph.R;
|
|
|
|
|
import com.loopeer.cardstack.AllMoveDownAnimatorAdapter;
|
|
|
|
|
import com.loopeer.cardstack.CardStackView;
|
|
|
|
@ -24,7 +23,6 @@ import org.json.JSONException;
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Random;
|
|
|
|
@ -51,8 +49,6 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
private CMKGStackAdapter cmkgStackAdapter;
|
|
|
|
|
Integer[] new_color;
|
|
|
|
|
|
|
|
|
|
String[] name = {"数据结构","计算机网络","编译原理","C语言","算法设计","FPGA编程"};
|
|
|
|
|
String[] scores = {"77","87","65","98","74","80"};
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
@ -83,29 +79,11 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
String message = response.getMsg();
|
|
|
|
|
Log.i("msg:",""+message);
|
|
|
|
|
|
|
|
|
|
// if(code== ConditionCode.DiseaseToMedicines || code == ConditionCode.MedicineToSymptom){
|
|
|
|
|
//// //病的治疗方法和药的作用,返回数组
|
|
|
|
|
//// JSONArray jsonArray = jsonObject.getJSONArray("data");
|
|
|
|
|
//// Log.i("length==",""+jsonArray.length());
|
|
|
|
|
//// for(int i=0;i<jsonArray.length();i++) Log.i("dataJsonArray=====",""+jsonArray.get(i));
|
|
|
|
|
//// }if(code == ConditionCode.DiseaseToSymptom || code ==ConditionCode.MedicineToOperation){
|
|
|
|
|
//// //病的症状或者药的用法,返回字符串
|
|
|
|
|
//// String jsonString = jsonObject.getString("data");
|
|
|
|
|
//// Log.i("dataString=====",jsonString);
|
|
|
|
|
////
|
|
|
|
|
//// }
|
|
|
|
|
|
|
|
|
|
if(code == DiseaseToSymptom){
|
|
|
|
|
/**
|
|
|
|
|
* //返回的是病症
|
|
|
|
|
* 标题就是病的名字,内容就是症状。lists就是病名,list就是病症
|
|
|
|
|
*/
|
|
|
|
|
// for(int i=0;i<content.size();i++){
|
|
|
|
|
// System.out.println("content="+content.get(i));
|
|
|
|
|
// List<ContentData> list=new LinkedList<>();
|
|
|
|
|
// list.add(new ContentData(content.get(i)));
|
|
|
|
|
// lists.add(list);
|
|
|
|
|
// }
|
|
|
|
|
List<ContentData> list = new LinkedList<>();
|
|
|
|
|
list.add(new ContentData((String)response.getData()));
|
|
|
|
|
lists.add(list);
|
|
|
|
@ -129,11 +107,7 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
* //返回的是药的用法
|
|
|
|
|
* //标题就是药品的名字,内容是用法
|
|
|
|
|
*/
|
|
|
|
|
// for(int i=0;i<content.size();i++){
|
|
|
|
|
// List<ContentData> list=new LinkedList<>();
|
|
|
|
|
// list.add(new ContentData(content.get(i)));
|
|
|
|
|
// lists.add(list);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
List<ContentData> list = new LinkedList<>();
|
|
|
|
|
list.add(new ContentData((String)response.getData()));
|
|
|
|
|
lists.add(list);
|
|
|
|
@ -143,11 +117,7 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
* //返回的是药的主治症状和对应的
|
|
|
|
|
* 标题是药的名字和“可以治疗的疾病”,内容是症状,和十种药物
|
|
|
|
|
*/
|
|
|
|
|
// for(int i = 0; i< content.size(); i++){
|
|
|
|
|
// List<ContentData> list=new LinkedList<>();
|
|
|
|
|
// list.add(new ContentData(content.get(i)));
|
|
|
|
|
// lists.add(list);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
List<ContentData> list = new LinkedList<>();
|
|
|
|
|
JSONObject jo=(JSONObject)response.getData();
|
|
|
|
|
String medicine_symptom=jo.getString("symptom");
|
|
|
|
@ -193,8 +163,6 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
* 每种不同的情况对应不同的状态码,用接口实现状态码
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// adapter.updateData(Arrays.asList(color),lists);
|
|
|
|
|
mCardStack.setAnimatorAdapter(new AllMoveDownAnimatorAdapter(mCardStack));
|
|
|
|
|
mCardStack.setAnimatorAdapter(new UpDownAnimatorAdapter(mCardStack));
|
|
|
|
|
mCardStack.setAnimatorAdapter(new UpDownStackAnimatorAdapter(mCardStack));
|
|
|
|
@ -207,18 +175,16 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
* 药——作用 联想搜索:nhm能治什么病,nhm的证候,nhm的功能
|
|
|
|
|
*/
|
|
|
|
|
TextView asscoiate_text=findViewById(R.id.asscoiate_text);
|
|
|
|
|
TextView[] textViews =new TextView[3];
|
|
|
|
|
String[] texts=new String[3];
|
|
|
|
|
|
|
|
|
|
if(response.getCode()==DiseaseToSymptom){
|
|
|
|
|
/**
|
|
|
|
|
* 病——症状 nm能吃什么药
|
|
|
|
|
*/
|
|
|
|
|
TextView textView_1=findViewById(R.id.asscoiate_entry);
|
|
|
|
|
textView_1.setText(response.getMsg()+"应该吃什么药");
|
|
|
|
|
textView_1.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
cmkgWebServiceGet.executeHttpGet(publicStringUtil.questionSearchURL,publicStringUtil.questionSearchURL+response.getMsg()+"吃什么药");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
texts[0]=(String)textView_1.getText();
|
|
|
|
|
}else if(response.getCode()==DiseaseToMedicines){
|
|
|
|
|
/**
|
|
|
|
|
* 病——药 nhm能指什么病,nhm能治什么病,nhm能治什么病
|
|
|
|
@ -227,14 +193,9 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
Random r=new Random();
|
|
|
|
|
for(int i=0;i<3;i++) {
|
|
|
|
|
TextView textView = findViewById(R.id.asscoiate_entry);
|
|
|
|
|
int index = r.nextInt(10) + 1;
|
|
|
|
|
int index = r.nextInt(9) + 1;
|
|
|
|
|
textView.setText(content.get(index) + "能治什么病症");
|
|
|
|
|
textView.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
cmkgWebServiceGet.executeHttpGet(publicStringUtil.questionSearchURL,publicStringUtil.questionSearchURL+response.getMsg()+"作用");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
texts[i]=(String)textView.getText();
|
|
|
|
|
}
|
|
|
|
|
}else if(response.getCode()==MedicineToOperation){
|
|
|
|
|
/**
|
|
|
|
@ -243,12 +204,25 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
*/
|
|
|
|
|
TextView textView_1=findViewById(R.id.asscoiate_entry);
|
|
|
|
|
textView_1.setText(response.getMsg()+"能治什么病");
|
|
|
|
|
textView_1.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
cmkgWebServiceGet.executeHttpGet(publicStringUtil.questionSearchURL,publicStringUtil.questionSearchURL+response.getMsg()+"作用");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
texts[0]=(String)textView_1.getText();
|
|
|
|
|
// textView_1.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onClick(View view) {
|
|
|
|
|
// new Thread(new Runnable() {
|
|
|
|
|
// @Override
|
|
|
|
|
// public void run() {
|
|
|
|
|
// ReturnData rd=cmkgWebServiceGet.executeHttpGet(publicStringUtil.questionArgsname+response.getMsg()+"作用",publicStringUtil.questionSearchURL);
|
|
|
|
|
// Intent intent=new Intent();
|
|
|
|
|
// Message m = new Message();
|
|
|
|
|
// Bundle bundle = new Bundle();
|
|
|
|
|
// bundle.putSerializable("msg", rd);
|
|
|
|
|
// intent.putExtras(bundle);
|
|
|
|
|
// intent.setClass(SearchEntryActivity.this,SearchEntryActivity.class);
|
|
|
|
|
// startActivity(intent);
|
|
|
|
|
// }
|
|
|
|
|
// }).start();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
}else {
|
|
|
|
|
/**
|
|
|
|
|
*药——作用,能治什么病
|
|
|
|
@ -256,15 +230,33 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
*/
|
|
|
|
|
TextView textView=findViewById(R.id.asscoiate_entry);
|
|
|
|
|
textView.setText(response.getMsg()+"的用法");
|
|
|
|
|
textView.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
cmkgWebServiceGet.executeHttpGet(publicStringUtil.questionSearchURL,publicStringUtil.questionSearchURL+response.getMsg()+"用法");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
texts[0]=(String)textView.getText();
|
|
|
|
|
// textView.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onClick(View view) {
|
|
|
|
|
// new Thread(new Runnable() {
|
|
|
|
|
// @Override
|
|
|
|
|
// public void run() {
|
|
|
|
|
// ReturnData rd=cmkgWebServiceGet.executeHttpGet(publicStringUtil.questionArgsname+response.getMsg()+"用法",publicStringUtil.questionSearchURL);
|
|
|
|
|
// Intent intent=new Intent();
|
|
|
|
|
// Message m = new Message();
|
|
|
|
|
// Bundle bundle = new Bundle();
|
|
|
|
|
// bundle.putSerializable("msg", rd);
|
|
|
|
|
// intent.putExtras(bundle);
|
|
|
|
|
// intent.setClass(SearchEntryActivity.this,SearchEntryActivity.class);
|
|
|
|
|
// startActivity(intent);
|
|
|
|
|
// }
|
|
|
|
|
// }).start();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
adapter.updateData(Arrays.asList(new_color),lists);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArrayAdapter<String> view_adapter = new ArrayAdapter<String>(SearchEntryActivity.this,android.R.layout.simple_list_item_1, texts);
|
|
|
|
|
ListView listView=findViewById(R.id.listview_group);
|
|
|
|
|
listView.setAdapter(view_adapter);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|