BMI
This commit is contained in:
@@ -1,26 +1,20 @@
|
||||
package com.example.ninefourone.nutritionmaster.modules;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
|
||||
import com.ToxicBakery.viewpager.transforms.CubeOutTransformer;
|
||||
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.ui.NoScrollViewPager;
|
||||
import com.example.ninefourone.nutritionmaster.utils.MessageUtils;
|
||||
import com.flyco.tablayout.SlidingTabLayout;
|
||||
import com.mxn.soul.flowingdrawer_core.ElasticDrawer;
|
||||
import com.mxn.soul.flowingdrawer_core.FlowingDrawer;
|
||||
import com.today.step.lib.ISportStepInterface;
|
||||
import com.today.step.lib.TodayStepManager;
|
||||
import com.today.step.lib.TodayStepService;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
@@ -36,6 +30,8 @@ public class MainActivity extends BaseActivity {
|
||||
NoScrollViewPager viewPager;
|
||||
@BindView(R.id.sliding_tab_layout)
|
||||
SlidingTabLayout slidingTabLayout;
|
||||
@BindView(R.id.bar_cover)
|
||||
FrameLayout barCover;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -47,10 +43,13 @@ public class MainActivity extends BaseActivity {
|
||||
public void initViews(Bundle savedInstanceState) {
|
||||
mDrawer.setTouchMode(ElasticDrawer.TOUCH_MODE_BEZEL);
|
||||
mDrawer.setOnDrawerStateChangeListener(new ElasticDrawer.OnDrawerStateChangeListener() {
|
||||
@SuppressLint("ResourceAsColor")
|
||||
@Override
|
||||
public void onDrawerStateChange(int oldState, int newState) {
|
||||
if (newState == ElasticDrawer.STATE_CLOSED) {
|
||||
// Logger.i("Drawer STATE_CLOSED");
|
||||
barCover.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
barCover.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.example.ninefourone.nutritionmaster.utils;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/8/29.
|
||||
*/
|
||||
|
||||
public class CalculateUtils {
|
||||
/**
|
||||
* 计算BMI值 BMI值計算公式: BMI = 體重(公斤) / 身高2(公尺2)
|
||||
*
|
||||
* @param height
|
||||
* @param weight
|
||||
* @return
|
||||
*/
|
||||
public static float BMI(float height, float weight) {
|
||||
height = height / 100;
|
||||
return weight / (height * height);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据BMI得到体质情况
|
||||
* @param BMI
|
||||
* @return
|
||||
*/
|
||||
public static String bodyStatus(float BMI) {
|
||||
if (BMI < 18.5) {
|
||||
return "轻体重";
|
||||
} else if (BMI < 24) {
|
||||
return "健康体重";
|
||||
} else if (BMI < 27) {
|
||||
return "轻度肥胖";
|
||||
} else if (BMI < 30) {
|
||||
return "中度肥胖";
|
||||
} else {
|
||||
return "重度肥胖";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user