|
|
|
@ -2,7 +2,10 @@ package com.example.SearchCenter;
|
|
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.os.Message;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.AdapterView;
|
|
|
|
|
import android.widget.ArrayAdapter;
|
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
import android.widget.ListView;
|
|
|
|
@ -12,6 +15,8 @@ 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;
|
|
|
|
@ -23,6 +28,7 @@ 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;
|
|
|
|
@ -30,6 +36,8 @@ import java.util.Random;
|
|
|
|
|
public class SearchEntryActivity extends AppCompatActivity implements CardStackView.ItemExpendListener,ConditionCode{
|
|
|
|
|
|
|
|
|
|
public static ArrayList<String> content=new ArrayList<String>();//存储数据内容
|
|
|
|
|
public static String model_Text;
|
|
|
|
|
public static int[] index=new int[3];//在随机生成选定联想搜索产生的索引值
|
|
|
|
|
Integer[] color = {
|
|
|
|
|
R.color.holo_blue_bright,
|
|
|
|
|
R.color.holo_orange_light,
|
|
|
|
@ -174,17 +182,17 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
* 药——操作方法 联想搜索:nhm能治什么病 ,nhm的证候,nhm的功能
|
|
|
|
|
* 药——作用 联想搜索:nhm能治什么病,nhm的证候,nhm的功能
|
|
|
|
|
*/
|
|
|
|
|
TextView asscoiate_text=findViewById(R.id.asscoiate_text);
|
|
|
|
|
TextView[] textViews =new TextView[3];
|
|
|
|
|
String[] texts=new String[3];
|
|
|
|
|
TextView asscoiate_text=findViewById(R.id.asscoiate_text);//显示文本“你可能感兴趣”
|
|
|
|
|
String[] texts=new String[3];//存放listView中的显示的数据
|
|
|
|
|
|
|
|
|
|
if(response.getCode()==DiseaseToSymptom){
|
|
|
|
|
/**
|
|
|
|
|
* 病——症状 nm能吃什么药
|
|
|
|
|
*/
|
|
|
|
|
TextView textView_1=findViewById(R.id.asscoiate_entry);
|
|
|
|
|
textView_1.setText(response.getMsg()+"应该吃什么药");
|
|
|
|
|
texts[0]=(String)textView_1.getText();
|
|
|
|
|
TextView textView=findViewById(R.id.asscoiate_entry);
|
|
|
|
|
textView.setText(response.getMsg()+"应该吃什么药");
|
|
|
|
|
texts[0]=(String)textView.getText();
|
|
|
|
|
model_Text=Model_Symptom;
|
|
|
|
|
}else if(response.getCode()==DiseaseToMedicines){
|
|
|
|
|
/**
|
|
|
|
|
* 病——药 nhm能指什么病,nhm能治什么病,nhm能治什么病
|
|
|
|
@ -193,10 +201,11 @@ 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(9) + 1;
|
|
|
|
|
textView.setText(content.get(index) + "能治什么病症");
|
|
|
|
|
index[i] = r.nextInt(9) + 1;
|
|
|
|
|
textView.setText(content.get(index[i]) + "能治什么病症");
|
|
|
|
|
texts[i]=(String)textView.getText();
|
|
|
|
|
}
|
|
|
|
|
model_Text=Model_Medicines;
|
|
|
|
|
}else if(response.getCode()==MedicineToOperation){
|
|
|
|
|
/**
|
|
|
|
|
* 药——操作方法
|
|
|
|
@ -205,24 +214,7 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
TextView textView_1=findViewById(R.id.asscoiate_entry);
|
|
|
|
|
textView_1.setText(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();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
model_Text=Model_Function;
|
|
|
|
|
}else {
|
|
|
|
|
/**
|
|
|
|
|
*药——作用,能治什么病
|
|
|
|
@ -231,33 +223,37 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
TextView textView=findViewById(R.id.asscoiate_entry);
|
|
|
|
|
textView.setText(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();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
model_Text=Model_Operation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
|
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
ReturnData rd=null;
|
|
|
|
|
if(response.getCode()==DiseaseToMedicines) {
|
|
|
|
|
rd = cmkgWebServiceGet.executeHttpGet(publicStringUtil.questionArgsname + content.get(index[position]) + model_Text, publicStringUtil.questionSearchURL);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
rd= cmkgWebServiceGet.executeHttpGet(publicStringUtil.questionArgsname+response.getMsg()+model_Text, publicStringUtil.questionSearchURL);
|
|
|
|
|
}
|
|
|
|
|
Message m = new Message();
|
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
|
bundle.putSerializable("msg", rd);
|
|
|
|
|
Intent intent = new Intent();
|
|
|
|
|
intent.setClass(SearchEntryActivity.this, SearchEntryActivity.class);
|
|
|
|
|
intent.putExtras(bundle);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
}
|
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
listView.setAdapter(view_adapter);
|
|
|
|
|
adapter.updateData(Arrays.asList(new_color),lists);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|