Merge branch 'wangtianrui' into develop
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".camera.FoodMaterialCamera" />
|
||||
<activity android:name=".camera.ClassifierCamera" />
|
||||
|
||||
<receiver
|
||||
android:name=".step.StepStarter"
|
||||
@@ -55,10 +55,11 @@
|
||||
<activity android:name=".modules.viewpagerfragments.customization.CustomizationActivity" />
|
||||
<activity android:name=".modules.information.InformationActivity" />
|
||||
<activity android:name=".modules.RecipeActivity.RecipeActivity" />
|
||||
<activity
|
||||
android:name=".LoginActivity"
|
||||
android:label="@string/title_activity_login" />
|
||||
<activity android:name=".modules.addinformation.AddInformationActivity"></activity>
|
||||
<!-- <activity -->
|
||||
<!-- android:name=".LoginActivity" -->
|
||||
<!-- android:label="@string/title_activity_login" /> -->
|
||||
<activity android:name=".modules.addinformation.AddInformationActivity" />
|
||||
<activity android:name=".modules.classifyresult.DishResultActivity"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -13,7 +13,15 @@ import com.google.gson.Gson;
|
||||
import com.orhanobut.logger.AndroidLogAdapter;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
@@ -36,6 +44,7 @@ public class NutritionMaster extends Application {
|
||||
mInstance = this;
|
||||
init();
|
||||
initUser();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,6 +89,14 @@ public class NutritionMaster extends Application {
|
||||
}
|
||||
});
|
||||
initOccupations();
|
||||
getAccessToken();
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initBD();
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public static NutritionMaster getInstance() {
|
||||
@@ -128,4 +145,57 @@ public class NutritionMaster extends Application {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* BDAPI init
|
||||
*/
|
||||
private void initBD() {
|
||||
ConstantUtils.BD_ACCESS_TOKEN = getAccessToken();
|
||||
// Logger.d(ConstantUtils.BD_ACCESS_TOKEN);
|
||||
}
|
||||
|
||||
|
||||
private String getAccessToken() {
|
||||
String authHost = "https://aip.baidubce.com/oauth/2.0/token?";
|
||||
String ak = ConstantUtils.BD_API_KEY;
|
||||
String sk = ConstantUtils.BD_SECRET_KEY;
|
||||
String getAccessTokenUrl = authHost
|
||||
// 1. grant_type为固定参数
|
||||
+ "grant_type=client_credentials"
|
||||
// 2. 官网获取的 API Key
|
||||
+ "&client_id=" + ak
|
||||
// 3. 官网获取的 Secret Key
|
||||
+ "&client_secret=" + sk;
|
||||
try {
|
||||
URL realUrl = new URL(getAccessTokenUrl);
|
||||
// 打开和URL之间的连接
|
||||
HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.connect();
|
||||
// 获取所有响应头字段
|
||||
Map<String, List<String>> map = connection.getHeaderFields();
|
||||
// 遍历所有的响应头字段
|
||||
for (String key : map.keySet()) {
|
||||
System.err.println(key + "--->" + map.get(key));
|
||||
}
|
||||
// 定义 BufferedReader输入流来读取URL的响应
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String result = "";
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
result += line;
|
||||
}
|
||||
/**
|
||||
* 返回结果示例
|
||||
*/
|
||||
System.err.println("result:" + result);
|
||||
JSONObject jsonObject = new JSONObject(result);
|
||||
String access_token = jsonObject.getString("access_token");
|
||||
return access_token;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
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 java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/10/5.
|
||||
*/
|
||||
|
||||
public class PickerAdapter extends RecyclerView.Adapter<PickerHolder> {
|
||||
private ArrayList<String> list;
|
||||
private Context context;
|
||||
|
||||
public PickerAdapter(ArrayList<String> list, Context context) {
|
||||
super();
|
||||
this.list = list;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PickerHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.picker_item, parent, false);
|
||||
return new PickerHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PickerHolder holder, int position) {
|
||||
holder.bindView(list.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.example.ninefourone.nutritionmaster.adapter;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/10/5.
|
||||
*/
|
||||
|
||||
public class PickerHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.picker_item)
|
||||
TextView pickerItem;
|
||||
|
||||
public PickerHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
}
|
||||
|
||||
public void bindView(String text) {
|
||||
pickerItem.setText(text);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
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.NutritionMaster;
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.bean.ClassifyResult;
|
||||
import com.example.ninefourone.nutritionmaster.modules.classifyresult.DishResultActivity;
|
||||
import com.example.ninefourone.nutritionmaster.utils.CalculateUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import travel.ithaka.android.horizontalpickerlib.PickerLayoutManager;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/10/5.
|
||||
*/
|
||||
|
||||
public class ResultListAdapter extends RecyclerView.Adapter<ResultListHolder> {
|
||||
private ArrayList<ClassifyResult> mList;
|
||||
private Context context;
|
||||
private PickerLayoutManager pickerLayoutManager;
|
||||
|
||||
public ResultListAdapter(ArrayList<ClassifyResult> list, Context context) {
|
||||
super();
|
||||
mList = list;
|
||||
this.context = context;
|
||||
mList = CalculateUtils.getDishQuantity(mList, NutritionMaster.user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultListHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.dish_result_item, parent, false);
|
||||
pickerLayoutManager = new PickerLayoutManager(context, PickerLayoutManager.HORIZONTAL, false);
|
||||
return new ResultListHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ResultListHolder holder, int position) {
|
||||
holder.bindView(mList.get(position), pickerLayoutManager, (DishResultActivity) context, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.example.ninefourone.nutritionmaster.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.LinearSnapHelper;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.SnapHelper;
|
||||
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.ClassifyResult;
|
||||
import com.example.ninefourone.nutritionmaster.modules.classifyresult.DishResultActivity;
|
||||
import com.example.ninefourone.nutritionmaster.utils.ConstantUtils;
|
||||
import com.example.ninefourone.nutritionmaster.utils.MessageUtils;
|
||||
import com.github.siyamed.shapeimageview.CircularImageView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import travel.ithaka.android.horizontalpickerlib.PickerLayoutManager;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/10/5.
|
||||
*/
|
||||
|
||||
public class ResultListHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.image)
|
||||
ImageView image;
|
||||
@BindView(R.id.name)
|
||||
TextView name;
|
||||
@BindView(R.id.picker)
|
||||
RecyclerView picker;
|
||||
|
||||
private PickerAdapter pickerAdapter;
|
||||
private Context context;
|
||||
|
||||
public ResultListHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
context = itemView.getContext();
|
||||
}
|
||||
|
||||
public void bindView(ClassifyResult classifyResult, PickerLayoutManager pickerLayoutManager,
|
||||
final DishResultActivity dishResultActivity,final int position) {
|
||||
pickerLayoutManager.setChangeAlpha(true);
|
||||
pickerLayoutManager.setScaleDownBy(0.99f);
|
||||
pickerLayoutManager.setScaleDownDistance(0.8f);
|
||||
picker.setLayoutManager(pickerLayoutManager);
|
||||
SnapHelper snapHelper = new LinearSnapHelper();
|
||||
snapHelper.attachToRecyclerView(picker);
|
||||
pickerAdapter = new PickerAdapter(ConstantUtils.dishPicerData, context);
|
||||
picker.setAdapter(pickerAdapter);
|
||||
picker.setNestedScrollingEnabled(false);
|
||||
picker.scrollToPosition(48);
|
||||
picker.smoothScrollBy(10, 0);
|
||||
|
||||
pickerLayoutManager.setOnScrollStopListener(new PickerLayoutManager.onScrollStopListener() {
|
||||
@Override
|
||||
public void selectedView(View view) {
|
||||
String text = ((TextView) view).getText().toString();
|
||||
// MessageUtils.MakeToast(text);
|
||||
dishResultActivity.refreshData(Integer.valueOf(text),position);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
name.setText(classifyResult.getName());
|
||||
Glide.with(context).load("http://s2.boohee.cn/house/food_big/big_photo20155149534910631.jpg").into(image);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.example.ninefourone.nutritionmaster.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/10/4.
|
||||
*/
|
||||
|
||||
public class ClassifyResult implements Serializable {
|
||||
|
||||
private String imgPath;
|
||||
private double probability;
|
||||
private String name;
|
||||
private double calorie;
|
||||
private Boolean has_calorie;
|
||||
private double quantity = -1;
|
||||
|
||||
public double getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(double quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public String getImgPath() {
|
||||
return imgPath;
|
||||
}
|
||||
|
||||
public void setImgPath(String imgPath) {
|
||||
this.imgPath = imgPath;
|
||||
}
|
||||
|
||||
public double getProbability() {
|
||||
return probability;
|
||||
}
|
||||
|
||||
public void setProbability(double probability) {
|
||||
this.probability = probability;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public double getCalorie() {
|
||||
return calorie;
|
||||
}
|
||||
|
||||
public void setCalorie(double calorie) {
|
||||
this.calorie = calorie;
|
||||
}
|
||||
|
||||
public Boolean getHas_calorie() {
|
||||
return has_calorie;
|
||||
}
|
||||
|
||||
public void setHas_calorie(Boolean has_calorie) {
|
||||
this.has_calorie = has_calorie;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name + ";置信度" + probability + ";卡路里" + calorie;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.example.ninefourone.nutritionmaster.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/10/5.
|
||||
*/
|
||||
|
||||
public class ResultList implements Serializable {
|
||||
|
||||
private ArrayList<ClassifyResult> results;
|
||||
|
||||
public ResultList(ArrayList<ClassifyResult> results) {
|
||||
super();
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
public ArrayList<ClassifyResult> getResults() {
|
||||
return results;
|
||||
}
|
||||
|
||||
public void setResults(ArrayList<ClassifyResult> results) {
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于Intent传递
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String log = "";
|
||||
for (int i = 0; i < results.size(); i++) {
|
||||
log += results.get(i).getName() + ";卡路里" +results.get(i).getCalorie() + "\n";
|
||||
}
|
||||
return log;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,13 @@ package com.example.ninefourone.nutritionmaster.camera;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.Camera;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Display;
|
||||
import android.util.Base64;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
@@ -17,9 +18,21 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.bean.ClassifyResult;
|
||||
import com.example.ninefourone.nutritionmaster.bean.ResultList;
|
||||
import com.example.ninefourone.nutritionmaster.modules.classifyresult.DishResultActivity;
|
||||
import com.example.ninefourone.nutritionmaster.utils.ConstantUtils;
|
||||
import com.example.ninefourone.nutritionmaster.utils.MessageUtils;
|
||||
import com.example.ninefourone.nutritionmaster.utils.WebUtils;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
@@ -28,7 +41,11 @@ import butterknife.OnClick;
|
||||
* Created by ScorpioMiku on 2018/9/3.
|
||||
*/
|
||||
|
||||
public class FoodMaterialCamera extends AppCompatActivity {
|
||||
public class ClassifierCamera extends AppCompatActivity {
|
||||
|
||||
public static int MATERAIL_CODE = 0;
|
||||
public static int DISH_CODE = 1;
|
||||
|
||||
@BindView(R.id.camera_preview)
|
||||
FrameLayout mCameraLayout;
|
||||
@BindView(R.id.results_text_view)
|
||||
@@ -37,20 +54,22 @@ public class FoodMaterialCamera extends AppCompatActivity {
|
||||
ImageView moreTakePhotoButtonCapture;
|
||||
@BindView(R.id.more_takephoto_ok)
|
||||
ImageView moreTakephotoOk;
|
||||
@BindView(R.id.more_camera_cover_linearlayout)
|
||||
FrameLayout moreCameraCoverLinearlayout;
|
||||
@BindView(R.id.camera_cover_linearlayout)
|
||||
FrameLayout cameraCoverLinearlayout;
|
||||
|
||||
private Camera mCamera;
|
||||
private CameraPreview mPreview;
|
||||
private int mCameraId = Camera.CameraInfo.CAMERA_FACING_BACK;
|
||||
|
||||
private int widthPixel;
|
||||
private float heightPixel;
|
||||
private ArrayList<ClassifyResult> resultList = new ArrayList<>();
|
||||
|
||||
private int code = -1;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Intent intent = getIntent();
|
||||
code = intent.getIntExtra("CODE", -1);
|
||||
//取消toolbar
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
//设置全屏
|
||||
@@ -59,9 +78,6 @@ public class FoodMaterialCamera extends AppCompatActivity {
|
||||
//注意:上面两个设置必须写在setContentView前面
|
||||
setContentView(R.layout.cameras_layout);
|
||||
ButterKnife.bind(this);
|
||||
Display display = getWindowManager().getDefaultDisplay();
|
||||
widthPixel = display.getWidth();
|
||||
heightPixel = display.getHeight() * (14.0f / 16);
|
||||
|
||||
if (!checkCameraHardware(this)) {
|
||||
MessageUtils.MakeToast("不支持相机");
|
||||
@@ -101,13 +117,6 @@ public class FoodMaterialCamera extends AppCompatActivity {
|
||||
if (null == mCamera) {
|
||||
mCamera = getCameraInstance();
|
||||
mPreview = new CameraPreview(this, mCamera);
|
||||
// mPreview.setOnTouchListener(new View.OnTouchListener() {
|
||||
// @Override
|
||||
// public boolean onTouch(View v, MotionEvent event) {
|
||||
// mCamera.autoFocus(null);
|
||||
// return false;
|
||||
// }
|
||||
// });
|
||||
mCameraLayout.addView(mPreview);
|
||||
mCamera.startPreview();
|
||||
}
|
||||
@@ -124,8 +133,10 @@ public class FoodMaterialCamera extends AppCompatActivity {
|
||||
c = Camera.open();
|
||||
|
||||
Camera.Parameters mParameters = c.getParameters();
|
||||
Logger.d(widthPixel+", "+heightPixel);
|
||||
mParameters.setPictureSize(widthPixel, (int) heightPixel);
|
||||
List<Camera.Size> sizes = mParameters.getSupportedPreviewSizes();
|
||||
|
||||
mParameters.setPictureSize(2048, 1536);
|
||||
mParameters.setPreviewSize(2048, 1536);
|
||||
c.setParameters(mParameters);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -152,7 +163,45 @@ public class FoodMaterialCamera extends AppCompatActivity {
|
||||
private Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
|
||||
@Override
|
||||
public void onPictureTaken(final byte[] data, Camera camera) {
|
||||
MessageUtils.MakeToast("拍照!");
|
||||
try {
|
||||
String imgStr = Base64.encodeToString(data, Base64.DEFAULT);
|
||||
String imgParam = URLEncoder.encode(imgStr, "UTF-8");
|
||||
final String param = "image=" + imgParam + "&top_num=" + 1;
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String result = null;
|
||||
try {
|
||||
if (code == 0) {
|
||||
result = WebUtils.HttpPost(ConstantUtils.BD_DISH_URL,
|
||||
ConstantUtils.BD_ACCESS_TOKEN, param);
|
||||
} else if (code == 1) {
|
||||
result = WebUtils.HttpPost(ConstantUtils.BD_DISH_URL,
|
||||
ConstantUtils.BD_ACCESS_TOKEN, param);
|
||||
} else {
|
||||
Logger.e("拍照code为-1");
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject(result);
|
||||
ClassifyResult classifyResult = new ClassifyResult();
|
||||
JSONArray resultObject = jsonObject.getJSONArray("result");
|
||||
jsonObject = resultObject.getJSONObject(0);
|
||||
classifyResult.setCalorie(jsonObject.getInt("calorie"));
|
||||
classifyResult.setHas_calorie(jsonObject.getBoolean("has_calorie"));
|
||||
classifyResult.setProbability(jsonObject.getDouble("probability"));
|
||||
classifyResult.setName(jsonObject.getString("name"));
|
||||
// Logger.d(classifyResult);
|
||||
resultList.add(classifyResult);
|
||||
refreshUI();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// MessageUtils.MakeToast("拍照!");
|
||||
mCamera.startPreview();
|
||||
}
|
||||
};
|
||||
@@ -168,8 +217,16 @@ public class FoodMaterialCamera extends AppCompatActivity {
|
||||
switch (view.getId()) {
|
||||
case R.id.more_take_photo_button_capture:
|
||||
mCamera.autoFocus(mAutoFocusCallback);
|
||||
cameraCoverLinearlayout.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case R.id.more_takephoto_ok:
|
||||
Intent intent = new Intent(ClassifierCamera.this, DishResultActivity.class);
|
||||
intent.putExtra("LIST", resultList);
|
||||
// intent.putExtra("LIST", ConstantUtils.testData);
|
||||
startActivity(intent);
|
||||
resultList.clear();
|
||||
refreshUI();
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -209,4 +266,19 @@ public class FoodMaterialCamera extends AppCompatActivity {
|
||||
}
|
||||
camera.setDisplayOrientation(result);
|
||||
}
|
||||
|
||||
|
||||
private void refreshUI() {
|
||||
resultsTextView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String text = "";
|
||||
for (int i = 0; i < resultList.size(); i++) {
|
||||
text += resultList.get(i).getName() + " ";
|
||||
}
|
||||
resultsTextView.setText(text);
|
||||
cameraCoverLinearlayout.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -19,13 +19,12 @@ import android.widget.TextView;
|
||||
|
||||
import com.ToxicBakery.viewpager.transforms.CubeOutTransformer;
|
||||
import com.akexorcist.roundcornerprogressbar.RoundCornerProgressBar;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.cb.ratingbar.CBRatingBar;
|
||||
import com.example.ninefourone.nutritionmaster.NutritionMaster;
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.adapter.HomePagerAdapter;
|
||||
import com.example.ninefourone.nutritionmaster.base.BaseActivity;
|
||||
import com.example.ninefourone.nutritionmaster.camera.FoodMaterialCamera;
|
||||
import com.example.ninefourone.nutritionmaster.camera.ClassifierCamera;
|
||||
import com.example.ninefourone.nutritionmaster.modules.addinformation.AddInformationActivity;
|
||||
import com.example.ninefourone.nutritionmaster.modules.addinformation.AddPhysiqueActivity;
|
||||
import com.example.ninefourone.nutritionmaster.modules.information.InformationActivity;
|
||||
@@ -316,14 +315,24 @@ public class MainActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onBoomButtonClick(int index) {
|
||||
Intent cameraIntent = new Intent(MainActivity.this,
|
||||
FoodMaterialCamera.class);
|
||||
ClassifierCamera.class);
|
||||
cameraIntent.putExtra("CODE", ClassifierCamera.MATERAIL_CODE);
|
||||
startActivity(cameraIntent);
|
||||
}
|
||||
});
|
||||
boomMenuButton.addBuilder(builder);
|
||||
HamButton.Builder builder2 = new HamButton.Builder()
|
||||
.normalImageRes(R.drawable.foods)
|
||||
.normalTextRes(R.string.food_title);
|
||||
.normalTextRes(R.string.food_title)
|
||||
.listener(new OnBMClickListener() {
|
||||
@Override
|
||||
public void onBoomButtonClick(int index) {
|
||||
Intent cameraIntent = new Intent(MainActivity.this,
|
||||
ClassifierCamera.class);
|
||||
cameraIntent.putExtra("CODE", ClassifierCamera.DISH_CODE);
|
||||
startActivity(cameraIntent);
|
||||
}
|
||||
});
|
||||
boomMenuButton.addBuilder(builder2);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.example.ninefourone.nutritionmaster.modules.classifyresult;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.adapter.ResultListAdapter;
|
||||
import com.example.ninefourone.nutritionmaster.base.BaseActivity;
|
||||
import com.example.ninefourone.nutritionmaster.bean.ClassifyResult;
|
||||
import com.example.ninefourone.nutritionmaster.utils.ConstantUtils;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
public class DishResultActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.recycler_view)
|
||||
RecyclerView recyclerView;
|
||||
@BindView(R.id.calorie)
|
||||
TextView calorie;
|
||||
@BindView(R.id.suger)
|
||||
TextView suger;
|
||||
@BindView(R.id.fat)
|
||||
TextView fat;
|
||||
@BindView(R.id.protein)
|
||||
TextView protein;
|
||||
@BindView(R.id.ok_button)
|
||||
Button okButton;
|
||||
|
||||
|
||||
private ArrayList<ClassifyResult> results;
|
||||
private ResultListAdapter resultListAdapter;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_dish_result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initViews(Bundle savedInstanceState) {
|
||||
Intent intent = getIntent();
|
||||
results = (ArrayList<ClassifyResult>) intent.getSerializableExtra("LIST");
|
||||
// for (int i = 0; i < results.size(); i++) {
|
||||
// Logger.d(results.get(i));
|
||||
// }
|
||||
results = ConstantUtils.testData;
|
||||
resultListAdapter = new ResultListAdapter(results, this);
|
||||
recyclerView.setAdapter(resultListAdapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initToolBar() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPointerCaptureChanged(boolean hasCapture) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 能量根据选择的来变
|
||||
*
|
||||
* @param quantity
|
||||
*/
|
||||
public void refreshData(int quantity, int positon) {
|
||||
float calorieSum = 0;
|
||||
float fatSum = 0;
|
||||
float sugarSum = 0;
|
||||
float proteinSum = 0;
|
||||
ClassifyResult temp = results.get(positon);
|
||||
temp.setQuantity(quantity);
|
||||
results.set(positon, temp);
|
||||
for (int i = 0; i < results.size(); i++) {
|
||||
calorieSum += results.get(i).getCalorie() * results.get(i).getQuantity() / 100;
|
||||
fatSum += results.get(i).getCalorie() * results.get(i).getQuantity() / 100;
|
||||
calorieSum += results.get(i).getCalorie() * results.get(i).getQuantity() / 100;
|
||||
calorieSum += results.get(i).getCalorie() * results.get(i).getQuantity() / 100;
|
||||
}
|
||||
calorie.setText((int)calorieSum + "");
|
||||
protein.setText((int)proteinSum + "");
|
||||
fat.setText((int)fatSum + "");
|
||||
suger.setText((int)sugarSum + "");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.example.ninefourone.nutritionmaster.utils;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.bean.ClassifyResult;
|
||||
import com.example.ninefourone.nutritionmaster.bean.MyUser;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
@@ -69,7 +72,30 @@ public class CalculateUtils {
|
||||
*/
|
||||
public static int getWeek() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Logger.d( calendar.get(Calendar.DAY_OF_WEEK));
|
||||
return calendar.get(Calendar.DAY_OF_WEEK)-1;
|
||||
// Logger.d( calendar.get(Calendar.DAY_OF_WEEK));
|
||||
return calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算每个食物吃多少
|
||||
* @param classifyResultArrayList
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static ArrayList<ClassifyResult> getDishQuantity(
|
||||
ArrayList<ClassifyResult> classifyResultArrayList, MyUser user) {
|
||||
double calorieSum = 0;
|
||||
double[] calories = new double[classifyResultArrayList.size()];
|
||||
double[] quantitys = new double[classifyResultArrayList.size()];
|
||||
float baseQuantity = 600f;
|
||||
for (int i = 0; i < classifyResultArrayList.size(); i++) {
|
||||
calorieSum += classifyResultArrayList.get(i).getCalorie();
|
||||
calories[i] = classifyResultArrayList.get(i).getCalorie();
|
||||
}
|
||||
for (int i = 0; i < classifyResultArrayList.size(); i++) {
|
||||
classifyResultArrayList.get(i).setQuantity(calories[i] / calorieSum * baseQuantity);
|
||||
}
|
||||
return classifyResultArrayList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.example.ninefourone.nutritionmaster.utils;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.bean.ClassifyResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
@@ -11,6 +13,7 @@ public class ConstantUtils {
|
||||
public static String[] dailyDescibes = {"快乐陪周一", "幸运伴周二", "轻松有周三", "温馨携周四",
|
||||
"愉悦同周五", "休闲找周六", "潇洒属周日"};
|
||||
|
||||
|
||||
public static String arab2Chinese(int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
@@ -267,4 +270,32 @@ public class ConstantUtils {
|
||||
"平和质人阴阳气血平衡,药膳调理不可偏补、贪补,以保持人体阴阳平衡状态最为紧要。所谓“不伤不扰,顺其自然”。"
|
||||
};
|
||||
|
||||
public static String BD_API_KEY = "GQfoj7AUUhj67ocHuwvA8G5q";
|
||||
public static String BD_APP_ID = "14346167";
|
||||
public static String BD_SECRET_KEY = "EEXe6pG7QGVdrqDM8eR0S3RY2WPf4Gwn";
|
||||
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 ArrayList<ClassifyResult> testData = new ArrayList<>();
|
||||
|
||||
static {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
ClassifyResult classifyResult = new ClassifyResult();
|
||||
classifyResult.setName("酱肉丝" + i);
|
||||
classifyResult.setProbability(0.5 + i);
|
||||
classifyResult.setCalorie(274 + i * 10);
|
||||
testData.add(classifyResult);
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<String> dishPicerData = new ArrayList<>();
|
||||
|
||||
static {
|
||||
for (int i = 0; i <= 700; i++) {
|
||||
if (i % 2 == 0) {
|
||||
dishPicerData.add(i + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package com.example.ninefourone.nutritionmaster.utils;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.NutritionMaster;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/8/26.
|
||||
@@ -13,4 +16,6 @@ public class MessageUtils {
|
||||
public static void MakeToast(String message) {
|
||||
Toast.makeText(NutritionMaster.getInstance(), message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,21 @@ import com.example.ninefourone.nutritionmaster.bean.Occupation;
|
||||
import com.google.gson.Gson;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
@@ -264,6 +277,54 @@ public class WebUtils {
|
||||
}
|
||||
|
||||
|
||||
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 static void main(String[] args) {
|
||||
/*WebUtils.getMenu("雪丽对虾", new Callback() {
|
||||
@Override
|
||||
|
||||
BIN
app/src/main/res/drawable/camera_bg.jpg
Normal file
BIN
app/src/main/res/drawable/camera_bg.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
@@ -1,4 +1,5 @@
|
||||
<vector android:height="24dp" android:viewportHeight="1024.0"
|
||||
android:viewportWidth="1024.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#ffffff" android:pathData="M512,62.4c-248.3,0 -449.6,201.3 -449.6,449.6s201.3,449.6 449.6,449.6 449.6,-201.3 449.6,-449.6S760.3,62.4 512,62.4zM728.1,403.9 L478.8,653.3c-4.6,4.6 -10.6,6.9 -16.6,6.9s-12,-2.3 -16.6,-6.9c-37.4,-37.4 -149.6,-149.6 -149.6,-149.6 -9.2,-9.2 -9.2,-24.1 0,-33.2 9.2,-9.2 24.1,-9.2 33.2,0l133,109.5 232.7,-209.2c9.2,-9.2 24.1,-9.2 33.2,0C737.3,379.9 737.3,394.8 728.1,403.9z"/>
|
||||
<path android:fillColor="#4fa67c" android:pathData="M512,512m-512,0a512,512 0,1 0,1024 0,512 512,0 1,0 -1024,0Z"/>
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M227.5,554.3l112.6,-92.2 92.2,92.2s174.1,-163.8 322.6,-250.9v61.4c-204.8,189.4 -332.8,394.2 -332.8,394.2l-194.6,-204.8z"/>
|
||||
</vector>
|
||||
|
||||
5
app/src/main/res/drawable/ic_take_photo.xml
Normal file
5
app/src/main/res/drawable/ic_take_photo.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:viewportHeight="1024.0"
|
||||
android:viewportWidth="1024.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#1db127" android:pathData="M591.9,434.4a114.3,114.3 0,0 1,21.1 32l1.4,-0.4L705.4,806C800.9,743 864,634.9 864,512a353.6,353.6 0,0 0,-8.8 -77.6zM845.1,398.9a352.8,352.8 0,0 0,-146.2 -184.8L514,398.9zM434.8,595.8l-0.3,0.3 -2.8,-2.8c-1.2,-1.1 -2.3,-2.3 -3.4,-3.4L196.1,357.6A349.9,349.9 0,0 0,160 512c0,91.7 35.4,175 92.9,237.6l225.1,-130a114.5,114.5 0,0 1,-43.2 -23.8zM568,608.2l0.2,0.3 -289,166.9C341.2,830.3 422.5,864 512,864a349.7,349.7 0,0 0,161.6 -39.5l-68,-253.8a115,115 0,0 1,-37.6 37.5zM423.8,439.1l-0.1,-0.1 0.8,-0.8a112.4,112.4 0,0 1,8.3 -8.4l233.7,-233.7A349.3,349.3 0,0 0,512 160c-125.8,0 -235.8,66.2 -298,165.3l183,183a111.9,111.9 0,0 1,26.8 -69.2z"/>
|
||||
<path android:fillColor="#34a13c" android:pathData="M512,0C229.2,0 0,229.2 0,512s229.2,512 512,512 512,-229.2 512,-512S794.8,0 512,0zM817.5,817.5a430.4,430.4 0,1 1,92.6 -137.3,430.7 430.7,0 0,1 -92.6,137.3z"/>
|
||||
</vector>
|
||||
218
app/src/main/res/layout/activity_dish_result.xml
Normal file
218
app/src/main/res/layout/activity_dish_result.xml
Normal file
@@ -0,0 +1,218 @@
|
||||
<?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:background="#54be82"
|
||||
android:orientation="vertical"
|
||||
tools:context="com.example.ninefourone.nutritionmaster.modules.classifyresult.DishResultActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_weight="0.5"
|
||||
android:gravity="center"
|
||||
android:text="信息清单"
|
||||
android:textColor="#fff"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="3">
|
||||
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_weight="0.9"
|
||||
app:cardCornerRadius="15dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#50b67c"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="卡路里总和"
|
||||
android:textColor="#fff" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/calorie_tag"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="大卡"
|
||||
android:textColor="#fff" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/calorie"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="7dp"
|
||||
android:layout_toLeftOf="@+id/calorie_tag"
|
||||
android:text="大卡"
|
||||
android:textColor="#fff" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="碳水化合物"
|
||||
android:textColor="#fff" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sugar_tag"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="克"
|
||||
android:textColor="#fff" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/suger"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="7dp"
|
||||
android:layout_toLeftOf="@+id/sugar_tag"
|
||||
android:text="大卡"
|
||||
android:textColor="#fff" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_weight="0.005"
|
||||
android:alpha="0.7"
|
||||
android:background="#d7d6d6" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="脂肪"
|
||||
android:textColor="#fff" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fat_tag"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="克"
|
||||
android:textColor="#fff" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fat"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="7dp"
|
||||
android:layout_toLeftOf="@+id/fat_tag"
|
||||
android:text="大卡"
|
||||
android:textColor="#fff" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="蛋白质"
|
||||
android:textColor="#fff" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/protein_tag"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="克"
|
||||
android:textColor="#fff" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/protein"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="7dp"
|
||||
android:layout_toLeftOf="@+id/protein_tag"
|
||||
android:text="大卡"
|
||||
android:textColor="#fff" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.8"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Button
|
||||
android:id="@+id/ok_button"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="#76c47e"
|
||||
android:text="确认提交到已吃清单"
|
||||
android:textColor="#f7f4f4" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
@@ -30,6 +30,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center"
|
||||
android:textColor="#fff"
|
||||
android:textSize="18sp"
|
||||
tools:text="@string/app_name" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -39,15 +41,15 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="2"
|
||||
android:alpha="0.2"
|
||||
android:background="#8a515050">
|
||||
android:alpha="0.5"
|
||||
android:background="@drawable/camera_bg">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/more_take_photo_button_capture"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/selector" />
|
||||
android:src="@drawable/ic_take_photo" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/more_takephoto_ok"
|
||||
@@ -63,7 +65,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/more_camera_cover_linearlayout"
|
||||
android:id="@+id/camera_cover_linearlayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:alpha="0.3"
|
||||
|
||||
62
app/src/main/res/layout/dish_result_item.xml
Normal file
62
app/src/main/res/layout/dish_result_item.xml
Normal file
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:layout_margin="5dp"
|
||||
app:cardCornerRadius="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#40b985"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="60dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:alpha="0.8"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
app:cardCornerRadius="30dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@drawable/food_test" />
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="15dp"
|
||||
android:textColor="#fff"
|
||||
tools:text="麻婆豆腐" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/picker"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:clipToPadding="false">
|
||||
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
8
app/src/main/res/layout/picker_item.xml
Normal file
8
app/src/main/res/layout/picker_item.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/picker_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="13dp"
|
||||
android:gravity="center"
|
||||
android:textSize="15sp" />
|
||||
Reference in New Issue
Block a user