Merge branch 'wangtianrui' into develop

This commit is contained in:
ScorpioMiku
2018-10-02 17:15:47 +08:00
15 changed files with 212 additions and 160 deletions

View File

@@ -14,8 +14,6 @@ import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.Arrays;
import okhttp3.Call;
import okhttp3.Callback;
@@ -103,7 +101,7 @@ public class NutritionMaster extends Application {
*/
private void initUser() {
user = new MyUser();
user.setNickName("ScorpioMiku");
user.setUsername("ScorpioMiku");
}
/**

View File

@@ -39,7 +39,7 @@ public class CardAdapter extends RecyclerView.Adapter<CardHolder> {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onBindViewHolder(CardHolder holder, int position) {
holder.bindView(mList.get(position).getPictureId(), mList.get(position).getTitle(), context);
holder.bindView(mList.get(position).getPictureId(), mList.get(position), context);
}
@Override

View File

@@ -11,6 +11,7 @@ import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.example.ninefourone.nutritionmaster.R;
import com.example.ninefourone.nutritionmaster.bean.DailyCard;
import com.example.ninefourone.nutritionmaster.modules.viewpagerfragments.customization.CustomizationActivity;
import com.orhanobut.logger.Logger;
@@ -41,12 +42,13 @@ public class CardHolder extends RecyclerView.ViewHolder {
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void bindView(int picId, String text, final Context context) {
tvName.setText(text);
public void bindView(int picId, DailyCard dailyCard, final Context context) {
tvName.setText(dailyCard.getTitle());
tvSign.setText(dailyCard.getDescription());
// ivPhoto.setImageDrawable(context.getDrawable(picId));
Glide.with(context).load(picId).into(ivPhoto);
i = new Intent(context, CustomizationActivity.class);
i.putExtra("SEND_CODE", text);
i.putExtra("SEND_CODE", dailyCard.getTitle());
// Logger.d(text);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
@@ -54,7 +56,6 @@ public class CardHolder extends RecyclerView.ViewHolder {
context.startActivity(i);
}
});
}

View File

@@ -22,11 +22,12 @@ public abstract class BaseActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.user = NutritionMaster.user;
setContentView(getLayoutId());
unbinder = ButterKnife.bind(this);
initViews(savedInstanceState);
initToolBar();
this.user = NutritionMaster.user;
}

View File

@@ -10,7 +10,7 @@ public class MyUser {
* password : password
* last_login : null
* is_superuser : false
* nickName : okhttptest
* username : okhttptest
* first_name :
* last_name :
* email :
@@ -28,7 +28,7 @@ public class MyUser {
private String password;
private Object last_login;
private boolean is_superuser;
private String nickName;
private String username;
private String first_name;
private String last_name;
private String email;
@@ -108,12 +108,12 @@ public class MyUser {
this.is_superuser = is_superuser;
}
public String getNickName() {
return nickName;
public String getUsername() {
return username;
}
public void setNickName(String nickName) {
this.nickName = nickName;
public void setUsername(String username) {
this.username = username;
}
public String getFirst_name() {
@@ -212,7 +212,7 @@ public class MyUser {
", password='" + password + '\'' +
", last_login=" + last_login +
", is_superuser=" + is_superuser +
", nickName='" + nickName + '\'' +
", username='" + username + '\'' +
", first_name='" + first_name + '\'' +
", last_name='" + last_name + '\'' +
", email='" + email + '\'' +

View File

@@ -7,6 +7,7 @@ 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.view.Surface;
import android.view.View;
import android.view.Window;
@@ -17,6 +18,7 @@ import android.widget.TextView;
import com.example.ninefourone.nutritionmaster.R;
import com.example.ninefourone.nutritionmaster.utils.MessageUtils;
import com.orhanobut.logger.Logger;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -42,6 +44,8 @@ public class FoodMaterialCamera extends AppCompatActivity {
private CameraPreview mPreview;
private int mCameraId = Camera.CameraInfo.CAMERA_FACING_BACK;
private int widthPixel;
private float heightPixel;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -55,6 +59,9 @@ 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("不支持相机");
@@ -65,6 +72,12 @@ public class FoodMaterialCamera extends AppCompatActivity {
setCameraDisplayOrientation(this, mCameraId, mCamera);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
}
/**
* 检查当前设备是否有相机
*
@@ -109,8 +122,10 @@ public class FoodMaterialCamera extends AppCompatActivity {
Camera c = null;
try {
c = Camera.open();
Camera.Parameters mParameters = c.getParameters();
mParameters.setPictureSize(720, 1280);
Logger.d(widthPixel+", "+heightPixel);
mParameters.setPictureSize(widthPixel, (int) heightPixel);
c.setParameters(mParameters);
} catch (Exception e) {
e.printStackTrace();

View File

@@ -19,14 +19,15 @@ 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.modules.addinformation.AddPhysiqueActivity;
import com.example.ninefourone.nutritionmaster.modules.addinformation.AddInformationActivity;
import com.example.ninefourone.nutritionmaster.modules.addinformation.AddPhysiqueActivity;
import com.example.ninefourone.nutritionmaster.modules.information.InformationActivity;
import com.example.ninefourone.nutritionmaster.ui.NoScrollViewPager;
import com.example.ninefourone.nutritionmaster.utils.CalculateUtils;
@@ -109,6 +110,8 @@ public class MainActivity extends BaseActivity {
RoundCornerProgressBar heightBar;
@BindView(R.id.weight_bar)
RoundCornerProgressBar weightBar;
@BindView(R.id.tool_bar_nickname)
TextView toolBarNickname;
@Override
@@ -129,7 +132,6 @@ public class MainActivity extends BaseActivity {
} else {
titleLayout.setBackgroundColor(getColor(R.color.bar_open));
}
}
@Override
@@ -137,13 +139,10 @@ public class MainActivity extends BaseActivity {
// Logger.i("openRatio=" + openRatio + " ,offsetPixels=" + offsetPixels);
}
});
// initInforView();
initSpiderView();
initViewPager();
initSearchView();
initBMB();
// initOccupations();
}
/**
@@ -164,7 +163,7 @@ public class MainActivity extends BaseActivity {
@Override
public void initToolBar() {
toolBarNickname.setText(user.getUsername());
}
@Override

View File

@@ -94,7 +94,6 @@ public class AddPhysiqueActivity extends BaseActivity {
private void initAddView() {
BaseAdapter adapter = new BaseAdapter() {
@Override
public int getCount() {
return colors.length;
@@ -113,6 +112,7 @@ public class AddPhysiqueActivity extends BaseActivity {
@Override
public View getView(final int position, View child, ViewGroup parent) {
child = LayoutInflater.from(parent.getContext()).inflate(R.layout.add_item, parent,
false);
child.findViewById(R.id.image).setBackgroundColor(colors[position]);
@@ -143,7 +143,6 @@ public class AddPhysiqueActivity extends BaseActivity {
}
});
} else {
firstButtons[position].setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -190,6 +189,9 @@ public class AddPhysiqueActivity extends BaseActivity {
@Override
public void onTurned(int position) {
bottomContent.setBackgroundColor(colors[position] - 60);
firstButtons[position].setEnabled(true);
secondButtons[position].setEnabled(true);
thirdButtons[position].setEnabled(true);
}
});

View File

@@ -15,6 +15,7 @@ import com.example.ninefourone.nutritionmaster.bean.DailyCard;
import com.example.ninefourone.nutritionmaster.cardconfig.CardConfig;
import com.example.ninefourone.nutritionmaster.cardconfig.CardItemTouchCallBack;
import com.example.ninefourone.nutritionmaster.cardconfig.SwipeCardLayoutManager;
import com.example.ninefourone.nutritionmaster.utils.CalculateUtils;
import com.example.ninefourone.nutritionmaster.utils.ConstantUtils;
import java.util.ArrayList;
@@ -80,11 +81,20 @@ public class CustomizationFragment extends BaseFragment {
@Override
protected void loadData() {
super.loadData();
for (int i = 1; i <= 7; i++) {
for (int i = CalculateUtils.getWeek(); i <= 7; i++) {
// mDataList.add("周" + ConstantUtils.arab2Chinese(i) + "美食普");
DailyCard dailyCard = new DailyCard(
"" + ConstantUtils.arab2Chinese(i) + "美食普",
"这里放描述",
ConstantUtils.dailyDescibes[i-1],
picList[i - 1]
);
mDataList.add(dailyCard);
}
for (int i = 1; i < CalculateUtils.getWeek(); i++) {
// mDataList.add("周" + ConstantUtils.arab2Chinese(i) + "美食普");
DailyCard dailyCard = new DailyCard(
"" + ConstantUtils.arab2Chinese(i) + "美食普",
ConstantUtils.dailyDescibes[i-1],
picList[i - 1]
);
mDataList.add(dailyCard);

View File

@@ -2,6 +2,8 @@ package com.example.ninefourone.nutritionmaster.utils;
import com.orhanobut.logger.Logger;
import java.util.Calendar;
/**
* Created by ScorpioMiku on 2018/8/29.
*/
@@ -59,4 +61,15 @@ public class CalculateUtils {
return "重度肥胖";
}
}
/**
* 获取星期几
*
* @return
*/
public static int getWeek() {
Calendar calendar = Calendar.getInstance();
Logger.d( calendar.get(Calendar.DAY_OF_WEEK));
return calendar.get(Calendar.DAY_OF_WEEK)-1;
}
}

View File

@@ -7,6 +7,10 @@ import java.util.ArrayList;
*/
public class ConstantUtils {
public static String[] dailyDescibes = {"快乐陪周一", "幸运伴周二", "轻松有周三", "温馨携周四",
"愉悦同周五", "休闲找周六", "潇洒属周日"};
public static String arab2Chinese(int number) {
switch (number) {
case 1:
@@ -262,4 +266,5 @@ public class ConstantUtils {
"气虚质中气不足,脾胃消化功能较弱,药膳应忌过于粘腻、寒凉或难以消化之物,以免食滞难化,影响脾胃功能。",
"平和质人阴阳气血平衡,药膳调理不可偏补、贪补,以保持人体阴阳平衡状态最为紧要。所谓“不伤不扰,顺其自然”。"
};
}

View File

@@ -27,7 +27,7 @@
<android.support.v7.widget.CardView
android:id="@+id/result_layout"
android:layout_width="300dp"
android:layout_height="450dp"
android:layout_height="500dp"
android:layout_centerInParent="true"
android:visibility="gone"
app:cardCornerRadius="20dp"
@@ -71,149 +71,153 @@
<android.support.v7.widget.CardView
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_height="320dp"
android:layout_gravity="center"
app:cardBackgroundColor="#95def4">
<LinearLayout
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<TextView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="常见表现"
android:textSize="10sp" />
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:alpha="0.5"
android:background="@color/place_holder" />
<TextView
android:id="@+id/expression_text_view"
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="10dp"
android:text="常见表现"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:alpha="0.5"
android:background="@color/place_holder" />
<TextView
android:id="@+id/expression_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:textSize="12sp"
tools:text="平素面色晦暗,皮肤偏暗或色素沉着,容易出现瘀斑,易患疼痛,口唇暗淡或紫,舌质暗有点、片状瘀斑,舌下静脉曲张。眼眶暗黑,鼻部暗滞,发易脱落,皮肤发干,或有出血倾向、吐血,女性多见痛经、闭经、或经血中多有血块,或经色紫黑有块。" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:textSize="9sp"
tools:text="平素面色晦暗,皮肤偏暗或色素沉着,容易出现瘀斑,易患疼痛,口唇暗淡或紫,舌质暗有点、片状瘀斑,舌下静脉曲张。眼眶暗黑,鼻部暗滞,发易脱落,皮肤发干,或有出血倾向、吐血,女性多见痛经、闭经、或经血中多有血块,或经色紫黑有块。" />
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="10dp"
android:text="特点"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:alpha="0.5"
android:background="@color/place_holder" />
<TextView
android:id="@+id/characteristic_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:textSize="12sp"
tools:text="瘀血质的人,血行不畅,临床常呈现肤色晦暗、色素沉着、瘀斑、性格抑郁、健忘,舌质紫黯或有瘀点、舌下络脉紫黯或增粗,脉涩。易患痛证、血证、症瘕等。" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="10dp"
android:text="心理特征"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:alpha="0.5"
android:background="@color/place_holder" />
<TextView
android:id="@+id/mentality_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:textSize="12sp"
tools:text="性情急躁,心情易烦,健忘。" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="10dp"
android:text="注意事项"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:alpha="0.5"
android:background="@color/place_holder" />
<TextView
android:id="@+id/matters_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:textSize="12sp"
tools:text="瘀血质气机失调,血行不畅,应慎食雪糕、冰淇淋、冰冻饮料等寒凉之品,以免影响气血运行。保持心情舒畅,是淤血质调理的重要环节" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="特点"
android:textSize="10sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:alpha="0.5"
android:background="@color/place_holder" />
<TextView
android:id="@+id/characteristic_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:textSize="9sp"
tools:text="瘀血质的人,血行不畅,临床常呈现肤色晦暗、色素沉着、瘀斑、性格抑郁、健忘,舌质紫黯或有瘀点、舌下络脉紫黯或增粗,脉涩。易患痛证、血证、症瘕等。" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="心理特征"
android:textSize="10sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:alpha="0.5"
android:background="@color/place_holder" />
<TextView
android:id="@+id/mentality_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:textSize="9sp"
tools:text="性情急躁,心情易烦,健忘。" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="注意事项"
android:textSize="10sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:alpha="0.5"
android:background="@color/place_holder" />
<TextView
android:id="@+id/matters_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:textSize="9sp"
tools:text="瘀血质气机失调,血行不畅,应慎食雪糕、冰淇淋、冰冻饮料等寒凉之品,以免影响气血运行。保持心情舒畅,是淤血质调理的重要环节" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</android.support.v7.widget.CardView>

View File

@@ -59,6 +59,7 @@
android:src="@drawable/test_avatar" />
<TextView
android:id="@+id/tool_bar_nickname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"

View File

@@ -35,6 +35,7 @@
android:id="@+id/choose_first"
android:layout_width="150dp"
android:layout_height="50dp"
android:enabled="false"
android:text="测试"
android:textSize="13sp"
android:visibility="gone">
@@ -46,6 +47,7 @@
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_marginTop="20dp"
android:enabled="false"
android:text="测试"
android:textSize="13sp"
android:visibility="gone">
@@ -57,6 +59,7 @@
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_marginTop="20dp"
android:enabled="false"
android:text="测试"
android:textSize="13sp"
android:visibility="gone">

View File

@@ -16,7 +16,7 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9">
android:layout_weight="14">
<FrameLayout
android:id="@+id/camera_preview"
@@ -38,9 +38,9 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.2"
android:alpha="0.4"
android:background="#8A000000">
android:layout_weight="2"
android:alpha="0.2"
android:background="#8a515050">
<ImageView
android:id="@+id/more_take_photo_button_capture"
@@ -67,7 +67,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.3"
android:background="@color/place_holder"
android:background="#e6e6e6"
android:visibility="invisible">
<ProgressBar