1
This commit is contained in:
@@ -203,6 +203,19 @@ public class NutritionMaster extends Application {
|
||||
*/
|
||||
private void initYouDao() {
|
||||
YouDaoApplication.init(this, ConstantUtils.YOUDAO_APPKEY);
|
||||
// WebUtil webUtil = WebUtil.getInstance();
|
||||
// webUtil.getMenu("雪丽对虾", new Callback() {
|
||||
// @Override
|
||||
// public void onFailure(Call call, IOException e) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onResponse(Call call, Response response) throws IOException {
|
||||
// FoodMenu menu = new Gson().fromJson(response.body().string(), FoodMenu.class);
|
||||
// Logger.d(menu);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,19 +7,21 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.bean.Material;
|
||||
import com.example.ninefourone.nutritionmaster.bean.FoodMaterial;
|
||||
import com.example.ninefourone.nutritionmaster.bean.FoodMenu;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/9/9.
|
||||
*/
|
||||
|
||||
public class MaterialAdapter extends RecyclerView.Adapter<MaterialHolder> {
|
||||
private ArrayList<Material> mList;
|
||||
private List<FoodMenu.CookQuantityBean> mList;
|
||||
private Context mContext;
|
||||
|
||||
public MaterialAdapter(ArrayList mList, Context mContext) {
|
||||
public MaterialAdapter(List mList, Context mContext) {
|
||||
this.mList = mList;
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.bean.Material;
|
||||
import com.example.ninefourone.nutritionmaster.bean.FoodMaterial;
|
||||
import com.example.ninefourone.nutritionmaster.bean.FoodMenu;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
@@ -24,11 +25,12 @@ public class MaterialHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public MaterialHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this,itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
}
|
||||
|
||||
public void bindView(Material material) {
|
||||
weightNumber.setText(material.getWeight() + "");
|
||||
name.setText(material.getMaterialName());
|
||||
public void bindView(FoodMenu.CookQuantityBean cookQuantityBean) {
|
||||
name.setText(cookQuantityBean.getMaterial());
|
||||
String weight = cookQuantityBean.getQuantity();
|
||||
weightNumber.setText(weight);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,37 @@
|
||||
package com.example.ninefourone.nutritionmaster.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.bean.FoodMenu;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/10/7.
|
||||
*/
|
||||
|
||||
public class MaterialResultAdapter extends RecyclerView.Adapter {
|
||||
public class MaterialResultAdapter extends RecyclerView.Adapter<MaterialResultHolder> {
|
||||
private ArrayList<FoodMenu> foodMenus;
|
||||
private Context context;
|
||||
|
||||
@Override
|
||||
public MaterialResultHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.recommend_item_middle, parent, false);
|
||||
return new MaterialResultHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(MaterialResultHolder holder, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return foodMenus.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,37 @@
|
||||
package com.example.ninefourone.nutritionmaster.adapter;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.bean.FoodMenu;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/10/7.
|
||||
*/
|
||||
|
||||
public class MaterialResultHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.recommend_item_imageview)
|
||||
ImageView recommendItemImageview;
|
||||
@BindView(R.id.recommend_item_title)
|
||||
TextView recommendItemTitle;
|
||||
@BindView(R.id.whole_layout)
|
||||
LinearLayout wholeLayout;
|
||||
|
||||
public MaterialResultHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
}
|
||||
|
||||
public void bindView(FoodMenu foodMenu) {
|
||||
Glide.with(itemView.getContext()).load(foodMenu.getImage_url()).into(recommendItemImageview);
|
||||
recommendItemTitle.setText(foodMenu.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ClassifyResult implements Serializable {
|
||||
private Boolean has_calorie = false;
|
||||
private double quantity = -1;
|
||||
private FoodMenu foodMenu;
|
||||
private FoodMaterial foodMaterial;
|
||||
private Material foodMaterial;
|
||||
|
||||
private int flag = -1;
|
||||
public static int MATERIAL = 0;
|
||||
@@ -69,8 +69,9 @@ public class ClassifyResult implements Serializable {
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String json = response.body().string();
|
||||
FoodMaterial material = new Gson().fromJson(json, FoodMaterial.class);
|
||||
foodMaterial = material;
|
||||
Logger.d(name + "|" + foodMaterial);
|
||||
foodMaterial = new Material();
|
||||
foodMaterial.setFoodMaterial(material);
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -78,7 +79,7 @@ public class ClassifyResult implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public FoodMaterial getFoodMaterial() {
|
||||
public Material getFoodMaterial() {
|
||||
return foodMaterial;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,93 @@
|
||||
package com.example.ninefourone.nutritionmaster.bean;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.utils.WebUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Response;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/10/7.
|
||||
*/
|
||||
|
||||
public class Material {
|
||||
public class Material implements Serializable {
|
||||
FoodMaterial foodMaterial;
|
||||
ArrayList<FoodMenu> menus = new ArrayList<>();
|
||||
|
||||
public FoodMaterial getFoodMaterial() {
|
||||
return foodMaterial;
|
||||
}
|
||||
|
||||
public void setFoodMaterial(FoodMaterial foodMaterial) {
|
||||
this.foodMaterial = foodMaterial;
|
||||
int max = foodMaterial.getCook_quantity().size() > 30 ? 30 : foodMaterial.getCook_quantity().size();
|
||||
int index = 0;
|
||||
// addMenu(index, max);
|
||||
for (int i = 0; i < max; i++) {
|
||||
WebUtil webUtil = WebUtil.getInstance();
|
||||
FoodMaterial.CookQuantityBean temp = foodMaterial.getCook_quantity().get(i);
|
||||
String menuName = temp.getMenu();
|
||||
webUtil.getMenu(menuName, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
Logger.d(response.body().string());
|
||||
FoodMenu menu = new Gson().fromJson(response.body().string(), FoodMenu.class);
|
||||
menus.add(menu);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<FoodMenu> getMenus() {
|
||||
return menus;
|
||||
}
|
||||
|
||||
public void setMenus(ArrayList<FoodMenu> menus) {
|
||||
this.menus = menus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return foodMaterial.toString() + "\nsize:" + menus.size();
|
||||
}
|
||||
|
||||
private void addMenu(final int index, final int max) {
|
||||
WebUtil webUtil = WebUtil.getInstance();
|
||||
FoodMaterial.CookQuantityBean temp = foodMaterial.getCook_quantity().get(index);
|
||||
String menuName = temp.getMenu();
|
||||
Logger.d(menuName);
|
||||
webUtil.getMenu(menuName, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
Logger.d(response.body().string());
|
||||
FoodMenu menu = new Gson().fromJson(response.body().string(), FoodMenu.class);
|
||||
menus.add(menu);
|
||||
if (index < max) {
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
addMenu(index + 1, max);
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,4 +65,10 @@ public class RecommendFood implements MultiItemEntity, Serializable {
|
||||
public int getItemType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return menu.toString();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,6 +186,7 @@ public class ClassifierCamera extends AppCompatActivity {
|
||||
result = jsonObject.getJSONArray("objects")
|
||||
.getJSONObject(0).getString("value");
|
||||
translate(result);
|
||||
refreshUI();
|
||||
} else if (code == DISH_CODE) {
|
||||
result = WebUtil.HttpPost(ConstantUtils.BD_DISH_URL,
|
||||
ConstantUtils.BD_ACCESS_TOKEN, param);
|
||||
@@ -323,7 +324,7 @@ public class ClassifierCamera extends AppCompatActivity {
|
||||
public void onResult(Translate translate, String s, String s1) {
|
||||
String result = "";
|
||||
result = translate.getTranslations().get(0);
|
||||
// Logger.d(result);
|
||||
Logger.d(result);
|
||||
ClassifyResult classifyResult = new ClassifyResult(ClassifyResult.MATERIAL);
|
||||
classifyResult.setName(result);
|
||||
resultList.add(classifyResult);
|
||||
|
||||
@@ -4,18 +4,27 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.adapter.MakeStepAdapter;
|
||||
import com.example.ninefourone.nutritionmaster.adapter.MaterialAdapter;
|
||||
import com.example.ninefourone.nutritionmaster.base.BaseActivity;
|
||||
import com.example.ninefourone.nutritionmaster.bean.Material;
|
||||
import com.example.ninefourone.nutritionmaster.bean.RecommendFood;
|
||||
import com.example.ninefourone.nutritionmaster.utils.CalculateUtils;
|
||||
import com.example.ninefourone.nutritionmaster.utils.MessageUtils;
|
||||
import com.github.lzyzsd.circleprogress.ArcProgress;
|
||||
import com.nightonke.boommenu.BoomButtons.HamButton;
|
||||
import com.nightonke.boommenu.BoomButtons.OnBMClickListener;
|
||||
import com.nightonke.boommenu.BoomMenuButton;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class RecipeActivity extends BaseActivity {
|
||||
|
||||
@@ -30,6 +39,20 @@ public class RecipeActivity extends BaseActivity {
|
||||
RecyclerView materialRecyclerView;
|
||||
@BindView(R.id.detail_way_recycler_view)
|
||||
RecyclerView detailWayRecyclerView;
|
||||
@BindView(R.id.image)
|
||||
ImageView image;
|
||||
@BindView(R.id.name)
|
||||
TextView name;
|
||||
@BindView(R.id.back_button)
|
||||
ImageView backButton;
|
||||
@BindView(R.id.protein_text)
|
||||
TextView proteinText;
|
||||
@BindView(R.id.fat_text)
|
||||
TextView fatText;
|
||||
@BindView(R.id.suger_text)
|
||||
TextView sugerText;
|
||||
@BindView(R.id.boom_menu_button)
|
||||
BoomMenuButton boomMenuButton;
|
||||
private RecommendFood recommendFood;
|
||||
|
||||
|
||||
@@ -50,7 +73,18 @@ public class RecipeActivity extends BaseActivity {
|
||||
public void initViews(Bundle savedInstanceState) {
|
||||
Intent intent = getIntent();
|
||||
recommendFood = (RecommendFood) intent.getSerializableExtra("SEND_OBJECT");
|
||||
Glide.with(RecipeActivity.this).load(recommendFood.getPicture()).into(image);
|
||||
name.setText(recommendFood.getMenu().getName());
|
||||
HashMap map = CalculateUtils.elementsProportion(recommendFood.getMenu().getElements());
|
||||
proteinCircle.setProgress((int) map.get("protein"));
|
||||
fatCircle.setProgress((int) map.get("fat"));
|
||||
carbohydrateCircle.setProgress((int) map.get("suger"));
|
||||
proteinText.setText(new Double(recommendFood.getMenu().getElements().getProtein()).intValue() + "克");
|
||||
fatText.setText(new Double(recommendFood.getMenu().getElements().getFat()).intValue() + "克");
|
||||
sugerText.setText(new Double(recommendFood.getMenu().getElements().getCarbohydrate()).intValue() + "克");
|
||||
Logger.d(recommendFood.getMenu().getPractice());
|
||||
initList();
|
||||
initBMB();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,25 +98,37 @@ public class RecipeActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void initList() {
|
||||
// ArrayList<Material> list = new ArrayList<>();
|
||||
// for (int i = 0; i < 7; i++) {
|
||||
// Material material = new Material("毛豆", 100);
|
||||
// list.add(material);
|
||||
// }
|
||||
// ArrayList<String> mList = new ArrayList<>();
|
||||
// for (int i = 0; i < 7; i++) {
|
||||
// String step = "第一步";
|
||||
// mList.add(step);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// makeStepAdapter = new MakeStepAdapter(menu.getMakeSteps(), this);
|
||||
// detailWayRecyclerView.setAdapter(makeStepAdapter);
|
||||
// detailWayRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
//
|
||||
// materialAdapter = new MaterialAdapter(menu.getMaterialArrayList(), this);
|
||||
// materialRecyclerView.setAdapter(materialAdapter);
|
||||
// materialRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
materialAdapter = new MaterialAdapter(recommendFood.getMenu().getCook_quantity(), RecipeActivity.this);
|
||||
materialRecyclerView.setAdapter(materialAdapter);
|
||||
materialRecyclerView.setLayoutManager(new LinearLayoutManager(RecipeActivity.this));
|
||||
materialRecyclerView.setNestedScrollingEnabled(false);
|
||||
|
||||
makeStepAdapter = new MakeStepAdapter(
|
||||
CalculateUtils.getStepArray(recommendFood.getMenu().getPractice()), RecipeActivity.this);
|
||||
detailWayRecyclerView.setLayoutManager(new LinearLayoutManager(RecipeActivity.this));
|
||||
detailWayRecyclerView.setAdapter(makeStepAdapter);
|
||||
detailWayRecyclerView.setNestedScrollingEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化悬浮按钮
|
||||
*/
|
||||
private void initBMB() {
|
||||
HamButton.Builder builder = new HamButton.Builder()
|
||||
.normalImageRes(R.drawable.ic_add_recipe)
|
||||
.normalTextRes(R.string.recipe_add_string)
|
||||
.listener(new OnBMClickListener() {
|
||||
@Override
|
||||
public void onBoomButtonClick(int index) {
|
||||
MessageUtils.MakeToast("已添加到记录");
|
||||
}
|
||||
});
|
||||
boomMenuButton.addBuilder(builder);
|
||||
}
|
||||
|
||||
@OnClick(R.id.back_button)
|
||||
public void onViewClicked() {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
package com.example.ninefourone.nutritionmaster.modules.classifyresult;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.base.BaseActivity;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class MaterialResultActivity extends BaseActivity {
|
||||
|
||||
|
||||
@BindView(R.id.recycler_view)
|
||||
RecyclerView recyclerView;
|
||||
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_material_result;
|
||||
@@ -28,4 +35,11 @@ public class MaterialResultActivity extends BaseActivity {
|
||||
public void onPointerCaptureChanged(boolean hasCapture) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// TODO: add setContentView(...) invocation
|
||||
ButterKnife.bind(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,11 @@ public class BodyInformationFragment extends BaseFragment {
|
||||
* 改变记步UI中的数字
|
||||
*/
|
||||
private void updateStepCount() {
|
||||
stepTextView.setText(stepCount + "");
|
||||
try {
|
||||
stepTextView.setText(stepCount + "");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -143,7 +143,8 @@ public class RecommendFragment extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
FoodMenu[] menus = new Gson().fromJson(response.body().string(), FoodMenu[].class);
|
||||
String json = response.body().string();
|
||||
FoodMenu[] menus = new Gson().fromJson(json, FoodMenu[].class);
|
||||
int count = 0;
|
||||
for (int i = 0; i < menus.length; i++) {
|
||||
if (count > 11) {
|
||||
@@ -169,7 +170,8 @@ public class RecommendFragment extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
Trick[] tricks = new Gson().fromJson(response.body().string(), Trick[].class);
|
||||
String json = response.body().string();
|
||||
Trick[] tricks = new Gson().fromJson(json, Trick[].class);
|
||||
int index = 0;
|
||||
for (int i = 0; i < datas.size(); i++) {
|
||||
if (datas.get(i).getItemType() == RecommendFood.TYPE_DETAIL) {
|
||||
@@ -205,7 +207,8 @@ public class RecommendFragment extends BaseFragment {
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
final int originsize = datas.size();
|
||||
FoodMenu[] menus = new Gson().fromJson(response.body().string(), FoodMenu[].class);
|
||||
String json = response.body().string();
|
||||
FoodMenu[] menus = new Gson().fromJson(json, FoodMenu[].class);
|
||||
int count = 0;
|
||||
for (int i = 0; i < menus.length; i++) {
|
||||
if (count > 7) {
|
||||
@@ -231,7 +234,8 @@ public class RecommendFragment extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
Trick[] tricks = new Gson().fromJson(response.body().string(), Trick[].class);
|
||||
String json = response.body().string();
|
||||
Trick[] tricks = new Gson().fromJson(json, Trick[].class);
|
||||
int index = 0;
|
||||
for (int i = originsize; i < datas.size(); i++) {
|
||||
if (datas.get(i).getItemType() == RecommendFood.TYPE_DETAIL) {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.example.ninefourone.nutritionmaster.utils;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.bean.ClassifyResult;
|
||||
import com.example.ninefourone.nutritionmaster.bean.FoodMenu;
|
||||
import com.example.ninefourone.nutritionmaster.bean.MyUser;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/8/29.
|
||||
@@ -135,4 +138,49 @@ public class CalculateUtils {
|
||||
}
|
||||
return classifyResultArrayList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 元素比例
|
||||
*
|
||||
* @param elementsBean
|
||||
* @return
|
||||
*/
|
||||
public static HashMap<String, Integer> elementsProportion(FoodMenu.ElementsBean elementsBean) {
|
||||
HashMap<String, Integer> map = new HashMap<>();
|
||||
Double suger = elementsBean.getCarbohydrate();
|
||||
Double fat = elementsBean.getFat();
|
||||
Double protein = elementsBean.getProtein();
|
||||
Double sum = fat + suger + protein;
|
||||
suger = suger / sum * 100;
|
||||
fat = fat / sum * 100;
|
||||
protein = protein / sum * 100;
|
||||
map.put("suger", suger.intValue());
|
||||
map.put("fat", fat.intValue());
|
||||
map.put("protein", protein.intValue());
|
||||
Logger.d(elementsBean);
|
||||
Logger.d(map.toString());
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将步骤字符串分解
|
||||
*
|
||||
* @param whole
|
||||
* @return
|
||||
*/
|
||||
public static ArrayList<String> getStepArray(String whole) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
String[] array = whole.split("'");
|
||||
Logger.d(Arrays.toString(array));
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
if (array[i].equals("[") || array[i].equals("]") || array[i].equals(", ") ||
|
||||
array[i].equals(",")||array[i].equals(" ")) {
|
||||
|
||||
} else {
|
||||
list.add(array[i]);
|
||||
}
|
||||
}
|
||||
Logger.d(Arrays.toString(list.toArray()));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,8 @@ public class WebUtil {
|
||||
private WebUtil() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static WebUtil getInstance() {
|
||||
return instance;
|
||||
}
|
||||
@@ -166,11 +168,13 @@ public class WebUtil {
|
||||
Request request = new Request.Builder().url("http://120.77.182.38/occupation/" + occupationName + "/").build();
|
||||
mClient.newCall(request).enqueue(callback);
|
||||
}
|
||||
|
||||
public static void getAllOccupations(Callback callback) {
|
||||
OkHttpClient mClient = new OkHttpClient();
|
||||
Request request = new Request.Builder().url("http://120.77.182.38/occupation/").build();
|
||||
mClient.newCall(request).enqueue(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取体质需要的食材
|
||||
* {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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:layout_width="match_parent"
|
||||
@@ -7,261 +7,285 @@
|
||||
<!--clipToPadding = false-->
|
||||
<!--令布局可以延伸到状态栏-->
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
app:layout_collapseMode="parallax"
|
||||
app:layout_scrollFlags="scroll|enterAlways">
|
||||
android:layout_height="250dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
app:layout_collapseMode="parallax"
|
||||
app:layout_scrollFlags="scroll|enterAlways">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.5"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp" />
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="90dp"
|
||||
app:cardCornerRadius="10dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitXY" />
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:textColor="#FFF"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:text="营养成分"
|
||||
android:textColor="#000000"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="10dp"
|
||||
android:text="单位:每100克"
|
||||
android:textSize="10sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="5dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.github.lzyzsd.circleprogress.ArcProgress
|
||||
android:id="@+id/protein_circle"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_margin="5dp"
|
||||
app:arc_bottom_text="蛋白质"
|
||||
app:arc_progress="50"
|
||||
app:arc_suffix_text_size="12sp"
|
||||
app:arc_text_size="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/protein_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="4.1克"
|
||||
android:textSize="10sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.github.lzyzsd.circleprogress.ArcProgress
|
||||
android:id="@+id/fat_circle"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_margin="5dp"
|
||||
app:arc_bottom_text="脂肪"
|
||||
app:arc_progress="50"
|
||||
app:arc_suffix_text_size="12sp"
|
||||
app:arc_text_size="12sp" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fat_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="4.1克"
|
||||
android:textSize="10sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.github.lzyzsd.circleprogress.ArcProgress
|
||||
android:id="@+id/carbohydrate_circle"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_margin="5dp"
|
||||
app:arc_bottom_text="糖分"
|
||||
app:arc_progress="50"
|
||||
app:arc_suffix_text_size="12sp"
|
||||
app:arc_text_size="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/suger_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="4.1克"
|
||||
android:textSize="10sp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back_button"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/ic_back_button_white" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FFF"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.5"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp" />
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="90dp"
|
||||
app:cardCornerRadius="10dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/food_test" />
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:text="红烧肉"
|
||||
android:textColor="#FFF"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:text="营养成分"
|
||||
android:textColor="#000000"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="10dp"
|
||||
android:text="单位:每100克"
|
||||
android:textSize="10sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="5dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.github.lzyzsd.circleprogress.ArcProgress
|
||||
android:id="@+id/protein_circle"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_margin="5dp"
|
||||
app:arc_bottom_text="测试"
|
||||
app:arc_progress="50"
|
||||
app:arc_suffix_text_size="12sp"
|
||||
app:arc_text_size="12sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="4.1克"
|
||||
android:textSize="10sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.github.lzyzsd.circleprogress.ArcProgress
|
||||
android:id="@+id/fat_circle"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_margin="5dp"
|
||||
app:arc_bottom_text="测试"
|
||||
app:arc_progress="50"
|
||||
app:arc_suffix_text_size="12sp"
|
||||
app:arc_text_size="12sp" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="4.1克"
|
||||
android:textSize="10sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.github.lzyzsd.circleprogress.ArcProgress
|
||||
android:id="@+id/carbohydrate_circle"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_margin="5dp"
|
||||
app:arc_bottom_text="测试"
|
||||
app:arc_progress="50"
|
||||
app:arc_suffix_text_size="12sp"
|
||||
app:arc_text_size="12sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="4.1克"
|
||||
android:textSize="10sp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:src="@drawable/ic_fortune_cookie" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="原料与做法"
|
||||
android:textColor="#131313"
|
||||
android:textSize="13sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/ic_back_button_white" />
|
||||
</RelativeLayout>
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FFF"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:src="@drawable/ic_fortune_cookie" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="原料与做法"
|
||||
android:textColor="#131313"
|
||||
android:textSize="13sp" />
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:id="@+id/nestedScrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<RelativeLayout
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:background="#FFF"
|
||||
android:gravity="center_vertical">
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:background="#FFF"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="主要材料"
|
||||
android:textColor="#000000"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/material_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="主要材料"
|
||||
android:textColor="#000000"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
android:background="#ffffff">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/material_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:background="#FFF"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:background="#FFF"
|
||||
android:gravity="center_vertical">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="详细步骤"
|
||||
android:textColor="#000000"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/detail_way_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="详细步骤"
|
||||
android:textColor="#000000"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
android:background="#ffffff">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/detail_way_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
</LinearLayout>
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
<com.nightonke.boommenu.BoomMenuButton
|
||||
android:id="@+id/boom_menu_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
app:bmb_buttonEnum="ham"
|
||||
app:bmb_buttonPlaceEnum="buttonPlace_ham_1"
|
||||
app:bmb_piecePlaceEnum="piecePlace_ham_1" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:background="#f9f9f6"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/make_step_text_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="#212121"
|
||||
tools:text="@string/app_name" />
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="#f9f9f6"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
@@ -31,7 +32,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="15dp"
|
||||
android:text="克"
|
||||
android:textColor="#131212"
|
||||
android:textSize="13sp" />
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<string name="food_meterial_title">食材识别</string>
|
||||
<string name="food_title">菜品识别</string>
|
||||
<string name="title_activity_login">登录</string>
|
||||
<string name="recipe_add_string">是否添加到已吃记录</string>
|
||||
|
||||
<!-- Strings related to login -->
|
||||
<string name="prompt_email">Email</string>
|
||||
|
||||
Reference in New Issue
Block a user