frame update

ongbodev
ongbo 6 years ago
parent 07f2732995
commit 90e4d72247

@ -0,0 +1 @@
CMKnowledgeGraph

@ -49,5 +49,11 @@ dependencies {
implementation 'com.jpardogo.materialtabstrip:library:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.0.0'
implementation 'com.github.ibrahimsn98:SmoothBottomBar:1.5'
//OKhttp
//// implementation "com.squareup.okhttp3:okhttp:4.2.2"
// implementation 'com.alibaba:fastjson:1.2.61'
implementation 'com.alibaba:fastjson:1.1.71.android'
//
implementation 'com.github.yalantis:jellytoolbar:v1.0'
}

@ -0,0 +1,38 @@
package com.example.PersonalCenter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON;
import com.example.cmknowledgegraph.LoginActivity;
import com.example.tools.retuData;
public class HandlerHandle extends Handler {
LoginActivity loginActivity;
public HandlerHandle(LoginActivity loginActivity){
this.loginActivity = loginActivity;
}
@Override
public void handleMessage(@NonNull Message msg) {
//根据登录状态请求不同的消息
super.handleMessage(msg);
Bundle b = msg.getData();
String data = b.getString("msg");
Log.i("haha-====","==="+data);
retuData retuData = JSON.parseObject(data, com.example.tools.retuData.class);
if(retuData.msg.equals("success")){
//登录成功,返回主页面
}else{
// 登录失败
Toast.makeText(loginActivity, retuData.msg, Toast.LENGTH_SHORT).show();
}
}
}

@ -0,0 +1,17 @@
package com.example.PersonalCenter;
import android.view.animation.LinearInterpolator;
public class JellyInterpolator extends LinearInterpolator {
private float factor;
public JellyInterpolator() {
this.factor = 0.15f;
}
@Override
public float getInterpolation(float input) {
return (float) (Math.pow(2, -10 * input)
* Math.sin((input - factor / 4) * (2 * Math.PI) / factor) + 1);
}
}

@ -2,6 +2,10 @@ package com.example.PersonalCenter;
import android.util.Log;
import com.example.tools.retuData;
import java.io.IOException;
public class Login {
private String password;
@ -12,15 +16,15 @@ public class Login {
this.phonenumber = phonenumber;
}
public String connUser(){
String infoString = WebServiceGet.executeHttpGet(phonenumber,password,"/Login");
public String connUser() throws IOException {
String infoString = WebServiceGet.executeHttpGet(phonenumber,password,"/person/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;
}

@ -0,0 +1,92 @@
package com.example.PersonalCenter;
/*
* User
*
*
*
* */
public class User {
private static User user;//保存某一个用户
private String phonenumber;
private String username;
private String avatar_url;
private String sex;
private Long age;
public static boolean isLogin;//是否登录
private User(){}
public static synchronized User getUser(){
if(user == null){
user = new User();
}
return user;
}
public static void setUser(String phonenumber, String username, String avatar_url, String sex, Long age) {
user.setAge(age);
user.setAvatar_url(avatar_url);
user.setPhonenumber(phonenumber);
user.setUsername(username);
user.setSex(sex);
}
//设置登录状态
public static void setLogin(boolean login) {
isLogin = login;
}
//获取登录状态
public static boolean isLogin() {
return isLogin;
}
//注销
public static void logoff(){
user.setAge(null);
user.setAvatar_url(null);
user.setPhonenumber(null);
user.setUsername(null);
user.setSex(null);
user = null;
}
public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
}
public void setUsername(String username) {
this.username = username;
}
public void setAvatar_url(String avatar_url) {
this.avatar_url = avatar_url;
}
public void setSex(String sex) {
this.sex = sex;
}
public void setAge(Long age) {
this.age = age;
}
public String getPhonenumber() {
return phonenumber;
}
public String getUsername() {
return username;
}
public String getAvatar_url() {
return avatar_url;
}
public String getSex() {
return sex;
}
public Long getAge() {
return age;
}
}

@ -1,5 +1,10 @@
package com.example.PersonalCenter;
import android.util.Log;
import com.alibaba.fastjson.JSON;
import com.example.tools.retuData;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@ -8,35 +13,45 @@ import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class WebServiceGet {
public static String executeHttpGet(String phonenumber,String password,String address){
public static String UrlPath = "http://114.55.37.70/CMKnowledgeGraph";//服务器项目的总请求路径
//登录请求
public static String executeHttpGet(String phonenumber,String password,String address) {
HttpURLConnection connection = null;
InputStream in = null;
InputStream br = null;
String Url = "http://106.54.210.208:8080/ChineseM"+address;
String Url = UrlPath + address;
String path = Url+"?phonenumber=" + phonenumber + "&password=" + password;
Log.i("login---====--",""+path);
URL url = null;
try {
url = new URL(path);
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
connection = (HttpURLConnection)url.openConnection();
connection = (HttpURLConnection) url.openConnection();
connection.setConnectTimeout(100000);
connection.setReadTimeout(80000);
connection.setRequestMethod("GET");
connection.setConnectTimeout(100000);//建立连接超时
connection.setReadTimeout(80000);//传输数据超时
in = connection.getInputStream();
return parseInfo(in);
//获取结果
// int responseCode = connection.getResponseCode();
// if(responseCode == 200){
br = connection.getInputStream();
String readline = parseInfo(br);
return readline;
// }
} catch (IOException e) {
e.printStackTrace();
}finally {
if(connection != null){
if(connection!=null){
connection.disconnect();
}
if(in != null){
if(br!=null){
try {
in.close();
br.close();
} catch (IOException e) {
e.printStackTrace();
}

@ -1,113 +1,308 @@
package com.example.cmknowledgegraph;
import android.content.Intent;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.view.ViewGroup;
import android.view.Window;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.example.PersonalCenter.HandlerHandle;
import com.example.PersonalCenter.JellyInterpolator;
import com.example.PersonalCenter.Login;
import com.example.tools.retuData;
import java.io.IOException;
public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
private TextView mBtnLogin;
private View progress;
private View mInputLayout;
private float mWidth, mHeight;
private LinearLayout mName, mPsw;
public class LoginActivity extends AppCompatActivity {
public static String username;
public static int usersuccess = 0;
public static boolean isLogin=false;//登录属性true登陆成功false未登录
@Override
protected void onCreate(Bundle savedInstanceState) {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_login);
final EditText tel_edit=findViewById(R.id.id_edit);
final EditText password_edit=findViewById(R.id.password_edit);
initView();
/**
* (int)(string)
*/
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.activity_personality_center, null);
final Button welcom_btn= layout.findViewById(R.id.welcom_btn);
}
public void initView(){
mBtnLogin = (TextView) findViewById(R.id.main_btn_login);
progress = findViewById(R.id.layout_progress);
mInputLayout = findViewById(R.id.input_layout);
mName = (LinearLayout) findViewById(R.id.id_edit);
mPsw = (LinearLayout) findViewById(R.id.password_edit);
//给登录设置监听
final Button login_btn=findViewById(R.id.login_btn);
login_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(tel_edit==null||tel_edit.getText().toString().equals("")){
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
builder.setTitle("登录失败");// 设置标题
builder.setMessage("请输入电话号码");// 为对话框设置内容
builder.create().show();// 使用show()方法显示对话框
}else if(password_edit==null||password_edit.getText().toString().equals("")){
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
builder.setTitle("登录失败");// 设置标题
builder.setMessage("请输入密码");// 为对话框设置内容
builder.create().show();// 使用show()方法显示对话框
}else {
//获取手机号和密码
String tel = tel_edit.getText().toString().trim();
String password = password_edit.getText().toString();
//调用数据库类中的方法进行登录
// boolean isLogin= OperaSchema.longin(tel,password);//原来的数据库
final Login login = new Login(tel, password);
//设置监听
mBtnLogin.setOnClickListener(this);
}
@Override
public void onClick(View v) {
//异步处理消息请求
final HandlerHandle handler = new HandlerHandle(this);
int viewID = v.getId();
switch (viewID){
case R.id.main_btn_login:
//登录
//根据监听的不同内容,来改变响应状态
// 计算出控件的高与宽
mWidth = mBtnLogin.getMeasuredWidth();
mHeight = mBtnLogin.getMeasuredHeight();
// 隐藏输入框
mName.setVisibility(View.INVISIBLE);
mPsw.setVisibility(View.INVISIBLE);
//调入动画
inputAnimator(mInputLayout, mWidth, mHeight);
//如果登录成功
//获取手机号和密码
EditText phonenumberEditText = (EditText) mName.getChildAt(1);
EditText passwordEditText = (EditText) mName.getChildAt(1);
if(phonenumberEditText==null||phonenumberEditText.getText().toString().equals("")){
//请输入用户名
Toast.makeText(this, "请输入用户名", Toast.LENGTH_SHORT).show();
}else if(passwordEditText==null||passwordEditText.getText().toString().equals("")){
//请输入密码
Toast.makeText(this, "请输入用户名", Toast.LENGTH_SHORT).show();
}else{
String phonenumber = phonenumberEditText.getText().toString();
String password = phonenumberEditText.getText().toString();
Login login = new Login(phonenumber, password);
new Thread(new Runnable() {
@Override
public void run() {
LoginActivity.username = login.connUser();
LoginActivity.usersuccess = 1;
Log.i("登录", "登录有没有问题" + username + "oooo");
try {
String retuData = login.connUser();
Log.i("returndat--","-----"+retuData);
Message m = new Message();
Bundle b = new Bundle();
b.putString("msg",retuData);
m.setData(b);
handler.sendMessage(m);
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
/**
*
*
*/
while (LoginActivity.usersuccess == 0) {
Log.i("suersuer======", "dkie" + LoginActivity.usersuccess);
}
if (!LoginActivity.username.equals("")) {
//改变个人中心的登录状态,
isLogin=true;
finish();//返回个人中心Activity
//刷新个人中心Activity
Log.i("成功", "成功了");
} else {//登陆失败提醒
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
builder.setTitle("登陆提醒");// 设置标题
builder.setMessage("登陆失败");// 为对话框设置内容
builder.create().show();// 使用show()方法显示对话框
Log.i("失败", "失败了");
}
LoginActivity.username = "";
LoginActivity.usersuccess = 0;
}
break;
case R.id.main_title:
//注册
}
}
//设置输入框动画效果
private void inputAnimator(final View view, float w, float h){
AnimatorSet set = new AnimatorSet();
ValueAnimator animator = ValueAnimator.ofFloat(0, w);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (Float) animation.getAnimatedValue();
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view
.getLayoutParams();
params.leftMargin = (int) value;
params.rightMargin = (int) value;
view.setLayoutParams(params);
}
});
//TextView注册跳转
TextView register_text=findViewById(R.id.register_text);
register_text.setOnClickListener(new View.OnClickListener() {
ObjectAnimator animator2 = ObjectAnimator.ofFloat(mInputLayout,
"scaleX", 1f, 0.5f);
set.setDuration(1000);
set.setInterpolator(new AccelerateDecelerateInterpolator());
set.playTogether(animator, animator2);
set.start();
set.addListener(new Animator.AnimatorListener() {
@Override
public void onClick(View view) {
//跳转到注册页面
Intent intent=new Intent();
intent.setClass(LoginActivity.this,RegisterActivity.class);
startActivity(intent);
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
/**
*
*/
progress.setVisibility(View.VISIBLE);
progressAnimator(progress);
mInputLayout.setVisibility(View.INVISIBLE);
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
}
private void progressAnimator(final View view) {
PropertyValuesHolder animator = PropertyValuesHolder.ofFloat("scaleX",
0.5f, 1f);
PropertyValuesHolder animator2 = PropertyValuesHolder.ofFloat("scaleY",
0.5f, 1f);
ObjectAnimator animator3 = ObjectAnimator.ofPropertyValuesHolder(view,
animator, animator2);
animator3.setDuration(1000);
animator3.setInterpolator(new JellyInterpolator());
animator3.start();
}
//登录错误,恢复初始状态
private void recovery() {
progress.setVisibility(View.GONE);
mInputLayout.setVisibility(View.VISIBLE);
mName.setVisibility(View.VISIBLE);
mPsw.setVisibility(View.VISIBLE);
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mInputLayout.getLayoutParams();
params.leftMargin = 0;
params.rightMargin = 0;
mInputLayout.setLayoutParams(params);
ObjectAnimator animator2 = ObjectAnimator.ofFloat(mInputLayout, "scaleX", 0.5f,1f );
animator2.setDuration(500);
animator2.setInterpolator(new AccelerateDecelerateInterpolator());
animator2.start();
}
// public static String username;
// public static int usersuccess = 0;
// public static boolean isLogin=false;//登录属性true登陆成功false未登录
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_login);
//
// final EditText tel_edit=findViewById(R.id.id_edit);
// final EditText password_edit=findViewById(R.id.password_edit);
//
// /**
// * 登录按钮,传递参数:手机号(int)、密码(string)
// */
//
// LayoutInflater inflater = getLayoutInflater();
// View layout = inflater.inflate(R.layout.activity_personality_center, null);
// final Button welcom_btn= layout.findViewById(R.id.welcom_btn);
//
// final Button login_btn=findViewById(R.id.login_btn);
// login_btn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// if(tel_edit==null||tel_edit.getText().toString().equals("")){
// AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
// builder.setTitle("登录失败");// 设置标题
// builder.setMessage("请输入电话号码");// 为对话框设置内容
// builder.create().show();// 使用show()方法显示对话框
// }else if(password_edit==null||password_edit.getText().toString().equals("")){
// AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
// builder.setTitle("登录失败");// 设置标题
// builder.setMessage("请输入密码");// 为对话框设置内容
// builder.create().show();// 使用show()方法显示对话框
// }else {
// //获取手机号和密码
// String tel = tel_edit.getText().toString().trim();
// String password = password_edit.getText().toString();
// //调用数据库类中的方法进行登录
//// boolean isLogin= OperaSchema.longin(tel,password);//原来的数据库
// final Login login = new Login(tel, password);
//
// new Thread(new Runnable() {
// @Override
// public void run() {
// LoginActivity.username = login.connUser();
// LoginActivity.usersuccess = 1;
// Log.i("登录", "登录有没有问题" + username + "oooo");
//
// }
// }).start();
///**
// * 登陆成功,返回上一个界面,即个人中心界面,刷新个人中心界面
// * 即,改变登录按钮为欢迎按钮
// */
// while (LoginActivity.usersuccess == 0) {
// Log.i("suersuer======", "dkie" + LoginActivity.usersuccess);
// }
//
// if (!LoginActivity.username.equals("")) {
// //改变个人中心的登录状态,
// isLogin=true;
// finish();//返回个人中心Activity
// //刷新个人中心Activity
// Log.i("成功", "成功了");
//
// } else {//登陆失败提醒
// AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
// builder.setTitle("登陆提醒");// 设置标题
// builder.setMessage("登陆失败");// 为对话框设置内容
// builder.create().show();// 使用show()方法显示对话框
// Log.i("失败", "失败了");
// }
// LoginActivity.username = "";
// LoginActivity.usersuccess = 0;
// }
//
// }
// });
//
// //TextView注册跳转
// TextView register_text=findViewById(R.id.register_text);
// register_text.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// //跳转到注册页面
// Intent intent=new Intent();
// intent.setClass(LoginActivity.this,RegisterActivity.class);
// startActivity(intent);
// }
// });
// }
}

@ -26,6 +26,7 @@ public class MainActivity extends AppCompatActivity {
public final AppCompatActivity getAppCompatActivity(){
return this;
}
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@ -46,7 +47,10 @@ public class MainActivity extends AppCompatActivity {
transaction.commit(); //提交事务
return true;
case R.id.search:
transaction.replace(R.id.content,new SearchContent()); //对应的java class
SearchContent searchContent = new SearchContent();
searchContent.setAppCompatActivity(getAppCompatActivity());
transaction.replace(R.id.content, searchContent); //对应的java class
transaction.commit(); //提交事务
return true;
case R.id.chat:

@ -26,23 +26,26 @@ public class PersonContent extends Fragment {
login_pc_btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//跳转到LoginActivity
if(!LoginActivity.isLogin){
Intent intent=new Intent();
intent.setClass(getActivity(),LoginActivity.class);
startActivity(intent);
}
// if(!LoginActivity.isLogin){
// Intent intent=new Intent();
// intent.setClass(getActivity(),LoginActivity.class);
// startActivity(intent);
// }
Intent intent=new Intent();
intent.setClass(getActivity(),LoginActivity.class);
startActivity(intent);
}
});
}
@Override
public void onResume() {
super.onResume();
if(LoginActivity.isLogin){
Button longin_pc_btn=(Button) getActivity().findViewById(R.id.login_pc_button);
longin_pc_btn.setText("Hello"+LoginActivity.username);
}
//高血压
}
// @Override
// public void onResume() {
// super.onResume();
// if(LoginActivity.isLogin){
// Button longin_pc_btn=(Button) getActivity().findViewById(R.id.login_pc_button);
// longin_pc_btn.setText("Hello"+LoginActivity.username);
// }
//
////高血压
// }
}

@ -17,17 +17,17 @@ public class SearchActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
EditText search_edit_frame = findViewById(R.id.search_edit);
ImageButton search_btn = findViewById(R.id.search_btn);
String sickname = search_edit_frame.getText().toString();
search_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Search search = new Search(sickname);
// search.search();
}
});
// EditText search_edit_frame = findViewById(R.id.search_edit);
// ImageButton search_btn = findViewById(R.id.search_btn);
// String sickname = search_edit_frame.getText().toString();
//
// search_btn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
//// Search search = new Search(sickname);
//// search.search();
// }
// });
}
}

@ -1,7 +1,9 @@
package com.example.cmknowledgegraph;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -9,63 +11,145 @@ import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatEditText;
import androidx.fragment.app.Fragment;
import com.example.PersonalCenter.Search;
import com.hankcs.hanlp.seg.common.Term;
import com.hankcs.hanlp.tokenizer.StandardTokenizer;
import com.yalantis.jellytoolbar.listener.JellyListener;
import com.yalantis.jellytoolbar.widget.JellyToolbar;
import java.util.List;
import java.util.Set;
//
public class SearchContent extends Fragment {
private static final String TEXT_KEY = "text";
AppCompatActivity appCompatActivity;
public static List<Set<String>> a;
public static int k=0;
public AppCompatActivity getAppCompatActivity() {
return appCompatActivity;
}
public void setAppCompatActivity(AppCompatActivity appCompatActivity) {
this.appCompatActivity = appCompatActivity;
}
private JellyToolbar toolbar;
private AppCompatEditText editText;
private JellyListener jellyListener = new JellyListener() {
@Override
public void onCancelIconClicked() {
if (TextUtils.isEmpty(editText.getText())) {
toolbar.collapse();
} else {
editText.getText().clear();
}
}
};
public static List<Set<String>> a;
public static int k=0;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate( R.layout.activity_search, container, false ); //要加载的layout文件
}
private int getStatusBarHeight() {
int result = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = getResources().getDimensionPixelSize(resourceId);
}
return result;
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
outState.putString(TEXT_KEY, editText.getText().toString());
super.onSaveInstanceState(outState);
}
//
// @Override
// public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
// super.onViewStateRestored(savedInstanceState);
//
// editText.setText(savedInstanceState.getString(TEXT_KEY));
// editText.setSelection(editText.getText().length());
// }
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
EditText search_edit = getActivity().findViewById(R.id.search_edit);
ImageButton search_btn = (ImageButton) getActivity().findViewById(R.id.search_btn);
search_btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Log.i("haha","=======Oncli");
//查找逻辑
List<Term> termList = StandardTokenizer.segment("什么是糖尿病");
System.out.println(termList);
String sickname = search_edit.getText().toString();
Search search = new Search(sickname);
new Thread(new Runnable() {
@Override
public void run() {
SearchContent.a = search.search();
SearchContent.k = 1;
}
}).start();
while(SearchContent.k==0) {Log.i("i","i");}
if(SearchContent.a!=null){
String[] medicines = a.get(0).toArray(new String[0]);
String[] reasons = a.get(1).toArray(new String[0]);
ListView lv = getActivity().findViewById(R.id.listView1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,medicines);
lv.setAdapter(adapter);
}
SearchContent.k=0;
SearchContent.a=null;
super.onActivityCreated(savedInstanceState);
toolbar = (JellyToolbar) appCompatActivity.findViewById(R.id.toolbar);
toolbar.getToolbar().setNavigationIcon(R.drawable.ic_menu);
toolbar.setJellyListener(jellyListener);
toolbar.getToolbar().setPadding(0, getStatusBarHeight(), 0, 0);
editText = (AppCompatEditText) LayoutInflater.from(appCompatActivity).inflate(R.layout.edit_text, null);
editText.setBackgroundResource(R.color.colorTransparent);
toolbar.setContentView(editText);//添加入输入框
appCompatActivity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
toolbar.setJellyListener(jellyListener);
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if((event != null && KeyEvent.KEYCODE_ENTER == event.getKeyCode() && KeyEvent.ACTION_DOWN == event.getAction())){
Log.i("dianjile","你点击了哥哥");
toolbar.collapse();
editText.getText().clear();
return true;
}
});
return false;
}
});
// TODO Auto-generated method stub
// super.onActivityCreated(savedInstanceState);
// EditText search_edit = getActivity().findViewById(R.id.search_edit);
//
// ImageButton search_btn = (ImageButton) getActivity().findViewById(R.id.search_btn);
//
// search_btn.setOnClickListener(new View.OnClickListener() {
// public void onClick(View v) {
// Log.i("haha","=======Oncli");
// //查找逻辑
// List<Term> termList = StandardTokenizer.segment("什么是糖尿病");
// System.out.println(termList);
// String sickname = search_edit.getText().toString();
// Search search = new Search(sickname);
// new Thread(new Runnable() {
// @Override
// public void run() {
// SearchContent.a = search.search();
// SearchContent.k = 1;
//
// }
// }).start();
// while(SearchContent.k==0) {Log.i("i","i");}
// if(SearchContent.a!=null){
// String[] medicines = a.get(0).toArray(new String[0]);
// String[] reasons = a.get(1).toArray(new String[0]);
// ListView lv = getActivity().findViewById(R.id.listView1);
// ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,medicines);
// lv.setAdapter(adapter);
//
// }
// SearchContent.k=0;
// SearchContent.a=null;
//
//
// }
// });
}
}

@ -0,0 +1,178 @@
package com.example.cmknowledgegraph;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.example.ChatContentPkg.RecyclerViewFragment;
import com.github.florent37.materialviewpager.MaterialViewPager;
import com.github.florent37.materialviewpager.header.HeaderDesign;
public class tt extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat);
// Toolbar toolbar = findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
//
// FloatingActionButton fab = findViewById(R.id.fab);
// fab.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
// .setAction("Action", null).show();
// }
// });
// BoomMenuButton bmb = findViewById(R.id.bmb);
// for (int i=0;i<bmb.getPiecePlaceEnum().pieceNumber();i++){
// SimpleCircleButton.Builder builder = new SimpleCircleButton.Builder()
// .normalImageRes(R.drawable.draw1)//设置点开的图片
// // 设置阴影
//// .shadowEffect(true)
//// .shadowOffsetX(20).shadowOffsetY(0)
//// .shadowRadius(Util.dp2px(20))
//// .shadowCornerRadius(Util.dp2px(20))
//// .shadowColor(Color.parseColor("#ee000000"))
//// 设置图片
//
// .highlightedImageRes(R.drawable.draw3)//点开某个按钮后突变的图片
// .unableImageRes(R.drawable.draw3)//unable时候的图片
// .imageRect(new Rect(Util.dp2px(10), Util.dp2px(10), Util.dp2px(70), Util.dp2px(70)))
// .imagePadding(new Rect(0, 0, 0, 0))
// .buttonCornerRadius(Util.dp2px(20))
//// .unable(true),默认是假的
//// 设置按钮样式
// ;
// bmb.addBuilder(builder);
// }
// final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb);
// final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();
// models.add(
// new NavigationTabBar.Model.Builder(
// getResources().getDrawable(R.drawable.draw3),
// Color.parseColor("red")
// ).title("论坛").badgeTitle("NTB").build());
// models.add(
// new NavigationTabBar.Model.Builder(
// getResources().getDrawable(R.drawable.draw1),
// Color.parseColor("blue")
// ).title("drug").badgeTitle("drug").build()
// );
// navigationTabBar.setModels(models);
// ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
// viewPager.setAdapter(new PagerAdapter() {
// @Override
// public int getCount() {
// return 0;
// }
//
// @Override
// public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
// return false;
// }
// });
// navigationTabBar.setViewPager(viewPager,2);
// navigationTabBar.setTitleMode(NavigationTabBar.TitleMode.ACTIVE);
// navigationTabBar.setBadgeGravity(NavigationTabBar.BadgeGravity.BOTTOM);
// navigationTabBar.setBadgePosition(NavigationTabBar.BadgePosition.CENTER);
//
// navigationTabBar.setIsBadged(true);
// navigationTabBar.setIsTitled(true);
// navigationTabBar.setIsTinted(true);
// navigationTabBar.setIsBadgeUseTypeface(true);
// navigationTabBar.setBadgeBgColor(Color.RED);
// navigationTabBar.setBadgeTitleColor(Color.WHITE);
// navigationTabBar.setIsSwiped(true);
// navigationTabBar.setBgColor(Color.BLACK);
// navigationTabBar.setBadgeSize(10);
// navigationTabBar.setTitleSize(10);
// navigationTabBar.setIconSizeFraction((float) 0.5);
//得到MaterviewPager实例
MaterialViewPager materialViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
//为MaterialViewPager添加监听
materialViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {
@Override
public HeaderDesign getHeaderDesign(int page) {
switch (page){
case 0:
return HeaderDesign.fromColorResAndUrl(
R.color.blue,
getResources().getDrawable(R.drawable.draw1).toString()
);
case 1:
return HeaderDesign.fromColorResAndUrl(
R.color.green,
getResources().getDrawable(R.drawable.draw2).toString()
);
case 2:
return HeaderDesign.fromColorResAndUrl(
R.color.cyan,
getResources().getDrawable(R.drawable.draw3).toString()
);
}
return null;
}
});
//设置Toolbar
Toolbar toolbar = materialViewPager.getToolbar();
if(toolbar!=null){
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setHomeButtonEnabled(true);
}
//为Viewpager设置适配器
ViewPager viewPager = materialViewPager.getViewPager();
viewPager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {
@NonNull
@Override
public Fragment getItem(int position) {
switch (position % 3){
case 0:
return RecyclerViewFragment.newInstance();
default:
return RecyclerViewFragment.newInstance();
}
}
@Override
public int getCount() {
return 3;
}
@Nullable
@Override
public CharSequence getPageTitle(int position) {
switch (position % 3){
case 0:
return "TAP1";
default:
return "TAPN";
}
}
});
materialViewPager.getViewPager().setOffscreenPageLimit(materialViewPager
.getViewPager().getAdapter().getCount());
materialViewPager.getPagerTitleStrip().setViewPager(materialViewPager.getViewPager());
}
}

@ -0,0 +1,14 @@
package com.example.tools;
public class retuData {
public String msg;//接受消息码
public Object data;//接受数据
public void setMsg(String msg) {
this.msg = msg;
}
public void setData(Object data) {
this.data = data;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="5dip"/>
<solid android:color="#ffffff"/>
</shape>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<corners android:radius="60dip" />
<solid android:color="#ffffff" />
</shape>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
>
<corners android:radius="50dip"/>
<stroke
android:width="1dip"
android:color="#ffffff" />
</shape>

@ -1,91 +1,78 @@
<?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"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".LoginActivity">
android:background="#7adfb8"
tools:context=".LoginActivity" >
<include
android:id="@+id/main_title"
layout="@layout/title_layout" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:layout_marginLeft="60dp">
android:layout_below="@+id/main_title"
android:orientation="vertical" >
<ImageView
android:layout_width="55dip"
android:layout_height="55dip"
android:layout_gravity="center_horizontal"
android:src="@drawable/project_detail_cir" />
<TextView
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="账号"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:textSize="20dp"
android:textColor="#35302D"/>
<EditText
android:id="@+id/id_edit"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:inputType="number"/>
android:layout_marginTop="5dip"
android:gravity="center"
android:text="FIREFLY FOREST"
android:textColor="#ffffff"
android:textSize="24sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="60dp">
<TextView
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="密码"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:textSize="20dp"
android:textColor="#8B4513"/>
<EditText
android:id="@+id/password_edit"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:inputType="textPassword"/>
android:gravity="center"
android:text="SHOW YOUR IDEAS"
android:textColor="#ffffff"
android:textSize="16sp" />
</LinearLayout>
<Button
android:id="@+id/login_btn"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:text="登录"
android:textSize="20dp"
android:background="#FFDAB9"
android:layout_marginTop="30dp"
android:layout_marginLeft="70dp"/>
<LinearLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="忘记密码?"
android:textSize="15dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="70dp"
android:textColor="#8B4513"/>
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
<include
android:id="@+id/input_layout"
android:layout_width="match_parent"
android:layout_height="250dip"
layout="@layout/input_layout" />
<include
android:id="@+id/layout_progress"
android:layout_width="match_parent"
android:layout_height="130dip"
layout="@layout/layout_progress"
android:visibility="gone" />
<TextView
android:id="@+id/register_text"
android:id="@+id/main_btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="注册"
android:textSize="17dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="180dp"
android:textColor="#8B4513"/>
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/login_pic"/>
android:layout_below="@+id/input_layout"
android:layout_centerInParent="true"
android:layout_marginTop="15dip"
android:background="@drawable/text_bg"
android:gravity="center"
android:paddingBottom="2dip"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:paddingTop="2dip"
android:text="Login"
android:textColor="#ffffff"
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

@ -7,30 +7,66 @@
android:orientation="vertical"
tools:context=".SearchActivity">
<LinearLayout
<com.yalantis.jellytoolbar.widget.JellyToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="101dp">
<EditText
android:id="@+id/search_edit"
android:layout_width="250dp"
android:background="@color/colorPrimary"
app:cancelIcon="@drawable/ic_close"
app:endColor="@color/colorEnd"
app:icon="@drawable/ic_search"
app:startColor="@color/colorStart"
app:title="@string/str_news_feed"
app:titleTextColor="@android:color/white" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:layout_marginTop="10dp"
android:paddingBottom="15dp"
android:text="糖尿病怎么办"
android:textColor="#C0C0C0"
android:textSize="40px"
/>
android:orientation="vertical">
<ImageButton
android:id="@+id/search_btn"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="10dp"
android:src="@mipmap/search"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:src="@drawable/content" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:src="@drawable/content" />
</LinearLayout>
</ScrollView>
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="101dp">-->
<!-- <EditText-->
<!-- android:id="@+id/search_edit"-->
<!-- android:layout_width="250dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="80dp"-->
<!-- android:layout_marginTop="10dp"-->
<!-- android:paddingBottom="15dp"-->
<!-- android:text="糖尿病怎么办"-->
<!-- android:textColor="#C0C0C0"-->
<!-- android:textSize="40px"-->
<!-- />-->
<!-- <ImageButton-->
<!-- android:id="@+id/search_btn"-->
<!-- android:layout_width="50dp"-->
<!-- android:layout_height="50dp"-->
<!-- android:layout_marginLeft="10dp"-->
<!-- android:src="@mipmap/search"/>-->
</LinearLayout>
<!-- </LinearLayout>-->
<GridLayout

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.AppCompatEditText xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorTransparent"
android:lines="1"
android:textColor="#7fffffff" />

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dip"
android:background="@drawable/radius_drawable_bg"
android:orientation="vertical"
android:padding="20dip" >
<LinearLayout
android:id="@+id/id_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/paw_code" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:background="#00000000"
android:hint="账号/用户名/邮箱"
android:textColor="@color/cyan"
android:padding="5dip"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="10px"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:background="#eeeeee" />
<LinearLayout
android:id="@+id/password_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/paw_left" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:background="#00000000"
android:hint="密码"
android:inputType="textPassword"
android:padding="5dip"
android:textSize="16sp"
android:textColor="@color/cyan"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="20dip"
android:background="@drawable/rotate_layout_bg"
android:orientation="vertical"
android:padding="10dip" >
<ProgressBar
android:id="@+id/progressBar2"
android:layout_width="wrap_content"
android:layout_margin="10dip"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dip"
android:gravity="center_vertical"
android:padding="10dip" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/back" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:textSize="20sp"
android:text="Sign up"
/>
</RelativeLayout>

@ -3,4 +3,7 @@
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="colorTransparent">#00ffffff</color>
<color name="colorStart">#cb5ed9</color>
<color name="colorEnd">#8463d4</color>
</resources>

@ -0,0 +1,5 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>

@ -1,3 +1,4 @@
<resources>
<string name="app_name">CMKnowledgeGraph</string>
<string name="str_news_feed">News feed</string>
</resources>

Loading…
Cancel
Save