master
ongbo 5 years ago
parent 014e88c7f4
commit e8915eca23

@ -15,7 +15,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.example.SearchCenter.SearchEntryActivity"/>
<activity android:name="com.example.PersonalCenter.LoginActivity"/>
<activity android:name="com.example.PersonalCenter.Login_Register.LoginActivity"/>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

@ -1,27 +0,0 @@
//package com.example.PersonalCenter;
//
//import android.util.Log;
//
//public class Login {
//
// private String password;
// private String phonenumber;
// public Login(String phonenumber,String password){
//
// this.password = password;
// this.phonenumber = phonenumber;
//
// }
// public String connUser(){
// String infoString = WebServiceGet.executeHttpGet(phonenumber,password,"/Login");
//// if(infoString.equals("false")){
//// Log.i("Login","+++++++++++fail"+infoString);
//// }else {
//// Log.i("Login","+++++++++++successs"+infoString);
//// }
// //登录成功后返回用户名
// while(infoString==null){}
// Log.i("sucesss",infoString+"ha");
// return infoString;
// }
//}

@ -1,4 +1,4 @@
package com.example.PersonalCenter;
package com.example.PersonalCenter.Login_Register;
import android.animation.Animator;
import android.animation.AnimatorSet;
@ -23,16 +23,13 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.example.PersonalCenter.JellyInterpolator;
import com.example.Util.ReturnData;
import com.example.Util.User;
import com.example.Util.cmkgWebServiceGet;
import com.example.Util.publicStringUtil;
import com.example.cmknowledgegraph.R;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.lang.ref.WeakReference;

@ -6,11 +6,10 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import androidx.fragment.app.Fragment;
import com.example.PersonalCenter.LoginActivity;
import com.example.PersonalCenter.Login_Register.LoginActivity;
import com.example.Util.User;
import com.example.cmknowledgegraph.R;

@ -1,20 +0,0 @@
//package com.example.PersonalCenter;
//
//public class Register {
// String phonenumber;
// String username;
// String password;
// public Register(String phonenumber, String username, String password){
// this.phonenumber = phonenumber;
// this.username = username;
// this.password = password;
// }
// public boolean regist(){
// String regRet = WebServicePost.execuHttpPost(username, phonenumber, password,"/Register");
// if(regRet.equals("true")){
// return true;
// }else {
// return false;
// }
// }
//}

@ -1,47 +0,0 @@
//package com.example.PersonalCenter;
//
//import android.util.Log;
//
//import com.hankcs.hanlp.HanLP;
//
//import java.lang.reflect.Array;
//import java.util.ArrayList;
//import java.util.HashSet;
//import java.util.List;
//import java.util.Set;
//
//public class Search {
// public String sickname;
// public Search(String sickname){
// this.sickname = sickname;
// }
//
// public List<Set<String>> search(){
// Log.i("search","sick执行了");
// //找出对应的8个关键字
// List<String> keywordList = HanLP.extractKeyword(sickname,8);
//
// //针对每一个sickname来查找一下能不能够找到相应的名字
// Set<String> mediciesSet = new HashSet<String>();
// Set<String> reasonsSet = new HashSet<String>();
// for(String i: keywordList){
// Log.i("关键词提取",i+"ha");
// String resq = SearchServiceGet.executeSearchGet(i,"/Search");
// String resq="dd";
// if(!resq.equals("fail")) {
// String[] me_rea = resq.split("-");
// String[] medicines = me_rea[0].split("\\|");
// for(String j: medicines) mediciesSet.add(j);
// String[] reasons = me_rea[1].split("\\|");
// for(String j: reasons) reasonsSet.add(j);
//
// }
// }
// List<Set<String>> a = new ArrayList<Set<String>>();
// a.add(mediciesSet);
// a.add(reasonsSet);
// return a;
//
//
// }
//}

@ -1,138 +0,0 @@
package com.example.PersonalCenter;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.util.ArrayList;
public class SearchServiceGet {
public static ArrayList<String> content=new ArrayList<String>();//存储数据内容
public static String name_back;
public static boolean SearchSuccess=false;
public static int code;
public static void executeSearchGet(String name){
HttpURLConnection connection = null;
InputStream in = null;
String address="/rest/cmkg/question/hello";
String Url = "http://114.116.199.154:5000/cmkg"+address;
String path = Url + "?name="+name;
URL url = null;
try {
url = new URL(path);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(100000);//建立连接超时
connection.setReadTimeout(80000);//传输数据超时
in = connection.getInputStream();
BufferedReader reader = null;//输入流
String line = "";//读取返回的每一行
StringBuilder response = new StringBuilder();
try {
reader = new BufferedReader(new InputStreamReader(in));
while((line = reader.readLine()) != null) {
response.append(line);
}
//这时候response就是一个连续字符串了吧
Log.i("response+++++",response+"返回值");
System.out.println(response.toString());
//开始解析返回的数据
// JSONObject jo=JSONObject.fromObject(response.toString());
org.json.JSONObject jo = null;
try {
jo = new org.json.JSONObject(response.toString());
} catch (JSONException e) {
e.printStackTrace();
}
try {
code=jo.getInt("code");
} catch (JSONException e) {
e.printStackTrace();
}
System.out.println("code="+code);
if(code!=0){ //查询成功,在开始解析数据
System.out.println("code==@@@@@@@@@@20"+code);
try {
name_back=jo.getString("message");//查询的主语
} catch (JSONException e) {
e.printStackTrace();
}
//把data看作一个JSONObject无论里面由多少元素都转换为JSONArray存在数组里
JSONObject jo_data= null;
try {
jo_data = jo.getJSONObject("data");
if(jo_data==null) System.out.println(("jo_data==null"));
} catch (JSONException e) {
e.printStackTrace();
}
JSONArray data_arr=new JSONArray();
ArrayList<String> datas=new ArrayList<String>();
try {
// jo_data.toJSONArray(data_arr);
datas.add(jo_data.toString());
data_arr=jo.getJSONArray("data");
System.out.println("data_arr======"+data_arr.length());
} catch (JSONException e) {
e.printStackTrace();
}
//遍历data_arr把里面的数据放入ArrayList<String> content里
for(int i=0;i<datas.size();i++){
try {
content.add(datas.get(i));
} catch (Exception e) {
e.printStackTrace();
}
}
SearchSuccess=true;//查找成功标志
}
// return content;
} catch (IOException e) {
e.printStackTrace();
}finally {
if(reader!=null){
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// return "";
}
public static void exxcuteTest(String name){
code=100;
name_back="糖尿病";
content.add("莲子粥");
content.add("推拿法");
content.add("大蒜蒸西瓜");
content.add("红枣糕");
}
}

@ -90,7 +90,7 @@ public class SearchContent extends Fragment {
@Override
public void run() {
ReturnData response = cmkgWebServiceGet.executeHttpGet(inputContentArgs,publicStringUtil.questionSearchURL);
// SearchServiceGet.exxcuteTest(inputContent);
//构建消息将消息交给handle处理
Message m = new Message();
Bundle bundle = new Bundle();
@ -105,8 +105,6 @@ public class SearchContent extends Fragment {
}
}).start();
// SearchServiceGet.exxcuteTest(inputContent);
// //执行到这里已经把data里的数据取出来了或没有但是都要跳转页面到SearchEntryActivity页面
}
});

Loading…
Cancel
Save