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 "重度肥胖";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,61 +24,81 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
<FrameLayout
|
||||
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/colorPrimary"
|
||||
app:contentInsetStart="0dp"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/bar_cover"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="110dp"
|
||||
android:background="@color/bar_open"
|
||||
android:visibility="gone">
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/navigation_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:contentInsetStart="0dp"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/navigation_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<ImageView
|
||||
<ImageView
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_drawer_home" />
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_drawer_home" />
|
||||
|
||||
<com.github.siyamed.shapeimageview.CircularImageView
|
||||
android:id="@+id/toolbar_user_avatar"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="31dp"
|
||||
android:layout_marginEnd="3dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:src="@drawable/test_avatar" />
|
||||
<com.github.siyamed.shapeimageview.CircularImageView
|
||||
android:id="@+id/toolbar_user_avatar"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="31dp"
|
||||
android:layout_marginEnd="3dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:src="@drawable/test_avatar" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:maxLines="1"
|
||||
android:text="营养大师"
|
||||
android:textColor="#FFFF"
|
||||
android:textSize="15sp" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:maxLines="1"
|
||||
android:text="营养大师"
|
||||
android:textColor="#FFFF"
|
||||
android:textSize="15sp" />
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
|
||||
<com.flyco.tablayout.SlidingTabLayout
|
||||
android:id="@+id/sliding_tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
app:tl_indicator_corner_radius="1dp"
|
||||
app:tl_indicator_height="2dp"
|
||||
app:tl_indicator_width="40dp"
|
||||
app:tl_tab_space_equal="true">
|
||||
|
||||
</com.flyco.tablayout.SlidingTabLayout>
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<com.flyco.tablayout.SlidingTabLayout
|
||||
android:id="@+id/sliding_tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="@color/colorPrimary"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
app:tl_indicator_corner_radius="1dp"
|
||||
app:tl_indicator_height="2dp"
|
||||
app:tl_indicator_width="40dp"
|
||||
app:tl_tab_space_equal="true">
|
||||
|
||||
</com.flyco.tablayout.SlidingTabLayout>
|
||||
</FrameLayout>
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<com.example.ninefourone.nutritionmaster.ui.NoScrollViewPager
|
||||
|
||||
@@ -9,5 +9,10 @@
|
||||
<color name="colorSwitchThumbNormal">#FF78909C</color>
|
||||
|
||||
|
||||
<color name="bar_open">#045ca1</color>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user