Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app/src/main/res/layout/activity_main.xml
master
hanxueqing 5 years ago
parent de89d85032
commit 581f8cbb1e

@ -2,8 +2,7 @@ package com.example.PersonalCenter;
import android.util.Log;
import com.alibaba.fastjson.JSON;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import java.io.BufferedReader;
@ -15,16 +14,14 @@ import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Map;
public class SearchServiceGet {
public static ArrayList<String> label=new ArrayList<String>();//存储标签内容
public static ArrayList<String> content=new ArrayList<String>();//存储数据内容
public static Map mapType;
public static String name_back;
public static boolean SearchSuccess=false;
public static String executeSearchGet(String name){
public static void executeSearchGet(String name){
HttpURLConnection connection = null;
InputStream in = null;
@ -55,24 +52,20 @@ public class SearchServiceGet {
//开始解析返回的数据
JSONObject jo=JSONObject.fromObject(response.toString());
String message=jo.getString("message");
int code=jo.getInt("code");
if((message.equals("病症查询成功")||message.equals("药品查询成功"))&&code==200){
//查询成功,在开始解析数据
//把data里的数据转换为Map遍历map打印键值对
String data=jo.get("data").toString();
mapType = JSON.parseObject(data,Map.class);
for (Object obj : mapType.keySet()) {
//把键值对放入队列中,前提是标签的内容不为空
if(mapType.get(obj)!=null) {
label.add(obj.toString());
content.add(mapType.get(obj).toString());
System.out.println("key为" + obj + "值为:" + mapType.get(obj));
}
if(code!=0){ //查询成功,在开始解析数据
name_back=jo.getString("message");//查询的主语
//把data看作一个JSONObject无论里面由多少元素都转换为JSONArray存在数组里
JSONObject jo_data=jo.getJSONObject("data");
JSONArray data_arr=null;
jo_data.toJSONArray(data_arr);
//遍历data_arr把里面的数据放入ArrayList<String> content里
for(int i=0;i<data_arr.size();i++){
content.add(data_arr.get(i).toString());
}
SearchSuccess=true;//查找成功标志
}
return response.toString();
// return content;
} catch (IOException e) {
e.printStackTrace();
}finally {
@ -91,7 +84,7 @@ public class SearchServiceGet {
} catch (IOException e) {
e.printStackTrace();
}
return "";
// return "";
}
}

@ -0,0 +1,10 @@
package com.example.cmknowledgegraph;
public interface ConditionCode {
public final int DiseaseToSymptom=100;
public final int DiseaseToMedicines=200;
public final int MedicineToOperation=300;
public final int MedicineToSymptom=400;
}

@ -0,0 +1,17 @@
package com.example.cmknowledgegraph;
public class ContentData {
/**
*
*/
private String contentdata;
public String getContentdata() {
return contentdata;
}
public void setContentdata(String contentdata) {
this.contentdata = contentdata;
}
}

@ -11,6 +11,8 @@ import android.widget.ImageButton;
import androidx.fragment.app.Fragment;
import com.example.PersonalCenter.SearchServiceGet;
import java.util.List;
import java.util.Set;
//
@ -33,23 +35,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
public void onClick(View v) {
Log.i("haha", "=======Oncli");
// //点击查找按钮之后,取出输入的句子,传给后台
// String inputContent = search_edit.getText().toString();
// SearchServiceGet.executeSearchGet(inputContent);
String inputContent = search_edit.getText().toString();
SearchServiceGet.executeSearchGet(inputContent);
// //执行到这里已经把data里的数据取出来了或没有但是都要跳转页面到SearchEntryActivity页面
// Intent intent = new Intent();
// intent.setClass(getActivity(), SearchEntryActivity.class);
// startActivity(intent);
//小测试,点击查找按钮后,先把队列装满,然后再跳转
// SearchServiceGet.label.add("name");
// SearchServiceGet.content.add("糖尿病");
// SearchServiceGet.label.add("症状");
// SearchServiceGet.content.add("附近的一耦合发动机设计费德勒水库fury突然附近的是否考虑降低身份与日房价疯狂的事啦JFK lads JFK的拉萨");
// System.out.println(SearchServiceGet.label.get(0)+"==========");
// System.out.println(SearchServiceGet.label.get(1)+"==========");
// System.out.println(SearchServiceGet.content.get(0)+"==========");
// System.out.println(SearchServiceGet.content.get(1)+"==========");
Intent intent = new Intent();
intent.setClass(getActivity(), SearchEntryActivity.class);
startActivity(intent);

@ -1,8 +1,14 @@
package com.example.cmknowledgegraph;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.loopeer.cardstack.AllMoveDownAnimatorAdapter;
import com.loopeer.cardstack.CardStackView;
import com.loopeer.cardstack.UpDownAnimatorAdapter;
import com.loopeer.cardstack.UpDownStackAnimatorAdapter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@ -23,53 +29,7 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search_entry);
init();
/**
* //有SearchContent跳转到这里。在这里访问全局变量实例化ListView
* Intent intent=new Intent();
* intent.setClass(this,SearchContentActivity.class);
*
* ListView lv = findViewById(R.id.listView1);
* ListView listView=findViewById(R.id.listView1);
* ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, SearchServiceGet.label);
* ArrayAdapter<String> adapter_1 = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, SearchServiceGet.content);
*
* lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
* @Override
* public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
* //根据点击不同的item跳转到不同的页面
* // switch (i){
* // case 0:
* // intent.putExtra("label",SearchServiceGet.label.get(1));
* // startActivity(intent);
* // break;
* // case 1:
* // intent.putExtra("label",SearchServiceGet.label.get(2));
* // startActivity(intent);
* // break;
* // }
*
* //做个小测试,做隐藏动画
* switch (listView.getVisibility()) {
* // 若显示,则隐藏
* case 0:
* listView.setVisibility(View.GONE);
* break;
* // 若隐藏,则显示
* case 8:
* listView.setVisibility(View.VISIBLE);
* break;
* default:
* break;
* }
*
* }
* });
* lv.setAdapter(adapter);
* listView.setAdapter(adapter_1);
*/
}
public void onItemExpend(boolean expend) {
@ -82,6 +42,16 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
mCardStack.setAdapter(adapter);
mCardStack.setItemExpendListener(this);
/**
*
* 便items
* -
* -
* -
* -
*
*
*/
List<List<LessonData>> lists = new LinkedList<>();
for(int i = 0;i<4;i++)
{
@ -94,8 +64,8 @@ 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));
mCardStack.setAnimatorAdapter(new AllMoveDownAnimatorAdapter(mCardStack));
mCardStack.setAnimatorAdapter(new UpDownAnimatorAdapter(mCardStack));
mCardStack.setAnimatorAdapter(new UpDownStackAnimatorAdapter(mCardStack));
}
}

@ -1,44 +0,0 @@
package com.example.cmknowledgegraph;
import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.suggest.Suggester;
import java.util.List;
public class abcd {
public void init(){
/**
*
* + ++ +
*
*
*
*/
String content = "我的胃不舒服";
List<String> keywordList = HanLP.extractKeyword(content, 5);
System.out.println(keywordList);
//关键词联想
Suggester suggester = new Suggester();
String[] titleArray =
(
"威廉王子发表演说 呼吁保护野生动物\n" +
"《时代》年度人物最终入围名单出炉 普京马云入选\n" +
"“黑格比”横扫菲:菲吸取“海燕”经验及早疏散\n" +
"日本保密法将正式生效 日媒指其损害国民知情权\n" +
"英报告说空气污染带来“公共健康危机”"
).split("\\n");
for (String title : titleArray)
{
suggester.addSentence(title);
}
System.out.println(suggester.suggest("发言", 1)); // 语义
System.out.println(suggester.suggest("危机公共", 1)); // 字符
System.out.println(suggester.suggest("mayun", 1)); // 拼音
}
}

@ -1,15 +0,0 @@
<?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="match_parent"
tools:context=".SearchContentActivity">
<TextView
android:id="@+id/search_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

@ -6,6 +6,9 @@
android:orientation="vertical"
android:padding="16dp"
>
<!--
这个布局是Header
\-->
<FrameLayout
android:layout_width="match_parent"
@ -16,7 +19,6 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2016-2017-2学期"
android:layout_margin="16dp"
android:textSize="20sp"
android:textStyle="bold"
@ -24,6 +26,7 @@
android:id="@+id/card_title_text"
/>
</FrameLayout>
<!-- android:text="2016-2017-2学期"-->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

@ -88,6 +88,22 @@
android:layout_marginLeft="25dp"
android:layout_marginStart="25dp"
/>
<!--为了方便我们先不删除原有模板的items我们点开之后有几种情况
病-症状:标题是名字,内容是症状
病-治疗药品:标婷是药的名字,内容是药的用法(暂时不做)
药-用法:标题是药的名字,内容是药的用法
药-作用:标题是药的名字,内容是药的用法
-->
<!--
所以在这里内容只设置一个TextView
-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/search_content"
style="@style/scores_item_style"
android:paddingLeft="10dp"
android:paddingTop="10dp"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
Loading…
Cancel
Save