Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
028fc613b8 | ||
|
|
9708b65292 | ||
|
|
31d3171102 | ||
|
|
a0d34e04d9 | ||
|
|
a19f3347b7 | ||
|
|
18d04a3a78 | ||
|
|
a02323d7be | ||
|
|
a5acd866c6 | ||
|
|
a7dd7fb69c | ||
|
|
57b9bcfd4c | ||
|
|
ae3451f4ca | ||
|
|
bcb948de95 | ||
|
|
d79cf541aa | ||
|
|
a0db58816b | ||
|
|
0b1f2d9772 | ||
|
|
1e15caa3dc | ||
|
|
d12c53f519 |
@@ -358,10 +358,10 @@
|
||||
|
||||
### 问题
|
||||
|
||||
* 连续识别,出现错误的,点一下消去 锐
|
||||
* bug: 连续拍照后 点了一周定制 锐
|
||||
* ~~连续识别,出现错误的,点一下消去 锐!~~
|
||||
* ~~bug: 连续拍照后 点了一周定制 锐~~
|
||||
* ~~*食材模糊识别 ok*~~
|
||||
* 通过食材组合,搜索菜 ,菜要符合username的信息 赵和锐 `getMenusByMaterials`
|
||||
* ~~通过食材组合,搜索菜 ,菜要符合username的信息 赵和锐 `getMenusByMaterials`~~
|
||||
* 卡路里不对
|
||||
* ~~*早餐晚餐的搜索不随机 shuffle了一下.ok*~~
|
||||
|
||||
@@ -371,6 +371,7 @@
|
||||
* getRandomMenus的调用里面加上username参数 锐
|
||||
* 吃饭的时候没拍照,吃饭完了才想添加,但是菜图片没有了.需要输入添加 (王)
|
||||
* 口味信息采集
|
||||
* 历史记录
|
||||
* 社交功能: 点赞,晒图,评论
|
||||
|
||||
|
||||
|
||||
@@ -112,4 +112,6 @@ dependencies {
|
||||
implementation files('libs/YoudaoCnDictOffline.jar')
|
||||
implementation files('libs/YoudaoTranslateOffline.jar')
|
||||
implementation files('libs/YoudaoTranslateOnline.jar')
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,11 +30,12 @@
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
|
||||
<application
|
||||
|
||||
android:name=".NutritionMaster"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:icon="@mipmap/ic"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:roundIcon="@mipmap/ic"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".modules.MainActivity">
|
||||
@@ -61,6 +62,7 @@
|
||||
<activity android:name=".modules.addinformation.AddInformationActivity" />
|
||||
<activity android:name=".modules.classifyresult.DishResultActivity" />
|
||||
<activity android:name=".modules.classifyresult.MaterialResultActivity" />
|
||||
<activity android:name=".modules.historysearch.HistoryActivity"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -27,6 +27,8 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -48,6 +50,7 @@ public class NutritionMaster extends Application {
|
||||
public static Occupation occupation = null;
|
||||
public static Element element = null;
|
||||
public static Illness illness = null;
|
||||
public static int flavourCount = 0;
|
||||
|
||||
public static Element calculatedElement = null;
|
||||
|
||||
@@ -155,6 +158,7 @@ public class NutritionMaster extends Application {
|
||||
for (int i = 0; i < occupations.length; i++) {
|
||||
ConstantUtils.occupationList.add(occupations[i].getOccupation_name());
|
||||
}
|
||||
Collections.shuffle(ConstantUtils.occupationList);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
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.History;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/11/7.
|
||||
*/
|
||||
|
||||
public class HistoryAdapter extends RecyclerView.Adapter<HistoryHolder> {
|
||||
private Context context;
|
||||
private List<History> mList;
|
||||
|
||||
public HistoryAdapter(Context context, List mList) {
|
||||
this.context = context;
|
||||
this.mList = mList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HistoryHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.dish_item, parent, false);
|
||||
HistoryHolder historyHolder = new HistoryHolder(view);
|
||||
return historyHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(HistoryHolder holder, int position) {
|
||||
holder.bindView(mList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.example.ninefourone.nutritionmaster.adapter;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.bean.FoodMenu;
|
||||
import com.example.ninefourone.nutritionmaster.bean.History;
|
||||
import com.example.ninefourone.nutritionmaster.bean.RecommendFood;
|
||||
import com.example.ninefourone.nutritionmaster.modules.RecipeActivity.RecipeActivity;
|
||||
import com.example.ninefourone.nutritionmaster.utils.WebUtil;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Response;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/11/7.
|
||||
*/
|
||||
|
||||
public class HistoryHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.image)
|
||||
ImageView image;
|
||||
@BindView(R.id.name)
|
||||
TextView name;
|
||||
@BindView(R.id.describle)
|
||||
TextView describle;
|
||||
private FoodMenu foodMenu;
|
||||
|
||||
public HistoryHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
}
|
||||
|
||||
public void bindView(History history) {
|
||||
Glide.with(itemView.getContext()).load(history.getMenu().getImage_url()).into(image);
|
||||
name.setText(history.getMenu().getName());
|
||||
WebUtil webUtil = WebUtil.getInstance();
|
||||
webUtil.getMenu(history.getMenu().getName(), new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String json = response.body().string();
|
||||
foodMenu = new Gson().fromJson(json, FoodMenu.class);
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(itemView.getContext().getApplicationContext(), RecipeActivity.class);
|
||||
RecommendFood recommendFood = new RecommendFood(foodMenu, 1);
|
||||
intent.putExtra("SEND_OBJECT", recommendFood);
|
||||
itemView.getContext().getApplicationContext().startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,12 @@ import android.view.View;
|
||||
import android.widget.Adapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.NutritionMaster;
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.bean.Illness;
|
||||
import com.example.ninefourone.nutritionmaster.utils.ConstantUtils;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
@@ -29,7 +33,7 @@ public class IllnessHolder extends RecyclerView.ViewHolder {
|
||||
this.adapter = adapter;
|
||||
}
|
||||
|
||||
public void bindView(String illness, final int position) {
|
||||
public void bindView(final String illness, final int position) {
|
||||
text.setText(illness);
|
||||
text.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -46,6 +50,10 @@ public class IllnessHolder extends RecyclerView.ViewHolder {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
adapter.deleteItem(position);
|
||||
if (ConstantUtils.getFlavour().contains(illness)) {
|
||||
NutritionMaster.flavourCount -= (ConstantUtils.getFlavour().indexOf(illness) + 1);
|
||||
// Logger.d(NutritionMaster.flavourCount);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -28,9 +28,11 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
this.user = NutritionMaster.user;
|
||||
setContentView(getLayoutId());
|
||||
unbinder = ButterKnife.bind(this);
|
||||
initViews(savedInstanceState);
|
||||
webUtil = WebUtil.getInstance();
|
||||
|
||||
initViews(savedInstanceState);
|
||||
initToolBar();
|
||||
|
||||
}
|
||||
|
||||
public WebUtil getWebUtil() {
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package com.example.ninefourone.nutritionmaster.bean;
|
||||
|
||||
public class History {
|
||||
|
||||
/**
|
||||
* id : 13 time : 2018-11-02T15:35:20.015542+08:00 user : 11 menu : 多味茄子泥
|
||||
* id : 13
|
||||
* menu : {"name":"多味茄子泥","calorie":105,"elements":6383,"image_url":"http://s1.ig.meishij.net/p/20121204/3fde157430b268b189a913983fdda3e6_150x150.jpg"}
|
||||
* time : 2018-11-02T15:34:27.050541+08:00
|
||||
* user : 11
|
||||
*/
|
||||
|
||||
private int id;
|
||||
private MenuBean menu;
|
||||
private String time;
|
||||
private int user;
|
||||
private String menu;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
@@ -19,6 +21,14 @@ public class History {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public MenuBean getMenu() {
|
||||
return menu;
|
||||
}
|
||||
|
||||
public void setMenu(MenuBean menu) {
|
||||
this.menu = menu;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
@@ -35,16 +45,69 @@ public class History {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getMenu() {
|
||||
return menu;
|
||||
}
|
||||
public static class MenuBean {
|
||||
/**
|
||||
* name : 多味茄子泥
|
||||
* calorie : 105
|
||||
* elements : 6383
|
||||
* image_url : http://s1.ig.meishij.net/p/20121204/3fde157430b268b189a913983fdda3e6_150x150.jpg
|
||||
*/
|
||||
|
||||
public void setMenu(String menu) {
|
||||
this.menu = menu;
|
||||
private String name;
|
||||
private int calorie;
|
||||
private int elements;
|
||||
private String image_url;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getCalorie() {
|
||||
return calorie;
|
||||
}
|
||||
|
||||
public void setCalorie(int calorie) {
|
||||
this.calorie = calorie;
|
||||
}
|
||||
|
||||
public int getElements() {
|
||||
return elements;
|
||||
}
|
||||
|
||||
public void setElements(int elements) {
|
||||
this.elements = elements;
|
||||
}
|
||||
|
||||
public String getImage_url() {
|
||||
return image_url;
|
||||
}
|
||||
|
||||
public void setImage_url(String image_url) {
|
||||
this.image_url = image_url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MenuBean{" +
|
||||
"name='" + name + '\'' +
|
||||
", calorie=" + calorie +
|
||||
", elements=" + elements +
|
||||
", image_url='" + image_url + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "History{" + "id=" + id + ", time='" + time + '\'' + ", user=" + user + ", menu='" + menu + '\'' + '}';
|
||||
return "History{" +
|
||||
"id=" + id +
|
||||
", menu=" + menu +
|
||||
", time='" + time + '\'' +
|
||||
", user=" + user +
|
||||
'}' + '\n';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Matrix;
|
||||
import android.hardware.Camera;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
@@ -46,6 +48,7 @@ import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -184,6 +187,7 @@ public class ClassifierCamera extends AppCompatActivity {
|
||||
* 拍照回调
|
||||
*/
|
||||
private Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
|
||||
@RequiresApi(api = Build.VERSION_CODES.FROYO)
|
||||
@Override
|
||||
public void onPictureTaken(final byte[] data, Camera camera) {
|
||||
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
|
||||
@@ -209,11 +213,20 @@ public class ClassifierCamera extends AppCompatActivity {
|
||||
String result = null;
|
||||
try {
|
||||
if (code == MATERAIL_CODE) {
|
||||
MaterialClassifier materialClassifier = new MaterialClassifier();
|
||||
JSONObject jsonObject = materialClassifier.plantDetect(data);
|
||||
result = jsonObject.getJSONArray("objects")
|
||||
.getJSONObject(0).getString("value");
|
||||
translate(result);
|
||||
// MaterialClassifier materialClassifier = new MaterialClassifier();
|
||||
// JSONObject jsonObject = materialClassifier.plantDetect(data);
|
||||
// result = jsonObject.getJSONArray("objects")
|
||||
// .getJSONObject(0).getString("value");
|
||||
// translate(result);
|
||||
result = WebUtil.HttpPost(ConstantUtils.BD_MATERIAL_URL,
|
||||
ConstantUtils.BD_ACCESS_TOKEN, param);
|
||||
Logger.d(result);
|
||||
JSONObject jsonObject = new JSONObject(result);
|
||||
JSONArray resultObject = jsonObject.getJSONArray("result");
|
||||
jsonObject = resultObject.getJSONObject(0);
|
||||
ClassifyResult classifyResult = new ClassifyResult(ClassifyResult.MATERIAL);
|
||||
classifyResult.setName(jsonObject.getString("name"));
|
||||
resultList.add(classifyResult);
|
||||
refreshUI();
|
||||
} else if (code == DISH_CODE) {
|
||||
result = WebUtil.HttpPost(ConstantUtils.BD_DISH_URL,
|
||||
@@ -255,6 +268,7 @@ public class ClassifierCamera extends AppCompatActivity {
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
|
||||
@OnClick({R.id.more_take_photo_button_capture, R.id.more_takephoto_ok, R.id.results_text_view})
|
||||
public void onViewClicked(View view) {
|
||||
switch (view.getId()) {
|
||||
@@ -274,28 +288,30 @@ public class ClassifierCamera extends AppCompatActivity {
|
||||
|
||||
|
||||
//把拍照结果的食材名字放到新的List:materials里面
|
||||
List<String> materials = new ArrayList<>();
|
||||
ArrayList<String> materials = new ArrayList<>();
|
||||
for (ClassifyResult classifyResult : resultList) {
|
||||
materials.add(classifyResult.getName());
|
||||
}
|
||||
WebUtil.getInstance().getMenusByMaterials(materials, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, final Response response) throws IOException {
|
||||
String json = response.body().string();
|
||||
FoodMenu[] menus = new Gson().fromJson(json, FoodMenu[].class);
|
||||
ArrayList<FoodMenu> menuList = new ArrayList<>();
|
||||
for (FoodMenu foodMenu : menus) {
|
||||
menuList.add(foodMenu);
|
||||
}
|
||||
intent.putExtra("LIST", menuList);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
// WebUtil.getInstance().getMenusByMaterials(materials, new Callback() {
|
||||
// @Override
|
||||
// public void onFailure(Call call, IOException e) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onResponse(Call call, final Response response) throws IOException {
|
||||
// String json = response.body().string();
|
||||
// FoodMenu[] menus = new Gson().fromJson(json, FoodMenu[].class);
|
||||
// ArrayList<FoodMenu> menuList = new ArrayList<>();
|
||||
// for (FoodMenu foodMenu : menus) {
|
||||
// menuList.add(foodMenu);
|
||||
// }
|
||||
// intent.putExtra("LIST", menuList);
|
||||
// startActivity(intent);
|
||||
// }
|
||||
// });
|
||||
intent.putExtra("LIST", materials);
|
||||
startActivity(intent);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.example.ninefourone.nutritionmaster.bean.Illness;
|
||||
import com.example.ninefourone.nutritionmaster.camera.ClassifierCamera;
|
||||
import com.example.ninefourone.nutritionmaster.modules.addinformation.AddInformationActivity;
|
||||
import com.example.ninefourone.nutritionmaster.modules.addinformation.AddPhysiqueActivity;
|
||||
import com.example.ninefourone.nutritionmaster.modules.historysearch.HistoryActivity;
|
||||
import com.example.ninefourone.nutritionmaster.modules.information.InformationActivity;
|
||||
import com.example.ninefourone.nutritionmaster.ui.NoScrollViewPager;
|
||||
import com.example.ninefourone.nutritionmaster.utils.CalculateUtils;
|
||||
@@ -62,6 +63,8 @@ import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
@@ -129,15 +132,33 @@ public class MainActivity extends BaseActivity {
|
||||
LinearLayout illButton;
|
||||
@BindView(R.id.change_information)
|
||||
TextView changeInformation;
|
||||
@BindView(R.id.add_flavour_button)
|
||||
ImageView addFlavourButton;
|
||||
@BindView(R.id.bmi_self)
|
||||
TextView bmiSelf;
|
||||
@BindView(R.id.bmi_standard)
|
||||
TextView bmiStandard;
|
||||
@BindView(R.id.height_self)
|
||||
TextView heightSelf;
|
||||
@BindView(R.id.height_standard)
|
||||
TextView heightStandard;
|
||||
@BindView(R.id.weight_self)
|
||||
TextView weightSelf;
|
||||
@BindView(R.id.weight_standard)
|
||||
TextView weightStandard;
|
||||
|
||||
|
||||
private OptionsPickerView illPicker;
|
||||
private OptionsPickerView flavourPicker;
|
||||
private ArrayList<String> illness = ConstantUtils.getIllness();
|
||||
private ArrayList<String> flavours = ConstantUtils.getFlavour();
|
||||
private ArrayList<String> userIllness = new ArrayList<>();
|
||||
private IllAdapter illAdapter;
|
||||
|
||||
private HomePagerAdapter homePagerAdapter;
|
||||
|
||||
public static float[] scores = {3.1f, 2.5f, 1.7f, 5.9f, 4.6f};
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_main;
|
||||
@@ -164,7 +185,7 @@ public class MainActivity extends BaseActivity {
|
||||
// Logger.i("openRatio=" + openRatio + " ,offsetPixels=" + offsetPixels);
|
||||
}
|
||||
});
|
||||
initSpiderView();
|
||||
|
||||
initViewPager();
|
||||
initSearchView();
|
||||
initBMB();
|
||||
@@ -189,7 +210,7 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void initToolBar() {
|
||||
toolBarNickname.setText(user.getUsername());
|
||||
toolBarNickname.setText("NutritionMaster");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -219,6 +240,24 @@ public class MainActivity extends BaseActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击事件
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.id_action_search:
|
||||
return true;
|
||||
case R.id.id_action_record:
|
||||
Intent intent = new Intent(MainActivity.this, HistoryActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
// Logger.d("prepareMenu");
|
||||
@@ -228,16 +267,12 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
//mDrawer.openMenu();
|
||||
|
||||
/**
|
||||
* 点击事件
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 初始化蛛网图
|
||||
*/
|
||||
private void initSpiderView() {
|
||||
float[] scores = {9.1f, 6.5f, 7.7f, 8.9f, 8.6f};
|
||||
|
||||
String[] flags = {"糖分", "淡水", "蛋白质", "维生素", "矿物质"};
|
||||
|
||||
List<RadarEntry> radarEntries = new ArrayList<>();
|
||||
@@ -298,6 +333,15 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
public void refreshSpider() {
|
||||
for (int i = 0; i < scores.length; i++) {
|
||||
scores[i] += (1 - i / 2);
|
||||
if (scores[i] >= 10) {
|
||||
scores[i] = 9.9f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化SearchView
|
||||
*/
|
||||
@@ -305,7 +349,7 @@ public class MainActivity extends BaseActivity {
|
||||
searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
MessageUtils.MakeToast(query);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -485,21 +529,24 @@ public class MainActivity extends BaseActivity {
|
||||
bmiBar.setSecondaryProgress(bmiAverage);
|
||||
bmiBar.setProgress(bmiSelf);
|
||||
} else {
|
||||
changeColor("bmi");
|
||||
bmiBar.setMax(100);
|
||||
bmiBar.setSecondaryProgress(bmiSelf);
|
||||
bmiBar.setProgress(bmiAverage);
|
||||
bmiBar.setProgressColor(getColor(R.color.color_bar_deeper));
|
||||
bmiBar.setSecondaryProgressColor(getColor(R.color.color_bar_self));
|
||||
}
|
||||
|
||||
// NutritionMaster.user.setBmi(bmiSelf);
|
||||
|
||||
float heightAverage = averageHeight / maxHeight * 100.0f;
|
||||
float heightSelf = height / maxHeight * 100.0f;
|
||||
if (heightAverage > heightSelf) {
|
||||
|
||||
heightBar.setMax(100);
|
||||
heightBar.setSecondaryProgress(heightAverage);
|
||||
heightBar.setProgress(heightSelf);
|
||||
} else {
|
||||
changeColor("height");
|
||||
heightBar.setMax(100);
|
||||
heightBar.setSecondaryProgress(heightSelf);
|
||||
heightBar.setProgress(heightAverage);
|
||||
@@ -511,10 +558,12 @@ public class MainActivity extends BaseActivity {
|
||||
float weightAverage = averageWeight / maxWeight * 100.0f;
|
||||
float weightSelf = weight / maxWeight * 100.0f;
|
||||
if (weightAverage > weightSelf) {
|
||||
|
||||
weightBar.setMax(100);
|
||||
weightBar.setSecondaryProgress(weightAverage);
|
||||
weightBar.setProgress(weightSelf);
|
||||
} else {
|
||||
changeColor("weight");
|
||||
weightBar.setMax(100);
|
||||
weightBar.setSecondaryProgress(weightSelf);
|
||||
weightBar.setProgress(weightAverage);
|
||||
@@ -530,6 +579,23 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换bar的颜色
|
||||
*/
|
||||
@SuppressLint("ResourceAsColor")
|
||||
private void changeColor(String flag) {
|
||||
if (flag.equals("bmi")) {
|
||||
bmiSelf.setBackgroundColor(R.color.color_bar_deeper);
|
||||
bmiStandard.setBackgroundColor(R.color.color_bar_self);
|
||||
} else if (flag.equals("height")) {
|
||||
heightBar.setBackgroundColor(R.color.color_bar_deeper);
|
||||
heightStandard.setBackgroundColor(R.color.color_bar_self);
|
||||
} else if (flag.equals("weight")) {
|
||||
weightSelf.setBackgroundColor(R.color.color_bar_deeper);
|
||||
weightStandard.setBackgroundColor(R.color.color_bar_self);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化用户疾病list
|
||||
@@ -559,6 +625,7 @@ public class MainActivity extends BaseActivity {
|
||||
// }
|
||||
// });
|
||||
// }else{
|
||||
initSpiderView();
|
||||
illButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -585,8 +652,9 @@ public class MainActivity extends BaseActivity {
|
||||
illRecyclerView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
userIllness.add(illname);
|
||||
illAdapter.notifyDataSetChanged();
|
||||
if (!userIllness.contains(illname)) {
|
||||
userIllness.add(illname);
|
||||
}
|
||||
illAdapter.notifyDataSetChanged();
|
||||
if (NutritionMaster.occupation != null && NutritionMaster.physique != null) {
|
||||
NutritionMaster.element = CalculateUtils.getElementsAddIllness(NutritionMaster.illness,
|
||||
@@ -606,6 +674,27 @@ public class MainActivity extends BaseActivity {
|
||||
illPicker.show();
|
||||
}
|
||||
});
|
||||
// }
|
||||
|
||||
addFlavourButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
flavourPicker = new OptionsPickerBuilder(MainActivity.this, new OnOptionsSelectListener() {
|
||||
@Override
|
||||
public void onOptionsSelect(int options1, int options2, int options3, View v) {
|
||||
final String flavourString = flavours.get(options1);
|
||||
if (!userIllness.contains(flavourString)) {
|
||||
userIllness.add(flavourString);
|
||||
}
|
||||
NutritionMaster.flavourCount += (options1 + 1);
|
||||
illAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}).build();
|
||||
flavourPicker.setPicker(flavours);
|
||||
flavourPicker.setTitleText("请选择你喜欢的口味");
|
||||
flavourPicker.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -17,16 +17,21 @@ import com.example.ninefourone.nutritionmaster.bean.Element;
|
||||
import com.example.ninefourone.nutritionmaster.bean.RecommendFood;
|
||||
import com.example.ninefourone.nutritionmaster.utils.CalculateUtils;
|
||||
import com.example.ninefourone.nutritionmaster.utils.MessageUtils;
|
||||
import com.example.ninefourone.nutritionmaster.utils.WebUtil;
|
||||
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.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class RecipeActivity extends BaseActivity {
|
||||
|
||||
@@ -128,6 +133,20 @@ public class RecipeActivity extends BaseActivity {
|
||||
|
||||
Element element = new Element(recommendFood.getMenu().getElements());
|
||||
NutritionMaster.user.getEaten_elements().add(element, 0.7f);
|
||||
|
||||
String username = NutritionMaster.user.getUsername();
|
||||
WebUtil.getInstance().addEatenHistory(username, recommendFood.getMenu().getName(), new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
boomMenuButton.addBuilder(builder);
|
||||
|
||||
@@ -34,6 +34,7 @@ public class MaterialResultActivity extends BaseActivity {
|
||||
RecyclerView recyclerView;
|
||||
ArrayList<ClassifyResult> classifyResults;
|
||||
ArrayList<FoodMenu> list;
|
||||
private ArrayList<String> nameList;
|
||||
private MaterialResultAdapter adapter;
|
||||
|
||||
@Override
|
||||
@@ -46,13 +47,33 @@ public class MaterialResultActivity extends BaseActivity {
|
||||
Intent intent = getIntent();
|
||||
// classifyResults = (ArrayList<ClassifyResult>) intent.getSerializableExtra("LIST");
|
||||
// list = classifyResults.get(0).getFoodMaterial().getMenus();
|
||||
list= (ArrayList<FoodMenu>) intent.getSerializableExtra("LIST");
|
||||
nameList = (ArrayList<String>) intent.getSerializableExtra("LIST");
|
||||
adapter = new MaterialResultAdapter(list, MaterialResultActivity.this);
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setNestedScrollingEnabled(false);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(MaterialResultActivity.this));
|
||||
|
||||
WebUtil.getInstance().getMenusByMaterials(nameList, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, final Response response) throws IOException {
|
||||
String json = response.body().string();
|
||||
FoodMenu[] menus = new Gson().fromJson(json, FoodMenu[].class);
|
||||
for (FoodMenu foodMenu : menus) {
|
||||
list.add(foodMenu);
|
||||
}
|
||||
recyclerView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,6 +93,5 @@ public class MaterialResultActivity extends BaseActivity {
|
||||
ButterKnife.bind(this);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.example.ninefourone.nutritionmaster.modules.historysearch;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.adapter.HistoryAdapter;
|
||||
import com.example.ninefourone.nutritionmaster.base.BaseActivity;
|
||||
import com.example.ninefourone.nutritionmaster.bean.History;
|
||||
import com.example.ninefourone.nutritionmaster.utils.WebUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class HistoryActivity extends BaseActivity {
|
||||
|
||||
|
||||
@BindView(R.id.recycler_view)
|
||||
RecyclerView recyclerView;
|
||||
private ArrayList<History> mList = new ArrayList<>();
|
||||
private HistoryAdapter adapter;
|
||||
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_history;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initViews(Bundle savedInstanceState) {
|
||||
adapter = new HistoryAdapter(this, mList);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setNestedScrollingEnabled(false);
|
||||
loadData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initToolBar() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPointerCaptureChanged(boolean hasCapture) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData() {
|
||||
super.loadData();
|
||||
Logger.d(user.getUsername());
|
||||
getWebUtil().getEatenHistory(user.getUsername(), new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String json = response.body().string();
|
||||
History[] histories = new Gson().fromJson(json, History[].class);
|
||||
Logger.d(Arrays.toString(histories));
|
||||
mList.clear();
|
||||
for (History temp: histories) {
|
||||
|
||||
mList.add(temp);
|
||||
}
|
||||
|
||||
recyclerView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// TODO: add setContentView(...) invocation
|
||||
ButterKnife.bind(this);
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,7 @@ public class BodyInformationFragment extends BaseFragment {
|
||||
weightLineChart.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
if (NutritionMaster.element != null) {
|
||||
Logger.d(NutritionMaster.element);
|
||||
// Logger.d(NutritionMaster.element);
|
||||
try {
|
||||
Element elementTemp = NutritionMaster.element.calculateData(NutritionMaster.user);
|
||||
float temp = (float) (elementTemp.getCalorie() - NutritionMaster.user.getEaten_elements().getCalorie());
|
||||
|
||||
@@ -128,6 +128,9 @@ public class CustomizationActivity extends BaseActivity {
|
||||
@Override
|
||||
public void loadData() {
|
||||
super.loadData();
|
||||
breakfastList.clear();
|
||||
dinnerList.clear();
|
||||
lunchList.clear();
|
||||
final WebUtil webUtil = WebUtil.getInstance();
|
||||
webUtil.getMenusByElements(getElementLimit(), new Callback() {
|
||||
@Override
|
||||
@@ -192,9 +195,9 @@ public class CustomizationActivity extends BaseActivity {
|
||||
}
|
||||
});
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
Random random = new Random(NutritionMaster.randomSeed + CalculateUtils.title2Int(text));
|
||||
start = random.nextInt(foodMenus.length );
|
||||
start = random.nextInt(foodMenus.length);
|
||||
for (int i = start; i < start + 12; i++) {
|
||||
webUtil.getMenu(foodMenus[i].getName(), new Callback() {
|
||||
@Override
|
||||
@@ -254,6 +257,8 @@ public class CustomizationActivity extends BaseActivity {
|
||||
public void onViewClicked(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.change_button:
|
||||
NutritionMaster.randomSeed = CalculateUtils.getSecond();
|
||||
loadData();
|
||||
break;
|
||||
case R.id.copy_button:
|
||||
break;
|
||||
@@ -317,5 +322,14 @@ public class CustomizationActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加到饮食记录
|
||||
*/
|
||||
private void addRecord() {
|
||||
for (int i = 0; i < breakfastList.size(); i++) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.example.ninefourone.nutritionmaster.modules.viewpagerfragments.recommend;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -17,13 +17,9 @@ import com.example.ninefourone.nutritionmaster.bean.FoodMenu;
|
||||
import com.example.ninefourone.nutritionmaster.bean.RecommendFood;
|
||||
import com.example.ninefourone.nutritionmaster.bean.Trick;
|
||||
import com.google.gson.Gson;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
@@ -40,6 +36,8 @@ public class RecommendFragment extends BaseFragment {
|
||||
@BindView(R.id.recycler_view)
|
||||
RecyclerView recyclerView;
|
||||
Unbinder unbinder;
|
||||
@BindView(R.id.swipe_refresh_layout)
|
||||
SwipeRefreshLayout swipeRefreshLayout;
|
||||
|
||||
private RecommendAdapter adapter;
|
||||
private ArrayList<RecommendFood> datas = new ArrayList<>();
|
||||
@@ -123,6 +121,13 @@ public class RecommendFragment extends BaseFragment {
|
||||
}
|
||||
});
|
||||
recyclerView.setLayoutManager(manager);
|
||||
|
||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
changeInfor();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,61 +139,64 @@ public class RecommendFragment extends BaseFragment {
|
||||
protected void loadData() {
|
||||
super.loadData();
|
||||
// if (NutritionMaster.user.getOccupation_name().equals("")) {
|
||||
getWebUtil().getRandomMenus(20, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
getWebUtil().getRandomMenus(20, NutritionMaster.user.getUsername(), new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
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) {
|
||||
break;
|
||||
} else {
|
||||
int flag = indexs[count % 3];
|
||||
RecommendFood recommendFood = new RecommendFood(menus[i], flag);
|
||||
if (!recommendFood.getPicture().equals("0")) {
|
||||
datas.add(recommendFood);
|
||||
count++;
|
||||
}
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
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) {
|
||||
break;
|
||||
} else {
|
||||
int flag = indexs[count % 3];
|
||||
RecommendFood recommendFood = new RecommendFood(menus[i], flag);
|
||||
if (!recommendFood.getPicture().equals("0")) {
|
||||
datas.add(recommendFood);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小知识
|
||||
*/
|
||||
getWebUtil().getRandomTricks(5, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
/**
|
||||
* 获取小知识
|
||||
*/
|
||||
getWebUtil().getRandomTricks(5, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
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) {
|
||||
datas.get(i).setDescription(tricks[index].getContent());
|
||||
datas.get(i).setTitle(tricks[index].getTitle());
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
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) {
|
||||
datas.get(i).setDescription(tricks[index].getContent());
|
||||
datas.get(i).setTitle(tricks[index].getTitle());
|
||||
index++;
|
||||
recyclerView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
adapter.notifyDataSetChanged();
|
||||
if (swipeRefreshLayout.isRefreshing()){
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
recyclerView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -197,62 +205,62 @@ public class RecommendFragment extends BaseFragment {
|
||||
*/
|
||||
private void addData() {
|
||||
// if (NutritionMaster.user.getOccupation_name().equals("")) {
|
||||
getWebUtil().getRandomMenus(20, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
getWebUtil().getRandomMenus(20, NutritionMaster.user.getUsername(), new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
final int originsize = datas.size();
|
||||
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) {
|
||||
break;
|
||||
} else {
|
||||
int flag = indexs[count % 3];
|
||||
RecommendFood recommendFood = new RecommendFood(menus[i], flag);
|
||||
if (!recommendFood.getPicture().equals("0")) {
|
||||
datas.add(recommendFood);
|
||||
count++;
|
||||
}
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
final int originsize = datas.size();
|
||||
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) {
|
||||
break;
|
||||
} else {
|
||||
int flag = indexs[count % 3];
|
||||
RecommendFood recommendFood = new RecommendFood(menus[i], flag);
|
||||
if (!recommendFood.getPicture().equals("0")) {
|
||||
datas.add(recommendFood);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小知识
|
||||
*/
|
||||
getWebUtil().getRandomTricks(5, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
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) {
|
||||
datas.get(i).setDescription(tricks[index].getContent());
|
||||
datas.get(i).setTitle(tricks[index].getTitle());
|
||||
index++;
|
||||
}
|
||||
}
|
||||
recyclerView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
adapter.loadMoreComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 获取小知识
|
||||
*/
|
||||
getWebUtil().getRandomTricks(5, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
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) {
|
||||
datas.get(i).setDescription(tricks[index].getContent());
|
||||
datas.get(i).setTitle(tricks[index].getTitle());
|
||||
index++;
|
||||
}
|
||||
}
|
||||
recyclerView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
adapter.loadMoreComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -264,4 +272,12 @@ public class RecommendFragment extends BaseFragment {
|
||||
private boolean isDataOverCount() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改信息后修改推荐
|
||||
*/
|
||||
public void changeInfor() {
|
||||
datas.clear();
|
||||
loadData();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +169,8 @@ public class CalculateUtils {
|
||||
calories[i] = classifyResultArrayList.get(i).getCalorie();
|
||||
}
|
||||
for (int i = 0; i < classifyResultArrayList.size(); i++) {
|
||||
classifyResultArrayList.get(i).setQuantity(calories[i] / calorieSum * baseQuantity * factor);
|
||||
classifyResultArrayList.get(i).setQuantity(calories[i] / calorieSum * baseQuantity * factor
|
||||
+ NutritionMaster.flavourCount * 5);
|
||||
}
|
||||
return classifyResultArrayList;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class ConstantUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 全国平均体重 index 0 对应 3岁
|
||||
* 全国平均身高 index 0 对应 3岁
|
||||
*/
|
||||
public static ArrayList<Float> averageBoyHeight = new ArrayList<>();
|
||||
|
||||
@@ -278,6 +278,7 @@ public class ConstantUtils {
|
||||
public static String BD_ACCESS_TOKEN = "";
|
||||
|
||||
public static String BD_DISH_URL = "https://aip.baidubce.com/rest/2.0/image-classify/v2/dish";
|
||||
public static String BD_MATERIAL_URL = "https://aip.baidubce.com/rest/2.0/image-classify/v1/classify/ingredient";
|
||||
|
||||
// public static ArrayList<ClassifyResult> testData = new ArrayList<>();
|
||||
//
|
||||
@@ -342,5 +343,15 @@ public class ConstantUtils {
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public static ArrayList<String> getFlavour() {
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
arrayList.add("苦");
|
||||
arrayList.add("甜");
|
||||
arrayList.add("咸");
|
||||
arrayList.add("辣");
|
||||
arrayList.add("酸");
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public static String YOUDAO_APPKEY = "3ea8061348a6bdd6";
|
||||
}
|
||||
|
||||
@@ -46,11 +46,11 @@ public class WebUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取具体的菜谱信息 { "flavor": "咸鲜味", "calorie": 234, "name": "雪丽对虾",
|
||||
* "technology": "炸", "image_url":
|
||||
* 获取具体的菜谱信息 { "flavor": "咸鲜味", "calorie": 234, "name": "雪丽对虾", "technology":
|
||||
* "炸", "image_url":
|
||||
* "http://s1.ig.meishij.net/p/20091012/fed63858e633540c8df73e62692520fb_150x150.jpg",
|
||||
* "cook_quantity": [ { "menu": "雪丽对虾", "quantity": "500", "material": "对虾"
|
||||
* }, { "menu": "雪丽对虾", "quantity": "60", "material": "鸡蛋清" }, }
|
||||
* "cook_quantity": [ { "menu": "雪丽对虾", "quantity": "500", "material": "对虾" }, {
|
||||
* "menu": "雪丽对虾", "quantity": "60", "material": "鸡蛋清" }, }
|
||||
*/
|
||||
public void getMenu(String menuName, Callback callback) {
|
||||
Request request = new Request.Builder().url("http://120.77.182.38/menus/" + menuName + "/").build();
|
||||
@@ -95,9 +95,9 @@ public class WebUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某食材可以做的菜 [ { "menu": "西红柿鸡蛋汤", "quantity": "适量", "material":
|
||||
* "西红柿" }, { "menu": "瘦身版红菜汤", "quantity": "4-5片", "material": "西红柿" },
|
||||
* { "menu": "西红柿炖豆腐", "quantity": "三个", "material": "西红柿" }, ]
|
||||
* 获取某食材可以做的菜 [ { "menu": "西红柿鸡蛋汤", "quantity": "适量", "material": "西红柿" }, {
|
||||
* "menu": "瘦身版红菜汤", "quantity": "4-5片", "material": "西红柿" }, { "menu":
|
||||
* "西红柿炖豆腐", "quantity": "三个", "material": "西红柿" }, ]
|
||||
*
|
||||
* @param materialName
|
||||
* @param callback
|
||||
@@ -108,10 +108,9 @@ public class WebUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某菜谱分类对应的菜 { "classification": "川菜", "cure_occupation": [],
|
||||
* "menu_effect": [ "三色鲍脯", "三色鸡酪", "三菇冬瓜汤", "三菌烩蛇段", "三鲜乌鱼汤",
|
||||
* "三鲜参片汤", "三鲜猪肝汤", "下饭的素版麻婆豆腐", "丝瓜鱼肚卷", "五更豆酥鱼", "元鱼烧鸡",
|
||||
* "冬苋菜豆腐汤", "冬菜排骨汤",
|
||||
* 获取某菜谱分类对应的菜 { "classification": "川菜", "cure_occupation": [], "menu_effect": [
|
||||
* "三色鲍脯", "三色鸡酪", "三菇冬瓜汤", "三菌烩蛇段", "三鲜乌鱼汤", "三鲜参片汤", "三鲜猪肝汤", "下饭的素版麻婆豆腐",
|
||||
* "丝瓜鱼肚卷", "五更豆酥鱼", "元鱼烧鸡", "冬苋菜豆腐汤", "冬菜排骨汤",
|
||||
*/
|
||||
public void getMenuClassification(String classificationName, Callback callback) {
|
||||
Request request = new Request.Builder()
|
||||
@@ -120,8 +119,8 @@ public class WebUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取职业需要的菜谱分类 { "occupation_name": "电力工程师", "menuclassification_set":
|
||||
* [ "接触电离辐射人员食谱", "防癌抗癌食谱", "明目食谱", "关节炎食谱", "壮腰健肾食谱" ] }
|
||||
* 获取职业需要的菜谱分类 { "occupation_name": "电力工程师", "menuclassification_set": [
|
||||
* "接触电离辐射人员食谱", "防癌抗癌食谱", "明目食谱", "关节炎食谱", "壮腰健肾食谱" ] }
|
||||
*/
|
||||
public void getOccupation(String occupationName, Callback callback) {
|
||||
Request request = null;
|
||||
@@ -134,8 +133,8 @@ public class WebUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取体质需要的食材 { "physical_name": "气虚质", "cure_material": [ "人参", "人参须",
|
||||
* "去芯莲子", "去芯莲子(3~4人份)", "土茯苓", ... ] }
|
||||
* 获取体质需要的食材 { "physical_name": "气虚质", "cure_material": [ "人参", "人参须", "去芯莲子",
|
||||
* "去芯莲子(3~4人份)", "土茯苓", ... ] }
|
||||
*/
|
||||
public void getPhysique(String physiqueName, Callback callback) {
|
||||
Request request = new Request.Builder().url("http://120.77.182.38/physique/" + physiqueName + "/").build();
|
||||
@@ -146,8 +145,8 @@ public class WebUtil {
|
||||
* 获取病相关的菜谱和元素信息 传入含有病的意义的菜谱分类名称,比如青少年食谱
|
||||
* <p>
|
||||
* { "menu_classification": { "classification": "青少年食谱", "cure_occupation": [
|
||||
* "学生" ], "menu_effect": [ "三鲜鳝汤", "上海糖醋小排骨", ... ] }, "elements": {
|
||||
* "id": 84, "calorie": 1.1, ... } }
|
||||
* "学生" ], "menu_effect": [ "三鲜鳝汤", "上海糖醋小排骨", ... ] }, "elements": { "id": 84,
|
||||
* "calorie": 1.1, ... } }
|
||||
*/
|
||||
public void getIllness(String illnessClassification, Callback callback) {
|
||||
Request request = new Request.Builder().url("http://120.77.182.38/illness/" + illnessClassification + "/")
|
||||
@@ -352,8 +351,7 @@ public class WebUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户吃了一个菜,更新用户本周已吃摄入的营养元素的量 传入这顿饭摄入的营养量
|
||||
* 返回当前user的最新信息,用MyUser类解析json
|
||||
* 用户吃了一个菜,更新用户本周已吃摄入的营养元素的量 传入这顿饭摄入的营养量 返回当前user的最新信息,用MyUser类解析json
|
||||
*/
|
||||
public void eatenElements(String username, Map<String, Double> elements, Callback callback) {
|
||||
String url = "http://120.77.182.38/myuser/eaten_menu/";
|
||||
@@ -388,6 +386,54 @@ public class WebUtil {
|
||||
Request request = new Request.Builder().url(url).post(formBody).build();
|
||||
mClient.newCall(request).enqueue(callback);
|
||||
}
|
||||
//
|
||||
// public static String HttpPost(String requestUrl, String accessToken, String params) throws Exception {
|
||||
// System.out.println(params);
|
||||
// String generalUrl = "";
|
||||
// generalUrl = requestUrl + "?access_token=" + accessToken;
|
||||
// System.out.println("发送的连接为:" + generalUrl);
|
||||
// URL url = new URL(generalUrl);
|
||||
// // 打开和URL之间的连接
|
||||
// HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
// System.out.println("打开链接,开始发送请求" + new Date().getTime() / 1000);
|
||||
// connection.setRequestMethod("POST");
|
||||
// // 设置通用的请求属性
|
||||
// connection.setRequestProperty("Content-Type", "application/json");
|
||||
// connection.setRequestProperty("Connection", "Keep-Alive");
|
||||
// connection.setUseCaches(false);
|
||||
// connection.setDoOutput(true);
|
||||
// connection.setDoInput(true);
|
||||
//
|
||||
// // 得到请求的输出流对象
|
||||
// DataOutputStream out = new DataOutputStream(connection.getOutputStream());
|
||||
// out.writeBytes(params);
|
||||
// out.flush();
|
||||
// out.close();
|
||||
//
|
||||
// // 建立实际的连接
|
||||
// connection.connect();
|
||||
// // 获取所有响应头字段
|
||||
// Map<String, List<String>> headers = connection.getHeaderFields();
|
||||
// // 遍历所有的响应头字段
|
||||
// for (String key : headers.keySet()) {
|
||||
// System.out.println(key + "--->" + headers.get(key));
|
||||
// }
|
||||
// // 定义 BufferedReader输入流来读取URL的响应
|
||||
// BufferedReader in = null;
|
||||
// if (requestUrl.contains("nlp"))
|
||||
// in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "GBK"));
|
||||
// else
|
||||
// in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
|
||||
// String result = "";
|
||||
// String getLine;
|
||||
// while ((getLine = in.readLine()) != null) {
|
||||
// result += getLine;
|
||||
// }
|
||||
// in.close();
|
||||
// System.out.println("请求结束" + new Date().getTime() / 1000);
|
||||
// System.out.println("result:" + result);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
public void addEatenHistory(String username, String menuName, Callback callback) {
|
||||
String url = "http://120.77.182.38/myuser/add_eaten_history/";
|
||||
@@ -413,7 +459,6 @@ public class WebUtil {
|
||||
Request request = new Request.Builder().url(url).post(formBody).build();
|
||||
mClient.newCall(request).enqueue(callback);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Map<String, Double> params = new HashMap<>();
|
||||
params.put("calorie", 100.0);
|
||||
@@ -435,6 +480,184 @@ public class WebUtil {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
/*
|
||||
MyUser testUser = new MyUser();
|
||||
testUser.setUsername("test6");
|
||||
testUser.setPassword("66666");
|
||||
testUser.setAge(8);
|
||||
testUser.setHeight(175);
|
||||
testUser.setPhysical_name("平和质");
|
||||
List<String> ills = new ArrayList<>();
|
||||
ills.add("乌发食谱");
|
||||
ills.add("失眠食谱");
|
||||
testUser.setIllness(ills);
|
||||
|
||||
//创建用户
|
||||
WebUtil.getInstance().createUser(testUser, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String responseJson = response.body().string();
|
||||
System.out.println(new Gson().fromJson(responseJson, MyUser.class));
|
||||
}
|
||||
});
|
||||
|
||||
//修改用户信息
|
||||
WebUtil.getInstance().changeUserInfo(testUser, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
System.out.println(new Gson().fromJson(response.body().string(), MyUser.class));
|
||||
}
|
||||
});*/
|
||||
|
||||
|
||||
|
||||
/*WebUtil.getInstance().eatenMenu("test5", "软熘虾片", new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String responseJson = response.body().string();
|
||||
System.out.println(responseJson);
|
||||
MyUser testUser = new Gson().fromJson(responseJson, MyUser.class);
|
||||
System.out.println(testUser);
|
||||
}
|
||||
});*/
|
||||
|
||||
/*WebUtil.getIllness("青少年食谱", new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
System.out.println(new Gson().fromJson(response.body().string(),Illness.class));
|
||||
}
|
||||
});*/
|
||||
|
||||
|
||||
/* 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);
|
||||
System.out.println(menu);
|
||||
}
|
||||
});*/
|
||||
|
||||
/*WebUtil.getRandomMenus(10, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
FoodMenu[] menus = new Gson().fromJson(response.body().string(), FoodMenu[].class);
|
||||
System.out.println(Arrays.toString(menus));
|
||||
System.out.println(menus.length);
|
||||
|
||||
}
|
||||
});*/
|
||||
|
||||
/*WebUtil.getFoodMaterial("西红柿", new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String json = response.body().string();
|
||||
FoodMaterial foodMaterial = new Gson().fromJson(json, FoodMaterial.class);
|
||||
System.out.println(foodMaterial);
|
||||
}
|
||||
});*/
|
||||
|
||||
/*WebUtil.getMenuClassification("川菜", new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
MenuClassification classification = new Gson().fromJson(response.body().string(), MenuClassification.class);
|
||||
System.out.println(classification);
|
||||
}
|
||||
});*/
|
||||
|
||||
/*WebUtil.getOccupation("程序员", new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String json = response.body().string();
|
||||
System.out.println(new Gson().fromJson(json, Occupation.class));
|
||||
|
||||
}
|
||||
});*/
|
||||
|
||||
/*WebUtil.getPhysique("气虚质", new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
System.out.println(new Gson().fromJson(response.body().string(), Physique.class));
|
||||
}
|
||||
});*/
|
||||
|
||||
/*WebUtil.instance.getUser("test5", new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
System.out.println(new Gson().fromJson(response.body().string(), MyUser.class));
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
/* WebUtil.getRandomTricks(10, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
System.out.println(response.body().string());
|
||||
}
|
||||
});*/
|
||||
|
||||
|
||||
/*
|
||||
* MyUser testUser = new MyUser(); testUser.setUsername("test6");
|
||||
* testUser.setPassword("66666"); testUser.setAge(8); testUser.setHeight(175);
|
||||
@@ -515,6 +738,7 @@ public class WebUtil {
|
||||
* } });
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* WebUtil.getFoodMaterial("西红柿", new Callback() {
|
||||
*
|
||||
@@ -589,5 +813,6 @@ public class WebUtil {
|
||||
* @Override public void onResponse(Call call, Response response) throws
|
||||
* IOException { System.out.println(response.body().string()); } });
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
BIN
app/src/main/res/drawable/ic.png
Normal file
BIN
app/src/main/res/drawable/ic.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
6
app/src/main/res/drawable/ic_flavour.xml
Normal file
6
app/src/main/res/drawable/ic_flavour.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<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="M900.3,220.6c-8.6,0 -17.2,-3.5 -23.6,-10.4 -84.6,-93 -205.2,-146.2 -330.8,-146.2 -123.7,0 -239,49.4 -324.2,139.1 -12.1,12.7 -32.2,13.1 -44.9,1 -12.7,-11.9 -13.1,-31.9 -1,-44.6 47.3,-49.6 102.8,-88.7 165.3,-116.1C405.9,15 474.9,0.4 546,0.4c73.1,0 143.8,15.2 209.9,45.1 63.9,28.9 120.4,69.8 167.7,121.9 11.9,12.9 10.9,33 -2,44.9 -5.9,5.5 -13.7,8.4 -21.3,8.4zM900.3,220.6M546,1022.2c-69,0 -135.8,-13.5 -198.9,-40.1 -60.8,-25.8 -115.5,-62.7 -162.4,-109.6s-83.8,-101.6 -109.6,-162.4c-26.6,-63.1 -40.1,-129.8 -40.1,-198.9 0,-29.5 2.5,-59.2 7.6,-88.1 3.1,-17.2 19.5,-28.9 36.7,-25.8 17.2,3.1 28.9,19.5 25.8,36.7 -4.3,25.2 -6.6,51.2 -6.6,77.2 0,246.8 200.7,447.5 447.5,447.5 155.4,0 297.6,-78.8 379.9,-210.9 9.2,-15 28.9,-19.5 43.6,-10 15,9.2 19.5,28.9 10,43.6 -45.1,72.3 -107.9,132.7 -182.1,174.7 -76.2,43.4 -163.2,66.2 -251.5,66.2zM546,1022.2"/>
|
||||
<path android:fillColor="#ffffff" android:pathData="M956.8,789.9c-7.8,0 -15.4,-2.9 -21.5,-8.4L649.6,518.3c-11.9,-11.1 -13.7,-29.3 -3.9,-42.4L874.9,169.8c10.4,-14.1 30.3,-17 44.4,-6.3 14.1,10.4 17,30.3 6.3,44.4L713.7,491.1l264.6,243.7c12.9,11.9 13.7,31.9 1.8,44.9 -6.3,6.8 -14.7,10.2 -23.3,10.2zM956.8,789.9"/>
|
||||
<path android:fillColor="#ffffff" android:pathData="M558.5,349.4c-55.3,0 -100.6,-45.1 -100.6,-100.6 0,-55.3 45.1,-100.4 100.6,-100.4 55.3,0 100.4,45.1 100.4,100.4 0.2,55.5 -44.9,100.6 -100.4,100.6zM558.5,212c-20.5,0 -37.1,16.6 -37.1,37.1s16.6,37.1 37.1,37.1c20.5,0 37.1,-16.6 37.1,-37.1s-16.6,-37.1 -37.1,-37.1zM558.5,212"/>
|
||||
</vector>
|
||||
16
app/src/main/res/layout/activity_history.xml
Normal file
16
app/src/main/res/layout/activity_history.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?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"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context="com.example.ninefourone.nutritionmaster.modules.historysearch.HistoryActivity">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
</LinearLayout>
|
||||
@@ -190,8 +190,8 @@
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ill_button"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_toLeftOf="@id/add_information_button"
|
||||
@@ -202,13 +202,22 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/add_information_button"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="25dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:src="@drawable/ic_data_add" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/add_flavour_button"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_toLeftOf="@id/ill_button"
|
||||
android:layout_marginRight="15dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:src="@drawable/ic_flavour" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/ill_recycler_view"
|
||||
android:layout_width="100dp"
|
||||
@@ -369,6 +378,7 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bmi_self"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="8dp"
|
||||
android:background="@color/color_bar_self" />
|
||||
@@ -380,6 +390,7 @@
|
||||
android:textSize="5sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bmi_standard"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="8dp"
|
||||
android:background="@color/color_bar_deeper" />
|
||||
@@ -453,6 +464,7 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/height_self"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="8dp"
|
||||
android:background="@color/color_bar_self" />
|
||||
@@ -464,6 +476,7 @@
|
||||
android:textSize="5sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/height_standard"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="8dp"
|
||||
android:background="@color/color_bar_deeper" />
|
||||
@@ -537,6 +550,7 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/weight_self"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="8dp"
|
||||
android:background="@color/color_bar_self" />
|
||||
@@ -548,6 +562,7 @@
|
||||
android:textSize="5sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/weight_standard"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="8dp"
|
||||
android:background="@color/color_bar_deeper" />
|
||||
|
||||
@@ -4,10 +4,16 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
<android.support.v4.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_refresh_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#d2e4cb"
|
||||
android:gravity="center" />
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#d2e4cb"
|
||||
android:gravity="center" />
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
</LinearLayout>
|
||||
BIN
app/src/main/res/mipmap-xxxhdpi/ic.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/ic.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
@@ -2,12 +2,13 @@
|
||||
|
||||
buildscript {
|
||||
|
||||
|
||||
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url 'https://bintray.com/rameshbhupathi/maven' }
|
||||
maven { url "https://dl.bintray.com/thelasterstar/maven/" }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.1.3'
|
||||
@@ -21,11 +22,13 @@ buildscript {
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url 'https://bintray.com/rameshbhupathi/maven' }
|
||||
maven { url "https://dl.bintray.com/thelasterstar/maven/" }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile 'com.android.support:appcompat-v7:26.1.0'
|
||||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'com.android.support:appcompat-v7:26.1.0'
|
||||
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'org.robolectric:robolectric:3.0-rc3'
|
||||
testCompile 'org.mockito:mockito-core:1.+'
|
||||
compile files('libs/microlog4android-1.0.0.jar')
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.robolectric:robolectric:3.0-rc3'
|
||||
testImplementation 'org.mockito:mockito-core:1.+'
|
||||
implementation files('libs/microlog4android-1.0.0.jar')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user