|
|
|
@ -3,10 +3,13 @@ package com.example.SearchCenter;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
|
|
|
|
|
import com.example.PersonalCenter.SearchServiceGet;
|
|
|
|
|
import com.example.Util.ConditionCode;
|
|
|
|
|
import com.example.Util.ReturnData;
|
|
|
|
|
import com.example.cmknowledgegraph.R;
|
|
|
|
@ -17,12 +20,12 @@ import com.loopeer.cardstack.UpDownStackAnimatorAdapter;
|
|
|
|
|
|
|
|
|
|
import org.json.JSONArray;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
public class SearchEntryActivity extends AppCompatActivity implements CardStackView.ItemExpendListener,ConditionCode{
|
|
|
|
|
|
|
|
|
@ -112,7 +115,6 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
*/
|
|
|
|
|
Log.i("hah",""+(String)response.getData());
|
|
|
|
|
JSONArray jsonArray = new JSONArray((String)response.getData());
|
|
|
|
|
|
|
|
|
|
List<ContentData> list=new LinkedList<>();
|
|
|
|
|
for(int i=0;i<jsonArray.length();i++){
|
|
|
|
|
list.add(new ContentData("我是您的用法哦~请您看看我嘞\n我无比的期待您的光临嘞\n我们没有连数据呢,马上就有嘞!"));
|
|
|
|
@ -155,9 +157,6 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
new_color[i]=color[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
@ -167,7 +166,6 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
new_color[i]=color[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CardStackView mCardStack = (CardStackView)findViewById(R.id.cardStackView);
|
|
|
|
|
CMKGStackAdapter adapter = new CMKGStackAdapter(this,response);
|
|
|
|
|
mCardStack.setAdapter(adapter);
|
|
|
|
@ -184,15 +182,87 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
|
|
|
|
|
*
|
|
|
|
|
* 每种不同的情况对应不同的状态码,用接口实现状态码
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adapter.updateData(Arrays.asList(new_color),lists);
|
|
|
|
|
|
|
|
|
|
// adapter.updateData(Arrays.asList(color),lists);
|
|
|
|
|
mCardStack.setAnimatorAdapter(new AllMoveDownAnimatorAdapter(mCardStack));
|
|
|
|
|
mCardStack.setAnimatorAdapter(new UpDownAnimatorAdapter(mCardStack));
|
|
|
|
|
mCardStack.setAnimatorAdapter(new UpDownStackAnimatorAdapter(mCardStack));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 从这里开始是联想搜索
|
|
|
|
|
* 病——症状 联想搜索:nm能吃什么药
|
|
|
|
|
* 病——药 俩像搜索:nhm能指什么病,nhm能治什么病,nhm能治什么病
|
|
|
|
|
* 药——操作方法 联想搜索:nhm能治什么病 ,nhm的证候,nhm的功能
|
|
|
|
|
* 药——作用 联想搜索:nhm能治什么病,nhm的证候,nhm的功能
|
|
|
|
|
*/
|
|
|
|
|
TextView asscoiate_text=findViewById(R.id.asscoiate_text);
|
|
|
|
|
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) {
|
|
|
|
|
SearchServiceGet.executeSearchGet(response.getMsg()+"吃什么药");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}else if(response.getCode()==DiseaseToMedicines){
|
|
|
|
|
/**
|
|
|
|
|
* 病——药 nhm能指什么病,nhm能治什么病,nhm能治什么病
|
|
|
|
|
* 随机选三种药品
|
|
|
|
|
*/
|
|
|
|
|
Random r=new Random();
|
|
|
|
|
for(int i=0;i<3;i++) {
|
|
|
|
|
TextView textView = findViewById(R.id.asscoiate_entry);
|
|
|
|
|
int index = r.nextInt(10) + 1;
|
|
|
|
|
textView.setText(content.get(index) + "能治什么病症");
|
|
|
|
|
textView.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
SearchServiceGet.executeSearchGet(content.get(index) + "能治什么病");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}else if(response.getCode()==MedicineToOperation){
|
|
|
|
|
/**
|
|
|
|
|
* 药——操作方法
|
|
|
|
|
* nhm能治什么病 ,nhm的证候,nhm的功能
|
|
|
|
|
*/
|
|
|
|
|
TextView textView_1=findViewById(R.id.asscoiate_entry);
|
|
|
|
|
TextView textView_2=findViewById(R.id.asscoiate_entry);
|
|
|
|
|
TextView textView_3=findViewById(R.id.asscoiate_entry);
|
|
|
|
|
textView_1.setText(response.getMsg()+"能治什么病");
|
|
|
|
|
textView_2.setText(response.getMsg()+"的证候");
|
|
|
|
|
textView_3.setText(response.getMsg()+"的功能");
|
|
|
|
|
textView_1.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
SearchServiceGet.executeSearchGet(response.getMsg() + "能治什么病");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
textView_2.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
SearchServiceGet.executeSearchGet(response.getMsg() + "的证候");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
textView_3.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
SearchServiceGet.executeSearchGet(response.getMsg() + "的功能");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}else if(response.getCode()==MedicineToSymptom){
|
|
|
|
|
/**
|
|
|
|
|
*药——作用
|
|
|
|
|
* nhm能治什么病,nhm的证候,nhm的功能
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|