Merge branch 'develop'

This commit is contained in:
ScorpioMiku
2018-09-08 21:52:51 +08:00
12 changed files with 514 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
## 营养大师
一款基于数据分析的智能饮食推荐APP

View File

@@ -66,4 +66,7 @@ dependencies {
implementation 'com.android.support:cardview-v7:26.1.0'
//混合式recyclerview
compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.30'
//翻页view
compile 'com.github.czy1121:turncardlistview:1.0.0'
}

View File

@@ -17,9 +17,11 @@
<!-- 相机权限 -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
@@ -42,7 +44,9 @@
<receiver
android:name=".step.StepStarter"
android:enabled="true"
android:exported="true"></receiver>
android:exported="true" />
<activity android:name=".modules.addinformation.AddActivity"></activity>
</application>
</manifest>

View File

@@ -11,6 +11,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.ToxicBakery.viewpager.transforms.CubeOutTransformer;
@@ -19,6 +20,7 @@ import com.example.ninefourone.nutritionmaster.R;
import com.example.ninefourone.nutritionmaster.adapter.HomePagerAdapter;
import com.example.ninefourone.nutritionmaster.base.BaseActivity;
import com.example.ninefourone.nutritionmaster.camera.FoodMaterialCamera;
import com.example.ninefourone.nutritionmaster.modules.addinformation.AddActivity;
import com.example.ninefourone.nutritionmaster.ui.NoScrollViewPager;
import com.example.ninefourone.nutritionmaster.utils.MessageUtils;
import com.example.ninefourone.nutritionmaster.utils.PermissionUtils;
@@ -81,6 +83,8 @@ public class MainActivity extends BaseActivity {
BoomMenuButton boomMenuButton;
@BindView(R.id.spider_view)
RadarChart spiderView;
@BindView(R.id.add_information_button)
ImageView addInformationButton;
@Override
@@ -166,13 +170,11 @@ public class MainActivity extends BaseActivity {
}
//mDrawer.openMenu();
/**
* 点击事件
*/
@OnClick(R.id.navigation_layout)
public void onViewClicked() {
mDrawer.openMenu();
}
/**
@@ -305,4 +307,17 @@ public class MainActivity extends BaseActivity {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
MessageUtils.MakeToast("权限赋予成功");
}
@OnClick({R.id.navigation_layout, R.id.add_information_button})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.navigation_layout:
mDrawer.openMenu();
break;
case R.id.add_information_button:
Intent intent = new Intent(MainActivity.this, AddActivity.class);
startActivity(intent);
break;
}
}
}

View File

@@ -0,0 +1,166 @@
package com.example.ninefourone.nutritionmaster.modules.addinformation;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.example.ninefourone.nutritionmaster.R;
import com.example.ninefourone.nutritionmaster.utils.ConstantUtils;
import com.example.ninefourone.nutritionmaster.utils.MessageUtils;
import com.github.czy1121.view.TurnCardListView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class AddActivity extends AppCompatActivity {
@BindView(R.id.card_list)
TurnCardListView cardList;
@BindView(R.id.bottom_content)
RelativeLayout bottomContent;
@BindView(R.id.back_button)
ImageView backButton;
@BindView(R.id.result_layout)
CardView resultLayout;
// private int[] colors = {0xff3F51B5, 0xff673AB7, 0xff006064, 0xffC51162, 0xffFFEB3B, 0xff795548, 0xff9E9E9E};
private int[] colors = {0xffdef6f9, 0xffd6eeec, 0xffB2EBF2, 0xffB2DFDB, 0xff8ed0ca, 0xff80CBC4, 0xff4DB6AC, 0xff3c948b};
private Button[] firstButtons = new Button[ConstantUtils.questionList.length];
private Button[] secondButtons = new Button[ConstantUtils.questionList.length];
private Button[] thirdButtons = new Button[ConstantUtils.questionList.length];
private TextView[] titleViews = new TextView[ConstantUtils.questionList.length];
private Button[][] buttonList;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
//设置全屏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add);
ButterKnife.bind(this);
buttonList = new Button[][]{
firstButtons,
secondButtons,
thirdButtons
};
initAddView();
}
private void initAddView() {
BaseAdapter adapter = new BaseAdapter() {
@Override
public int getCount() {
return colors.length;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View child, ViewGroup parent) {
child = LayoutInflater.from(parent.getContext()).inflate(R.layout.add_item, parent, false);
child.findViewById(R.id.image).setBackgroundColor(colors[position]);
titleViews[position] = child.findViewById(R.id.title_view);
titleViews[position].setText(ConstantUtils.questionList[position]);
firstButtons[position] = child.findViewById(R.id.choose_first);
firstButtons[position].setBackgroundColor(colors[position] + 30);
secondButtons[position] = child.findViewById(R.id.choose_second);
secondButtons[position].setBackgroundColor(colors[position] + 30);
thirdButtons[position] = child.findViewById(R.id.choose_third);
thirdButtons[position].setBackgroundColor(colors[position] + 30);
if (position != ConstantUtils.questionList.length - 1) {
firstButtons[position].setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
firstButtons[position].setBackgroundColor(colors[position] - 60);
secondButtons[position].setBackgroundColor(colors[position] + 30);
thirdButtons[position].setBackgroundColor(colors[position] + 30);
cardList.turnTo(position + 1);
}
});
} else {
firstButtons[position].setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resultLayout.setVisibility(View.VISIBLE);
}
});
}
secondButtons[position].setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
firstButtons[position].setBackgroundColor(colors[position] + 30);
thirdButtons[position].setBackgroundColor(colors[position] + 30);
secondButtons[position].setBackgroundColor(colors[position] - 60);
cardList.turnTo(position + 1);
}
});
thirdButtons[position].setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
firstButtons[position].setBackgroundColor(colors[position] + 30);
secondButtons[position].setBackgroundColor(colors[position] + 30);
thirdButtons[position].setBackgroundColor(colors[position] - 60);
cardList.turnTo(position + 1);
}
});
for (int i = 0; i < ConstantUtils.answerList[position].length; i++) {
buttonList[i][position].setText(ConstantUtils.answerList[position][i]);
buttonList[i][position].setVisibility(View.VISIBLE);
}
return child;
}
};
cardList.setAdapter(adapter);
cardList.setOnTurnListener(new TurnCardListView.OnTurnListener() {
@Override
public void onTurned(int position) {
bottomContent.setBackgroundColor(colors[position] - 60);
}
});
}
@OnClick(R.id.back_button)
public void onViewClicked() {
finish();
}
}

View File

@@ -28,4 +28,27 @@ public class ConstantUtils {
}
}
public static String[] questionList = new String[]{
"现在先去找个镜子吧" +
"\n下面会用到哦",
"你舌苔的颜色",
"舌底经络颜色",
"口腔整体情况",
"整体生活精神状况",
"性格特点",
"食物温度偏向",
"揭晓结果"
};
public static String[][] answerList = new String[][]{
{"开始吧"},
{"偏暗红", "偏白", "淡红"},
{"暗红", "细红", "不明显"},
{"口舌干燥", "口黏苔腻", "还算正常"},
{"沉寂易疲劳", "精力充沛"},
{"内向", "开朗"},
{"烫的", "冷的", "没有特别喜欢的"},
{"查看"}
};
}

View File

@@ -0,0 +1,4 @@
<vector android:height="24dp" android:viewportHeight="1024.0"
android:viewportWidth="1024.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#2c2c2c" android:pathData="M228.9,535.7l238.5,238.5a51.2,51.2 0,0 1,-72.4 72.4L69.1,520.8a51.1,51.1 0,0 1,-9.7 -13.5,51.2 51.2,0 0,1 6.8,-64.1l325.8,-325.8A51.2,51.2 0,1 1,464.4 189.8L220.9,433.3H888.8a51.2,51.2 0,0 1,0 102.4H228.9z"/>
</vector>

View File

@@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="1024.0"
android:viewportWidth="1024.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ffffff" android:pathData="M512,967.1A455.1,455.1 0,1 0,512 56.9a455.1,455.1 0,0 0,0 910.2zM512,1024A512,512 0,1 1,512 0a512,512 0,0 1,0 1024z"/>
<path android:fillColor="#ffffff" android:pathData="M712.2,606.7c-69.3,-16.3 -104.8,-55.1 -110.9,-63.2 -6.1,-8.2 -6.1,-18.4 -6.1,-30.6 0,-4.1 2,-10.2 4.1,-14.2l2,-4.1c2,-4.1 10.1,-24.5 16.3,-36.8 0,-2 4,-8.2 8.1,-12.2 6.1,-4.1 12.2,-10.2 22.4,-22.4 16.3,-24.5 8.2,-46.9 -6.1,-57.1v-4c8.1,-22.5 12.2,-48.9 10.2,-81.6 -2.1,-34.7 -34.7,-87.7 -118.3,-87.7 -83.6,0 -116.2,51 -118.2,87.7 -2,32.6 2,59.1 10.2,79.5V364.1c-14.3,12.3 -20.5,34.7 -6.1,59.2 8.1,12.2 16.3,18.3 22.4,22.4 4.1,4.1 8.2,10.2 8.2,12.2 6.1,12.3 14.3,30.6 16.3,36.8l2,4c2,6.1 4,10.2 4,14.2 0,10.2 0,22.5 -6.1,30.7 -6.1,8.1 -40.8,46.9 -110.1,63.1 -61.2,14.3 -100.7,49.3 -100.7,129.8 0,4.1 4.1,10.2 10.2,10.2h533.7c4,0 10.2,-4.1 10.2,-10.2 0,-84.5 -34.7,-115.5 -97.8,-129.7z"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

View File

@@ -0,0 +1,211 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/bottom_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#b0ce93"
tools:context="com.example.ninefourone.nutritionmaster.modules.addinformation.AddActivity">
<com.github.czy1121.view.TurnCardListView
android:id="@+id/card_list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.github.czy1121.view.TurnCardListView>
<ImageView
android:id="@+id/back_button"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:src="@drawable/ic_back_button" />
<android.support.v7.widget.CardView
android:id="@+id/result_layout"
android:layout_width="300dp"
android:layout_height="450dp"
android:layout_centerInParent="true"
android:visibility="gone"
app:cardCornerRadius="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/result_bg"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="30dp"
android:gravity="center"
android:orientation="horizontal">
<com.github.siyamed.shapeimageview.CircularImageView
android:layout_width="100dp"
android:layout_height="100dp"
tools:src="@drawable/test_avatar" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:textStyle="bold"
tools:text="淤血质" />
</LinearLayout>
<android.support.v7.widget.CardView
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_gravity="center"
app:cardBackgroundColor="#95def4">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="常见表现"
android:textSize="10sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@color/place_holder" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:textSize="8sp"
tools:text="平素面色晦暗,皮肤偏暗或色素沉着,容易出现瘀斑,易患疼痛,口唇暗淡或紫,舌质暗有点、片状瘀斑,舌下静脉曲张。眼眶暗黑,鼻部暗滞,发易脱落,皮肤发干,或有出血倾向、吐血,女性多见痛经、闭经、或经血中多有血块,或经色紫黑有块。" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="特点"
android:textSize="10sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@color/place_holder" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:textSize="8sp"
tools:text="瘀血质的人,血行不畅,临床常呈现肤色晦暗、色素沉着、瘀斑、性格抑郁、健忘,舌质紫黯或有瘀点、舌下络脉紫黯或增粗,脉涩。易患痛证、血证、症瘕等。" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="心理特征"
android:textSize="10sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@color/place_holder" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:textSize="8sp"
tools:text="性情急躁,心情易烦,健忘。" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="注意事项"
android:textSize="10sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@color/place_holder" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:textSize="8sp"
tools:text="瘀血质气机失调,血行不畅,应慎食雪糕、冰淇淋、冰冻饮料等寒凉之品,以免影响气血运行。保持心情舒畅,是淤血质调理的重要环节" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>

View File

@@ -193,6 +193,7 @@
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/information_layout"
android:layout_width="110dp"
android:layout_height="match_parent"
android:gravity="center"
@@ -227,6 +228,15 @@
android:layout_marginEnd="10dp"
android:alpha="0.2"
android:src="@drawable/icon_black" />
<ImageView
android:id="@+id/add_information_button"
android:layout_width="23dp"
android:layout_height="23dp"
android:layout_alignParentRight="true"
android:layout_marginRight="25dp"
android:layout_marginTop="15dp"
android:src="@drawable/ic_data_add" />
</RelativeLayout>
</LinearLayout>

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 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="300dp"
android:layout_height="450dp"
android:layout_gravity="center"
app:cardCornerRadius="20dp">
<LinearLayout
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_margin="20dp"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/title_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/app_name"
android:textSize="17sp" />
</LinearLayout>
<Button
android:id="@+id/choose_first"
android:layout_width="150dp"
android:layout_height="50dp"
android:text="测试"
android:textSize="13sp"
android:visibility="gone">
</Button>
<Button
android:id="@+id/choose_second"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_marginTop="20dp"
android:text="测试"
android:textSize="13sp"
android:visibility="gone">
</Button>
<Button
android:id="@+id/choose_third"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_marginTop="20dp"
android:text="测试"
android:textSize="13sp"
android:visibility="gone">
</Button>
</LinearLayout>
</android.support.v7.widget.CardView>