体质测评完成
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
android:enabled="true"
|
||||
android:exported="true" />
|
||||
|
||||
<activity android:name=".modules.addinformation.AddActivity" />
|
||||
<activity android:name=".modules.addinformation.AddPhysiqueActivity" />
|
||||
<activity android:name=".modules.viewpagerfragments.customization.CustomizationActivity" />
|
||||
<activity android:name=".modules.information.InformationActivity" />
|
||||
<activity android:name=".modules.RecipeActivity.RecipeActivity" />
|
||||
|
||||
@@ -14,6 +14,8 @@ import com.orhanobut.logger.AndroidLogAdapter;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Arrays;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
@@ -118,6 +120,7 @@ public class NutritionMaster extends Application {
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
Occupation[] occupations = new Gson().fromJson(response.body().string(), Occupation[].class);
|
||||
// Logger.d(Arrays.toString(occupations));
|
||||
for (int i = 0; i < occupations.length; i++) {
|
||||
ConstantUtils.occupationList.add(occupations[i].getOccupation_name());
|
||||
}
|
||||
|
||||
@@ -25,8 +25,9 @@ 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.modules.addinformation.AddPhysiqueActivity;
|
||||
import com.example.ninefourone.nutritionmaster.modules.addinformation.AddInformationActivity;
|
||||
import com.example.ninefourone.nutritionmaster.modules.information.InformationActivity;
|
||||
import com.example.ninefourone.nutritionmaster.ui.NoScrollViewPager;
|
||||
import com.example.ninefourone.nutritionmaster.utils.CalculateUtils;
|
||||
import com.example.ninefourone.nutritionmaster.utils.ConstantUtils;
|
||||
@@ -373,13 +374,12 @@ public class MainActivity extends BaseActivity {
|
||||
mDrawer.openMenu();
|
||||
break;
|
||||
case R.id.add_information_button:
|
||||
Intent intent = new Intent(MainActivity.this, AddActivity.class);
|
||||
Intent intent = new Intent(MainActivity.this, AddPhysiqueActivity.class);
|
||||
startActivity(intent);
|
||||
break;
|
||||
case R.id.information_layout:
|
||||
break;
|
||||
case R.id.user_occupation_text:
|
||||
|
||||
Intent informationIntent = new Intent(MainActivity.this, InformationActivity.class);
|
||||
startActivity(informationIntent);
|
||||
break;
|
||||
case R.id.adder_infor:
|
||||
Intent i = new Intent(MainActivity.this, AddInformationActivity.class);
|
||||
@@ -470,11 +470,11 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
float weightAverage = averageWeight / maxWeight * 100.0f;
|
||||
float weightSelf = weight / maxWeight * 100.0f;
|
||||
if (weightAverage>weightSelf){
|
||||
if (weightAverage > weightSelf) {
|
||||
weightBar.setMax(100);
|
||||
weightBar.setSecondaryProgress(weightAverage);
|
||||
weightBar.setProgress(weightSelf);
|
||||
}else{
|
||||
} else {
|
||||
weightBar.setMax(100);
|
||||
weightBar.setSecondaryProgress(weightSelf);
|
||||
weightBar.setProgress(weightAverage);
|
||||
|
||||
@@ -17,25 +17,35 @@ 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 com.orhanobut.logger.Logger;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class AddActivity extends AppCompatActivity {
|
||||
public class AddPhysiqueActivity 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.title)
|
||||
TextView title;
|
||||
@BindView(R.id.result_layout)
|
||||
CardView resultLayout;
|
||||
@BindView(R.id.bottom_content)
|
||||
RelativeLayout bottomContent;
|
||||
|
||||
|
||||
private String result = "";
|
||||
private String physique = "平和质";
|
||||
private float[] counter = {0, 0, 0, 0, 0, 0, 0, 0, -1};
|
||||
private String[] physiques = {"淤血质", "阴虚质", "阳虚质", "痰湿质", "湿热质", "气郁质", "气虚质", "平和质"};
|
||||
|
||||
// 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];
|
||||
@@ -85,7 +95,8 @@ public class AddActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public View getView(final int position, View child, ViewGroup parent) {
|
||||
|
||||
child = LayoutInflater.from(parent.getContext()).inflate(R.layout.add_item, parent, false);
|
||||
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]);
|
||||
@@ -110,14 +121,18 @@ public class AddActivity extends AppCompatActivity {
|
||||
secondButtons[position].setBackgroundColor(colors[position] + 30);
|
||||
thirdButtons[position].setBackgroundColor(colors[position] + 30);
|
||||
cardList.turnTo(position + 1);
|
||||
result += "1";
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
firstButtons[position].setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getResult();
|
||||
resultLayout.setVisibility(View.VISIBLE);
|
||||
cardList.setVisibility(View.INVISIBLE);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -128,6 +143,7 @@ public class AddActivity extends AppCompatActivity {
|
||||
thirdButtons[position].setBackgroundColor(colors[position] + 30);
|
||||
secondButtons[position].setBackgroundColor(colors[position] - 60);
|
||||
cardList.turnTo(position + 1);
|
||||
result += "2";
|
||||
}
|
||||
});
|
||||
thirdButtons[position].setOnClickListener(new View.OnClickListener() {
|
||||
@@ -137,6 +153,7 @@ public class AddActivity extends AppCompatActivity {
|
||||
secondButtons[position].setBackgroundColor(colors[position] + 30);
|
||||
thirdButtons[position].setBackgroundColor(colors[position] - 60);
|
||||
cardList.turnTo(position + 1);
|
||||
result += "3";
|
||||
}
|
||||
});
|
||||
|
||||
@@ -164,4 +181,186 @@ public class AddActivity extends AppCompatActivity {
|
||||
public void onViewClicked() {
|
||||
finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断体质
|
||||
*/
|
||||
private void getResult() {
|
||||
|
||||
float margin = 0.75f;
|
||||
|
||||
String code = result.substring(1);
|
||||
char[] codes = code.toCharArray();
|
||||
Logger.d(Arrays.toString(codes));
|
||||
|
||||
switch ((int) (codes[0]) - 48) {
|
||||
case 1:
|
||||
counter[0]++;
|
||||
counter[1]++;
|
||||
|
||||
counter[3] += margin;
|
||||
break;
|
||||
case 2:
|
||||
counter[2]++;
|
||||
counter[4]++;
|
||||
counter[5]++;
|
||||
counter[5] += 0.3;
|
||||
|
||||
counter[3] += margin;
|
||||
break;
|
||||
case 3:
|
||||
counter[6]++;
|
||||
counter[7]++;
|
||||
|
||||
counter[3] += margin;
|
||||
break;
|
||||
default:
|
||||
Logger.e((int) (codes[0]) + " 没执行");
|
||||
}
|
||||
switch ((int) (codes[1]) - 48) {
|
||||
case 1:
|
||||
counter[0]++;
|
||||
|
||||
counter[2] += margin;
|
||||
counter[3] += margin;
|
||||
counter[6] += margin;
|
||||
break;
|
||||
case 2:
|
||||
counter[4]++;
|
||||
|
||||
counter[2] += margin;
|
||||
counter[3] += margin;
|
||||
counter[6] += margin;
|
||||
break;
|
||||
case 3:
|
||||
counter[1]++;
|
||||
counter[5]++;
|
||||
counter[7]++;
|
||||
|
||||
counter[2] += margin;
|
||||
counter[3] += margin;
|
||||
counter[6] += margin;
|
||||
break;
|
||||
}
|
||||
switch ((int) (codes[2]) - 48) {
|
||||
case 1:
|
||||
counter[1]++;
|
||||
counter[4]++;
|
||||
|
||||
counter[0] += margin;
|
||||
counter[2] += margin;
|
||||
counter[5] += margin;
|
||||
counter[6] += margin;
|
||||
|
||||
break;
|
||||
case 2:
|
||||
counter[3]++;
|
||||
|
||||
counter[0] += margin;
|
||||
counter[2] += margin;
|
||||
counter[5] += margin;
|
||||
counter[6] += margin;
|
||||
break;
|
||||
case 3:
|
||||
counter[7]++;
|
||||
|
||||
counter[0] += margin;
|
||||
counter[2] += margin;
|
||||
counter[5] += margin;
|
||||
counter[6] += margin;
|
||||
break;
|
||||
}
|
||||
switch ((int) (codes[3]) - 48) {
|
||||
case 1:
|
||||
counter[0]++;
|
||||
counter[1]++;
|
||||
counter[2]++;
|
||||
counter[5]++;
|
||||
counter[6]++;
|
||||
|
||||
counter[3] += margin;
|
||||
counter[4] += margin;
|
||||
break;
|
||||
case 2:
|
||||
counter[7]++;
|
||||
|
||||
counter[3] += margin;
|
||||
counter[4] += margin;
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
}
|
||||
switch ((int) (codes[4]) - 48) {
|
||||
case 1:
|
||||
counter[3]++;
|
||||
|
||||
counter[1] += margin;
|
||||
counter[2] += margin;
|
||||
counter[4] += margin;
|
||||
counter[5] += margin;
|
||||
counter[6] += margin;
|
||||
break;
|
||||
case 2:
|
||||
counter[5]++;
|
||||
|
||||
counter[1] += margin;
|
||||
counter[2] += margin;
|
||||
counter[4] += margin;
|
||||
counter[5] += margin;
|
||||
counter[6] += margin;
|
||||
|
||||
break;
|
||||
case 3:
|
||||
counter[7]++;
|
||||
|
||||
counter[1] += margin;
|
||||
counter[2] += margin;
|
||||
counter[4] += margin;
|
||||
counter[5] += margin;
|
||||
counter[6] += margin;
|
||||
break;
|
||||
}
|
||||
switch ((int) (codes[5]) - 48) {
|
||||
case 1:
|
||||
counter[2]++;
|
||||
counter[2]++;
|
||||
|
||||
counter[0] += margin;
|
||||
counter[3] += margin;
|
||||
counter[4] += margin;
|
||||
counter[5] += margin;
|
||||
counter[6] += margin;
|
||||
break;
|
||||
case 2:
|
||||
counter[1]++;
|
||||
counter[1]++;
|
||||
|
||||
counter[0] += margin;
|
||||
counter[3] += margin;
|
||||
counter[4] += margin;
|
||||
counter[5] += margin;
|
||||
counter[6] += margin;
|
||||
break;
|
||||
case 3:
|
||||
counter[7]++;
|
||||
|
||||
counter[0] += margin;
|
||||
counter[3] += margin;
|
||||
counter[4] += margin;
|
||||
counter[5] += margin;
|
||||
counter[6] += margin;
|
||||
break;
|
||||
}
|
||||
|
||||
int maxIndex = -1;
|
||||
for (int i = 0; i < counter.length; i++) {
|
||||
if (counter[i] > counter[8]) {
|
||||
maxIndex = i;
|
||||
counter[8] = counter[i];
|
||||
}
|
||||
}
|
||||
Logger.d(Arrays.toString(counter) + "\n" + physiques[maxIndex]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -36,18 +36,18 @@ public class ConstantUtils {
|
||||
"舌底经络颜色",
|
||||
"口腔整体情况",
|
||||
"整体生活精神状况",
|
||||
"性格特点",
|
||||
"生活中的小问题",
|
||||
"食物温度偏向",
|
||||
"揭晓结果"
|
||||
};
|
||||
|
||||
public static String[][] answerList = new String[][]{
|
||||
{"开始吧"},
|
||||
{"偏暗红", "偏白", "淡红"},
|
||||
{"暗红", "细红", "不明显"},
|
||||
{"深红", "偏白", "淡红"},
|
||||
{"暗紫", "细红", "不明显"},
|
||||
{"口舌干燥", "口黏苔腻", "还算正常"},
|
||||
{"沉寂易疲劳", "精力充沛"},
|
||||
{"内向", "开朗"},
|
||||
{"多汗无力", "多愁善感", "都不"},
|
||||
{"烫的", "冷的", "没有特别喜欢的"},
|
||||
{"查看"}
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#b0ce93"
|
||||
tools:context="com.example.ninefourone.nutritionmaster.modules.addinformation.AddActivity">
|
||||
tools:context="com.example.ninefourone.nutritionmaster.modules.addinformation.AddPhysiqueActivity">
|
||||
|
||||
|
||||
<com.github.czy1121.view.TurnCardListView
|
||||
|
||||
Reference in New Issue
Block a user