Merge remote-tracking branch 'origin/master'

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

@ -117,9 +117,9 @@
<orderEntry type="library" name="Gradle: androidx.constraintlayout:constraintlayout-solver:1.1.3@jar" level="project" />
<orderEntry type="library" name="Gradle: com.alibaba:fastjson:1.2.62@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.material:material:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.cardview:cardview:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.loopeer.library:cardstack:1.0.2@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.appcompat:appcompat:1.0.2@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.cardview:cardview:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.fragment:fragment:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.vectordrawable:vectordrawable-animated:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.recyclerview:recyclerview:1.0.0@aar" level="project" />

@ -14,7 +14,6 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".SearchContentActivity"></activity>
<activity android:name=".SearchEntryActivity" />
<activity android:name=".PersonalityCenterActivity" />
<activity android:name=".LoginActivity" />

@ -1,10 +1,8 @@
package com.example.PersonalCenter;
import android.util.Log;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@ -20,14 +18,15 @@ 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";
String address="/rest/cmkg/question/hello";
String Url = "http://localhost:8080"+address;
String Url = "http://114.116.199.154:5000"+address;
String path = Url + "?name="+name;
URL url = null;
try {
@ -52,7 +51,7 @@ public class SearchServiceGet {
//开始解析返回的数据
JSONObject jo=JSONObject.fromObject(response.toString());
int code=jo.getInt("code");
code=jo.getInt("code");
if(code!=0){ //查询成功,在开始解析数据
name_back=jo.getString("message");//查询的主语
//把data看作一个JSONObject无论里面由多少元素都转换为JSONArray存在数组里
@ -87,4 +86,15 @@ public class SearchServiceGet {
// return "";
}
public static void exxcuteTest(String name){
code=100;
name_back="糖尿病";
content.add("jjfkdjfkjklfjdklsjfklasjflksjflsjfdlsjfdklsjfklsjfklsjfkldjsafl;das"
+"FJDKSLDJFKLDSKLFJDSKLAJFKLDSAJFKLDASJFKLDSAJFKLDSAJFKLDASJFKLDASJFKLDASJFKLDASJFL"
+"FNDFJDJFKLDSJFKLDSJFIOWUIORUEJGKLDKLGDKSLFJKDLSAJFKLD;SA");
content.add("dddddddd反馈i惹我给i偶i哦好v考虑的设计规范房价的快速了解法拉盛覅柔儿一个可能"
+"fdighreioghi飞机迪斯科飞机俄欧分工i热i购房贷款了JFK逻辑非我");
}
}

@ -12,18 +12,20 @@ import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.PersonalCenter.SearchServiceGet;
import com.loopeer.cardstack.CardStackView;
import com.loopeer.cardstack.StackAdapter;
import java.util.List;
public class CMKGStackAdapter extends StackAdapter<Integer> {
public class CMKGStackAdapter extends StackAdapter<Integer> implements ConditionCode{
List<List<LessonData>> lessonList;
List<List<ContentData>> contentList;
/**
*
*
*/
static int title_num=0;//标题的数目
public CMKGStackAdapter(Context context)
{
super(context);
@ -55,17 +57,17 @@ public class CMKGStackAdapter extends StackAdapter<Integer> {
* @param data
* @param lessonList
*/
public void updateData(List data, List<List<LessonData>> lessonList) {
this.lessonList = lessonList;
public void updateData(List data, List<List<ContentData>> lessonList) {
this.contentList = lessonList;
updateData(data);
System.out.println("Updata!");
System.out.println("Updata!*****************************");
}
public void bindView(Integer data, int position, CardStackView.ViewHolder holder) {
if(holder instanceof CardViewHolder)
{
CardViewHolder cardHolder = (CardViewHolder)holder;
cardHolder.onBind(data,position,lessonList);
cardHolder.onBind(data,position,contentList);
}
System.out.println("bindView");
}
@ -92,12 +94,28 @@ public class CMKGStackAdapter extends StackAdapter<Integer> {
System.out.println("CardViewHolder constructor");
}
public void onBind(Integer backgroundColorId,int position,List<List<LessonData>> dataList)
public void onBind(Integer backgroundColorId,int position,List<List<ContentData>> dataList)
{
/*
bindView ViewHolderbindViewViewHolderonBind使
*/
/**
* v -
* * -
* * -
* * -
*/
if(SearchServiceGet.code==DiseaseToSymptom||SearchServiceGet.code==MedicineToOperation||SearchServiceGet.code==MedicineToSymptom){
//对应病症,那么标题只有一个就是病的名字
titleText.setText(SearchServiceGet.name_back);
}else {
//对应治疗方法,那么标题就要有多个
titleText.setText(SearchServiceGet.content.get(title_num));
title_num++;
}
cardTitle.getBackground().setColorFilter(ContextCompat.getColor(getContext(),backgroundColorId), PorterDuff.Mode.SRC_IN);//传入的int值其实是一个颜色在这里改变头部的颜色
System.out.println("========================"+position);
ListAdapter adapter = new ListAdapter(dataList.get(position));
scoreList.setLayoutManager(new LinearLayoutManager(getContext()));
scoreList.setAdapter(adapter);

@ -2,6 +2,12 @@ package com.example.cmknowledgegraph;
public interface ConditionCode {
/**
* DiseaseToSymptom
* DiseaseToMedeicines
* MedicineToOperation
* MedicineToSympton
*/
public final int DiseaseToSymptom=100;
public final int DiseaseToMedicines=200;
public final int MedicineToOperation=300;

@ -2,11 +2,12 @@ package com.example.cmknowledgegraph;
public class ContentData {
/**
*
*/
private String contentdata;
public ContentData(String content) {
this.contentdata = content;
}
public String getContentdata() {
return contentdata;
}
@ -15,3 +16,4 @@ public class ContentData {
this.contentdata = contentdata;
}
}

@ -1,28 +0,0 @@
package com.example.cmknowledgegraph;
public class LessonData {
String lessonName;
String lessonScore;
public LessonData(String lessonName, String lessonScore) {
this.lessonName = lessonName;
this.lessonScore = lessonScore;
}
public String getLessonName() {
return lessonName;
}
public void setLessonName(String lessonName) {
this.lessonName = lessonName;
}
public String getLessonScore() {
return lessonScore;
}
public void setLessonScore(String lessonScore) {
this.lessonScore = lessonScore;
}
}

@ -13,40 +13,27 @@ import java.util.List;
* Created by LZL on 2017/7/16.
*/
public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ScoresViewHodler> {
List<LessonData> scores_list;
public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ScoresViewHodler> implements ConditionCode{
List<ContentData> content_list;
public ListAdapter(List<LessonData> list)
public ListAdapter(List<ContentData> list)
{
scores_list = list;
content_list = list;
}
public static class ScoresViewHodler extends RecyclerView.ViewHolder
{
TextView name; //课程名称
TextView high_scores; //最高分
TextView daily_scores; //平时成绩
TextView type; //课程类型
TextView credit; //学分
TextView middle_scores; //期中成绩
TextView final_scores; //期末成绩
TextView search_content; //内容
public ScoresViewHodler(View view)
{
super(view);
name = (TextView)view.findViewById(R.id.scores_lesson_name);
high_scores = (TextView)view.findViewById(R.id.scores_lesson_score);
daily_scores = (TextView)view.findViewById(R.id.scores_lesson_pingshi);
type = (TextView)view.findViewById(R.id.scores_lesson_type);
credit = (TextView)view.findViewById(R.id.scores_lesson_xf);
middle_scores = (TextView)view.findViewById(R.id.scores_lesson_qzcj);
final_scores = (TextView)view.findViewById(R.id.scores_lesson_qmcj);
search_content=(TextView)view.findViewById(R.id.search_content);
}
}
@Override
public void onBindViewHolder(ScoresViewHodler holder, int position) {
holder.name.setText(scores_list.get(position).getLessonName());
holder.high_scores.setText(scores_list.get(position).getLessonScore());
holder.search_content.setText(content_list.get(position).getContentdata());
}
@Override
@ -57,6 +44,6 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ScoresViewHodl
@Override
public int getItemCount() {
return scores_list.size();
return content_list.size();
}
}

@ -36,7 +36,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
Log.i("haha", "=======Oncli");
// //点击查找按钮之后,取出输入的句子,传给后台
String inputContent = search_edit.getText().toString();
SearchServiceGet.executeSearchGet(inputContent);
// SearchServiceGet.executeSearchGet(inputContent);
SearchServiceGet.exxcuteTest(inputContent);
// //执行到这里已经把data里的数据取出来了或没有但是都要跳转页面到SearchEntryActivity页面
Intent intent = new Intent();
intent.setClass(getActivity(), SearchEntryActivity.class);

@ -1,52 +0,0 @@
package com.example.cmknowledgegraph;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.TypedValue;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.example.PersonalCenter.SearchServiceGet;
public class SearchContentActivity extends AppCompatActivity {
/**
* SearchEntryActivity
* intent访map
*
* @param savedInstanceState
*/
int left=50,top=80,right=500,bottom=100;
int gap=20;//内容与内容的间隔
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search_content);
TextView text_title=findViewById(R.id.search_content);
//设置内容的标题,位置,大小
String label_name=getIntent().getStringExtra("label").toString();
text_title.setPadding(left,top,bottom,right);
text_title.setText(label_name);
text_title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
text_title.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
//遍历label和content的队列显示内容
for(int i=1;i< SearchServiceGet.label.size();i++){
TextView text_label=findViewById(R.id.search_content);
text_label.setText(SearchServiceGet.label.get(i));
text_label.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
text_label.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
text_label.setPadding(left,gap,bottom,right);
TextView text_content=findViewById(R.id.search_content);
text_content.setText(SearchServiceGet.content.get(i));
text_content.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
text_content.setPadding(left,gap,bottom,right);
}
}
}

@ -4,6 +4,7 @@ import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.example.PersonalCenter.SearchServiceGet;
import com.loopeer.cardstack.AllMoveDownAnimatorAdapter;
import com.loopeer.cardstack.CardStackView;
import com.loopeer.cardstack.UpDownAnimatorAdapter;
@ -13,16 +14,15 @@ import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class SearchEntryActivity extends AppCompatActivity implements CardStackView.ItemExpendListener{
public class SearchEntryActivity extends AppCompatActivity implements CardStackView.ItemExpendListener,ConditionCode{
Integer[] color = {
R.color.holo_blue_bright,
R.color.holo_orange_light,
R.color.holo_purple,
R.color.holo_red_light
// R.color.holo_purple,
// R.color.holo_red_light
};
//模拟数据
String[] name = {"数据结构","计算机网络","编译原理","C语言","算法设计","FPGA编程"};
String[] scores = {"77","87","65","98","74","80"};
@Override
@ -42,6 +42,7 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
mCardStack.setAdapter(adapter);
mCardStack.setItemExpendListener(this);
/**
*
* 便items
@ -52,17 +53,55 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
*
*
*/
List<List<LessonData>> lists = new LinkedList<>();
for(int i = 0;i<4;i++)
{
List<LessonData> list = new LinkedList<>();
for(int j = 0;j<6;j++)
{
list.add(new LessonData(name[j],scores[j]));
List<List<ContentData>> lists=new LinkedList<>();
if(SearchServiceGet.code==DiseaseToSymptom){
/**
* //返回的是病症
* listslist
*/
for(int i=0;i<SearchServiceGet.content.size();i++){
List<ContentData> list=new LinkedList<>();
list.add(new ContentData(SearchServiceGet.content.get(i)));
lists.add(list);
}
}else if(SearchServiceGet.code==DiseaseToMedicines){
/**
* //返回的是结解决的多种药品方法
*
*/
List<ContentData> list=new LinkedList<>();
for(int i=0;i<SearchServiceGet.content.size();i++){
list.add(new ContentData("我是您的用法哦~请您看看我嘞"));
lists.add(list);
}
}else if(SearchServiceGet.code==MedicineToOperation) {
/**
* //返回的是药的用法
* //标题就是药品的名字,内容是用法
*/
for(int i=0;i<SearchServiceGet.content.size();i++){
List<ContentData> list=new LinkedList<>();
list.add(new ContentData(SearchServiceGet.content.get(i)));
lists.add(list);
}
}else{
/**
* //返回的是药的主治症状
*
*/
for(int i = 0; i< SearchServiceGet.content.size(); i++){
List<ContentData> list=new LinkedList<>();
list.add(new ContentData(SearchServiceGet.content.get(i)));
lists.add(list);
}
lists.add(list);
}
adapter.updateData(Arrays.asList(color),lists);
mCardStack.setAnimatorAdapter(new AllMoveDownAnimatorAdapter(mCardStack));
mCardStack.setAnimatorAdapter(new UpDownAnimatorAdapter(mCardStack));

@ -25,6 +25,7 @@
android:textColor="#ffffff"
android:id="@+id/card_title_text"
/>
</FrameLayout>
<!-- android:text="2016-2017-2学期"-->
<FrameLayout

@ -16,78 +16,78 @@
android:layout_height="match_parent"
android:background="@null"
>
<TextView
android:id="@+id/scores_lesson_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginLeft="60dp"
android:layout_marginStart="60dp"
android:textSize="15sp"
android:text="数据结构"
android:textColor="@color/text_black"
/>
<TextView
android:text="最高成绩98"
style="@style/scores_item_style"
android:id="@+id/scores_lesson_score"
android:layout_alignLeft="@id/scores_lesson_name"
android:layout_alignStart="@id/scores_lesson_name"
android:layout_below="@id/scores_lesson_name"
android:layout_marginTop="10dp"
/>
<TextView
android:text="课程性质:必修课"
style="@style/scores_item_style"
android:layout_below="@id/scores_lesson_score"
android:layout_alignLeft="@id/scores_lesson_score"
android:layout_alignStart="@id/scores_lesson_score"
android:layout_marginTop="5dp"
android:id="@+id/scores_lesson_type"
/>
<TextView
android:text="平时成绩88"
style="@style/scores_item_style"
android:id="@+id/scores_lesson_pingshi"
android:layout_alignLeft="@id/scores_lesson_type"
android:layout_alignStart="@id/scores_lesson_type"
android:layout_below="@id/scores_lesson_type"
android:layout_marginTop="5dp"
/>
<TextView
android:text="学分4"
style="@style/scores_item_style"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignBottom="@id/scores_lesson_score"
android:layout_marginRight="95dp"
android:layout_marginEnd="95dp"
android:id="@+id/scores_lesson_xf"
/>
<TextView
android:text="期中成绩:88"
style="@style/scores_item_style"
android:layout_alignLeft="@id/scores_lesson_xf"
android:layout_alignStart="@id/scores_lesson_xf"
android:layout_alignBottom="@id/scores_lesson_type"
android:id="@+id/scores_lesson_qzcj"
/>
<TextView
android:text="期末成绩95"
style="@style/scores_item_style"
android:id="@+id/scores_lesson_qmcj"
android:layout_alignBottom="@id/scores_lesson_pingshi"
android:layout_alignLeft="@id/scores_lesson_qzcj"
android:layout_alignStart="@id/scores_lesson_qzcj"
/>
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@mipmap/picture"
android:layout_alignTop="@id/scores_lesson_name"
android:layout_marginLeft="25dp"
android:layout_marginStart="25dp"
/>
<!-- <TextView-->
<!-- android:id="@+id/scores_lesson_name"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="15dp"-->
<!-- android:layout_marginLeft="60dp"-->
<!-- android:layout_marginStart="60dp"-->
<!-- android:textSize="15sp"-->
<!-- android:text="数据结构"-->
<!-- android:textColor="@color/text_black"-->
<!-- />-->
<!-- <TextView-->
<!-- android:text="最高成绩98"-->
<!-- style="@style/scores_item_style"-->
<!-- android:id="@+id/scores_lesson_score"-->
<!-- android:layout_alignLeft="@id/scores_lesson_name"-->
<!-- android:layout_alignStart="@id/scores_lesson_name"-->
<!-- android:layout_below="@id/scores_lesson_name"-->
<!-- android:layout_marginTop="10dp"-->
<!-- />-->
<!-- <TextView-->
<!-- android:text="课程性质:必修课"-->
<!-- style="@style/scores_item_style"-->
<!-- android:layout_below="@id/scores_lesson_score"-->
<!-- android:layout_alignLeft="@id/scores_lesson_score"-->
<!-- android:layout_alignStart="@id/scores_lesson_score"-->
<!-- android:layout_marginTop="5dp"-->
<!-- android:id="@+id/scores_lesson_type"-->
<!-- />-->
<!-- <TextView-->
<!-- android:text="平时成绩88"-->
<!-- style="@style/scores_item_style"-->
<!-- android:id="@+id/scores_lesson_pingshi"-->
<!-- android:layout_alignLeft="@id/scores_lesson_type"-->
<!-- android:layout_alignStart="@id/scores_lesson_type"-->
<!-- android:layout_below="@id/scores_lesson_type"-->
<!-- android:layout_marginTop="5dp"-->
<!-- />-->
<!-- <TextView-->
<!-- android:text="学分4"-->
<!-- style="@style/scores_item_style"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:layout_alignParentEnd="true"-->
<!-- android:layout_alignBottom="@id/scores_lesson_score"-->
<!-- android:layout_marginRight="95dp"-->
<!-- android:layout_marginEnd="95dp"-->
<!-- android:id="@+id/scores_lesson_xf"-->
<!-- />-->
<!-- <TextView-->
<!-- android:text="期中成绩:88"-->
<!-- style="@style/scores_item_style"-->
<!-- android:layout_alignLeft="@id/scores_lesson_xf"-->
<!-- android:layout_alignStart="@id/scores_lesson_xf"-->
<!-- android:layout_alignBottom="@id/scores_lesson_type"-->
<!-- android:id="@+id/scores_lesson_qzcj"-->
<!-- />-->
<!-- <TextView-->
<!-- android:text="期末成绩95"-->
<!-- style="@style/scores_item_style"-->
<!-- android:id="@+id/scores_lesson_qmcj"-->
<!-- android:layout_alignBottom="@id/scores_lesson_pingshi"-->
<!-- android:layout_alignLeft="@id/scores_lesson_qzcj"-->
<!-- android:layout_alignStart="@id/scores_lesson_qzcj"-->
<!-- />-->
<!-- <ImageView-->
<!-- android:layout_width="18dp"-->
<!-- android:layout_height="18dp"-->
<!-- android:src="@mipmap/picture"-->
<!-- android:layout_alignTop="@id/scores_lesson_name"-->
<!-- android:layout_marginLeft="25dp"-->
<!-- android:layout_marginStart="25dp"-->
<!-- />-->
<!--为了方便我们先不删除原有模板的items我们点开之后有几种情况
病-症状:标题是名字,内容是症状
病-治疗药品:标婷是药的名字,内容是药的用法(暂时不做)

Loading…
Cancel
Save