1
This commit is contained in:
@@ -117,7 +117,6 @@ public class NutritionMaster extends Application {
|
||||
* 初始化用户信息
|
||||
*/
|
||||
private void initUser() {
|
||||
Logger.d("初始化user");
|
||||
user = new MyUser();
|
||||
user.setUsername("ScorpioMiku");
|
||||
}
|
||||
@@ -136,7 +135,6 @@ public class NutritionMaster extends Application {
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
Occupation[] occupations = new Gson().fromJson(response.body().string(), Occupation[].class);
|
||||
// Logger.d(Arrays.toString(occupations));
|
||||
for (int i = 0; i < occupations.length; i++) {
|
||||
ConstantUtils.occupationList.add(occupations[i].getOccupation_name());
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.NutritionMaster;
|
||||
import com.example.ninefourone.nutritionmaster.bean.MyUser;
|
||||
import com.example.ninefourone.nutritionmaster.utils.WebUtil;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
@@ -18,6 +19,7 @@ import butterknife.Unbinder;
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
private Unbinder unbinder;
|
||||
protected MyUser user;
|
||||
private WebUtil webUtil;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -26,9 +28,13 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
setContentView(getLayoutId());
|
||||
unbinder = ButterKnife.bind(this);
|
||||
initViews(savedInstanceState);
|
||||
webUtil = new WebUtil();
|
||||
initToolBar();
|
||||
}
|
||||
|
||||
public WebUtil getWebUtil() {
|
||||
return webUtil;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置布局layout
|
||||
@@ -93,7 +99,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
protected void upUser() {
|
||||
NutritionMaster.user = user;
|
||||
Logger.d("用户信息已改"+NutritionMaster.user.toString());
|
||||
Logger.d("用户信息已改" + NutritionMaster.user.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.view.ViewGroup;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.NutritionMaster;
|
||||
import com.example.ninefourone.nutritionmaster.bean.MyUser;
|
||||
import com.example.ninefourone.nutritionmaster.utils.WebUtil;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
@@ -27,6 +28,8 @@ public abstract class BaseFragment extends Fragment {
|
||||
protected boolean isPrepared;
|
||||
protected boolean isVisible;
|
||||
private Unbinder unbinder;
|
||||
private WebUtil webUtil;
|
||||
|
||||
|
||||
public abstract
|
||||
@LayoutRes
|
||||
@@ -44,10 +47,15 @@ public abstract class BaseFragment extends Fragment {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
unbinder = ButterKnife.bind(this, view);
|
||||
initView(savedInstanceState);
|
||||
webUtil = new WebUtil();
|
||||
this.user = NutritionMaster.user;
|
||||
}
|
||||
|
||||
|
||||
public WebUtil getWebUtil() {
|
||||
return webUtil;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化自己的ui
|
||||
*
|
||||
@@ -157,7 +165,7 @@ public abstract class BaseFragment extends Fragment {
|
||||
|
||||
protected void upUser() {
|
||||
NutritionMaster.user = user;
|
||||
Logger.d("用户信息已改"+NutritionMaster.user.toString());
|
||||
Logger.d("用户信息已改" + NutritionMaster.user.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
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 okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Response;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/10/4.
|
||||
*/
|
||||
@@ -14,6 +23,34 @@ public class ClassifyResult implements Serializable {
|
||||
private double calorie;
|
||||
private Boolean has_calorie;
|
||||
private double quantity = -1;
|
||||
private FoodMenu foodMenu;
|
||||
|
||||
|
||||
public void getMenu() {
|
||||
WebUtil webUtil = new WebUtil();
|
||||
webUtil.getMenu("素红烧肉", new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
name = "-1";
|
||||
Logger.e("我们数据库没有这个菜");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
FoodMenu menu = new Gson().fromJson(response.body().string(), FoodMenu.class);
|
||||
foodMenu = menu;
|
||||
Logger.d(name + "|" + menu);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public FoodMenu getFoodMenu() {
|
||||
return foodMenu;
|
||||
}
|
||||
|
||||
public void setFoodMenu(FoodMenu foodMenu) {
|
||||
this.foodMenu = foodMenu;
|
||||
}
|
||||
|
||||
public double getQuantity() {
|
||||
return quantity;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.example.ninefourone.nutritionmaster.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class FoodMenu {
|
||||
|
||||
public class FoodMenu implements Serializable {
|
||||
|
||||
/**
|
||||
* flavor : 五香味
|
||||
|
||||
@@ -188,6 +188,7 @@ public class ClassifierCamera extends AppCompatActivity {
|
||||
classifyResult.setHas_calorie(jsonObject.getBoolean("has_calorie"));
|
||||
classifyResult.setProbability(jsonObject.getDouble("probability"));
|
||||
classifyResult.setName(jsonObject.getString("name"));
|
||||
classifyResult.getMenu();
|
||||
// Logger.d(classifyResult);
|
||||
resultList.add(classifyResult);
|
||||
refreshUI();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.example.ninefourone.nutritionmaster.modules.viewpagerfragments.customization;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
@@ -13,9 +15,35 @@ import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class CustomizationActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.breakfast_energy_text)
|
||||
TextView breakfastEnergyText;
|
||||
@BindView(R.id.breakfast_recycler_view)
|
||||
RecyclerView breakfastRecyclerView;
|
||||
@BindView(R.id.lunch_energy_text)
|
||||
TextView lunchEnergyText;
|
||||
@BindView(R.id.lunch_recycler_view)
|
||||
RecyclerView lunchRecyclerView;
|
||||
@BindView(R.id.dinner_energy_text)
|
||||
TextView dinnerEnergyText;
|
||||
@BindView(R.id.dinner_recycler_view)
|
||||
RecyclerView dinnerRecyclerView;
|
||||
@BindView(R.id.calorie_text)
|
||||
TextView calorieText;
|
||||
@BindView(R.id.fat_text)
|
||||
TextView fatText;
|
||||
@BindView(R.id.suger_text)
|
||||
TextView sugerText;
|
||||
@BindView(R.id.protein_text)
|
||||
TextView proteinText;
|
||||
@BindView(R.id.change_button)
|
||||
LinearLayout changeButton;
|
||||
@BindView(R.id.copy_button)
|
||||
LinearLayout copyButton;
|
||||
|
||||
private ArrayList<FoodMenu> breakfastList = new ArrayList<>();
|
||||
private ArrayList<FoodMenu> lunchList = new ArrayList<>();
|
||||
private ArrayList<FoodMenu> dinnerList = new ArrayList<>();
|
||||
@@ -53,4 +81,14 @@ public class CustomizationActivity extends BaseActivity {
|
||||
super.loadData();
|
||||
|
||||
}
|
||||
|
||||
@OnClick({R.id.change_button, R.id.copy_button})
|
||||
public void onViewClicked(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.change_button:
|
||||
break;
|
||||
case R.id.copy_button:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.example.ninefourone.nutritionmaster.base.BaseFragment;
|
||||
import com.example.ninefourone.nutritionmaster.bean.RecommendFood;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
@@ -22,6 +23,9 @@ import android.view.LayoutInflater;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Unbinder;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Response;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/8/26.
|
||||
@@ -84,13 +88,7 @@ public class RecommendFragment extends BaseFragment {
|
||||
recyclerView.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Logger.d("加载数据");
|
||||
for (int i = 0; i < 6; i++) {
|
||||
RecommendFood recommendFood = new RecommendFood(1, "烧肉", "好吃", indexs[i % 4]);
|
||||
adapter.getData().add(recommendFood);
|
||||
}
|
||||
adapter.loadMoreComplete();
|
||||
addData();
|
||||
}
|
||||
|
||||
}, 1000);
|
||||
@@ -124,17 +122,42 @@ public class RecommendFragment extends BaseFragment {
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载数据
|
||||
* 初始化数据
|
||||
* 病 、 体质 、 职业
|
||||
* 0-4 5-7 8-10
|
||||
*/
|
||||
@Override
|
||||
protected void loadData() {
|
||||
super.loadData();
|
||||
for (int i = 0; i < 11; i++) {
|
||||
RecommendFood recommendFood = new RecommendFood(1, "烧肉", "好吃", indexs[i % 4]);
|
||||
int flag = indexs[i % 4];
|
||||
RecommendFood recommendFood = new RecommendFood(1, "烧肉", "好吃", flag);
|
||||
datas.add(recommendFood);
|
||||
// if (flag == 2) {
|
||||
//
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载新数据
|
||||
*/
|
||||
private void addData() {
|
||||
// Logger.d("加载数据");
|
||||
for (int i = 0; i < 7; i++) {
|
||||
int flag = indexs[i % 4];
|
||||
if (flag == 2) {
|
||||
|
||||
} else {
|
||||
RecommendFood recommendFood = new RecommendFood(1, "烧肉", "好吃", flag);
|
||||
adapter.getData().add(recommendFood);
|
||||
}
|
||||
}
|
||||
adapter.loadMoreComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断数据是否加载完了(服务器没了)
|
||||
*
|
||||
|
||||
@@ -130,14 +130,15 @@
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp"
|
||||
android:layout_height="250dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="15dp"
|
||||
app:cardCornerRadius="20dp">
|
||||
|
||||
<LinearLayout
|
||||
android:background="#eae8e8"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#e0efd5"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
@@ -158,11 +159,30 @@
|
||||
android:layout_height="50dp"
|
||||
android:src="@drawable/ic_calorie" />
|
||||
|
||||
<TextView
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="卡路里:500千卡" />
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="卡路里:" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/calorie_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="500" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="千卡" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
@@ -179,11 +199,30 @@
|
||||
android:layout_height="50dp"
|
||||
android:src="@drawable/ic_fat" />
|
||||
|
||||
<TextView
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="脂肪:500克" />
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="脂肪:" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fat_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="500" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="克" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -207,11 +246,30 @@
|
||||
android:layout_height="50dp"
|
||||
android:src="@drawable/ic_sugar" />
|
||||
|
||||
<TextView
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="糖分:500克" />
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="糖:" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/suger_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="500" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="克" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -227,11 +285,30 @@
|
||||
android:layout_height="50dp"
|
||||
android:src="@drawable/ic_protein" />
|
||||
|
||||
<TextView
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="蛋白质:500克" />
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="蛋白质:" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/protein_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="500" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="克" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -257,6 +334,7 @@
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/change_button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
@@ -280,6 +358,7 @@
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/copy_button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
|
||||
@@ -8,5 +8,6 @@
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#d2e4cb"
|
||||
android:gravity="center" />
|
||||
</LinearLayout>
|
||||
@@ -30,6 +30,7 @@
|
||||
app:cardCornerRadius="20dp">
|
||||
|
||||
<LinearLayout
|
||||
android:background="#dcffe1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
@@ -51,7 +52,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:textSize="10sp"
|
||||
android:textSize="12sp"
|
||||
tools:text="红烧肉是最美味的菜了!超级好吃!" />
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
Reference in New Issue
Block a user