enviroment

This commit is contained in:
ScorpioMiku
2019-08-20 16:29:48 +08:00
parent 17ba8fb698
commit 416f42efc1
9 changed files with 295 additions and 17 deletions

View File

@@ -1,15 +1,39 @@
package com.scorpiomiku.oldpeoplehome.modules.oldpeople.fragmemt;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.data.Entry;
import com.scorpiomiku.oldpeoplehome.R;
import com.scorpiomiku.oldpeoplehome.base.BaseFragment;
import com.scorpiomiku.oldpeoplehome.utils.ChartUtils;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
/**
* Created by ScorpioMiku on 2019/8/18.
*/
public class EnvironmentFragment extends BaseFragment {
@BindView(R.id.temperature_text)
TextView temperatureText;
@BindView(R.id.humidity_text)
TextView humidityText;
@BindView(R.id.temperature_chart)
LineChart temperatureChart;
@BindView(R.id.humidity_chart)
LineChart humidityChart;
Unbinder unbinder;
@Override
protected Handler initHandle() {
return null;
@@ -27,6 +51,42 @@ public class EnvironmentFragment extends BaseFragment {
@Override
protected void initView() {
initChart();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// TODO: inflate a fragment view
View rootView = super.onCreateView(inflater, container, savedInstanceState);
unbinder = ButterKnife.bind(this, rootView);
return rootView;
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
/**
* 初始化Chart
*/
private void initChart() {
ArrayList<Entry> temperatureValues = new ArrayList<>();
float[] temperature = {20f, 90f, 60f, 88f};
temperatureValues.add(new Entry(0, 0));
for (int i = 0; i < temperature.length; i++) {
temperatureValues.add(new Entry(i + 1, temperature[i]));
}
ChartUtils.initSingleLineChart(temperatureChart, temperatureValues, "近15天平均温度", 0xFF01B67A);
ArrayList<Entry> humidityValues = new ArrayList<>();
float[] levels = {20f, 90f, 60f, 88f};
humidityValues.add(new Entry(0, 0));
for (int i = 0; i < levels.length; i++) {
humidityValues.add(new Entry(i + 1, levels[i]));
}
ChartUtils.initSingleLineChart(humidityChart, humidityValues, "近15天平均湿度", 0xFF01B67A);
}
}

View File

@@ -75,16 +75,13 @@ public class HeartRateFragment extends BaseFragment {
*/
private void initChart() {
ArrayList<Entry> pointValues = new ArrayList<>();
pointValues.add(new Entry(0, 100));
ArrayList<Float> data = new ArrayList<>();
int i;
float[] levels = {2f, 90f, 60f, 88f};
for (i = 1; i <= levels.length - 1; i++) {
pointValues.add(new Entry(i, Float.valueOf(levels[i])));
data.add(Float.valueOf(levels[i]));
float[] levels = {20f, 90f, 60f, 88f, 100f};
pointValues.add(new Entry(0, 0));
for (i = 0; i < levels.length; i++) {
pointValues.add(new Entry(i + 1, levels[i]));
}
pointValues.add(new Entry(i, 0));
ChartUtils.initSingleLineChart(chart, pointValues, "心率统计图");
ChartUtils.initSingleLineChart(chart, pointValues, "近15天平均心率", 0xFFF56EC0);
}
}

View File

@@ -33,13 +33,13 @@ public class ChartUtils {
* @param linename
* @return
*/
public static void initSingleLineChart(LineChart mLineChart, List<Entry> list, String linename) {
public static void initSingleLineChart(LineChart mLineChart, List<Entry> list, String linename,int fillColor) {
LineDataSet dataSet = new LineDataSet(list, "Label"); // add entries to dataset
dataSet.setColor(Color.parseColor("#d63f9c"));//线条颜色
dataSet.setColor(fillColor);//线条颜色
dataSet.setCircleColor(Color.parseColor("#7d7d7d"));//圆点颜色
dataSet.setDrawFilled(true);
dataSet.setFillColor(0xFFF56EC0);
dataSet.setFillColor(fillColor);
dataSet.setLineWidth(1f);//线条宽度
//设置样式
@@ -73,7 +73,7 @@ public class ChartUtils {
//隐藏x轴描述
Description description = new Description();
description.setText("近15天平均心率");
description.setText(linename);
description.setTextSize(12f);
// description.setTextColor(0x000);
description.setTextColor(Color.WHITE);

View 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="#ffffff" android:pathData="M512.2,964.5c-105.1,0 -207.1,-55.2 -266.2,-144.1 -56.4,-84.8 -65.8,-188.2 -25.9,-284.1 41,-75.5 86.4,-144.1 130.4,-210.4 34.1,-51.5 69.3,-104.7 102.2,-160.6 12,-20.3 23.4,-42.9 34.4,-64.6 7.7,-15.2 15.5,-30.7 23.5,-45.4l54.7,108.1 0.3,0.4c32.2,54.9 69,107.5 104.5,158.3 51,73 99.1,141.9 132.6,214.1 40.9,88.9 32.7,193.8 -21.9,280.6 -57.1,90.7 -155.4,145.9 -263,147.7 -1.8,0 -3.6,0 -5.3,0zM552.3,233.3c-21.2,-29.6 -65,-30 -86.8,-0.9 -65.6,87.5 -148.8,213.1 -184.7,281.4 -39.5,78.6 -40,178 9.1,259.8 48.3,80.4 135.8,136 228.4,138.2l1,-0c88.6,-3.4 180.6,-65.9 224.2,-146.3 46.5,-85.8 33.9,-185.8 -23.3,-281.5l-0.5,-0.7c-18.6,-27.5 -44.7,-68.6 -72.3,-112 -24.9,-39.1 -64.8,-95.6 -95.1,-137.9z"/>
<path android:fillColor="#ffffff" android:pathData="M743.7,589.7c-51.6,-11.9 -144.6,-20.2 -245.5,33.7 -90.9,48.6 -179.6,20.8 -226.3,-1.4 -2.3,50.4 10.7,102.8 38.5,149.2 45.1,75.1 120.7,119.4 207.3,121.4l1,-0c71.6,-2.7 140.9,-41 184.7,-99.9 10.8,-16.9 20.6,-34.3 29.3,-51.5 20,-47.7 23.6,-99.3 11,-151.5z"/>
</vector>

View File

@@ -0,0 +1,4 @@
<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="M514.8,83.3c20,0.2 40,1.5 59.8,4.4 39.2,5.8 77.7,17.1 113.8,33.5a429.7,429.7 0,0 1,117.5 78.7,431.6 431.6,0 0,1 85.5,112.3 426.5,426.5 0,0 1,41.6 118.6c8.7,45.6 10,92.5 3.9,138.4a425.2,425.2 0,0 1,-37.4 126.1,430.6 430.6,0 0,1 -88.1,123.2 429.8,429.8 0,0 1,-132.6 88.4,429.7 429.7,0 0,1 -328.8,1.9 428.9,428.9 0,0 1,-116.5 -71.2c-39.8,-34.1 -73.3,-75.4 -98.4,-121.5a425.4,425.4 0,0 1,-40.8 -107.5,430.8 430.8,0 0,1 -8.8,-140.5c4.4,-43.2 15.4,-85.7 32.5,-125.4a427.6,427.6 0,0 1,83.7 -126.5,431.3 431.3,0 0,1 129.2,-93c35.1,-16.4 72.4,-27.8 110.6,-34.1 20.6,-3.4 41.4,-5.3 62.2,-5.8 3.7,0 7.4,-0.2 11.1,0zM509.5,117.4c-18.4,0 -36.8,1.4 -55.1,4.1 -36.1,5.3 -71.4,15.7 -104.7,30.7 -36.9,16.7 -71.1,39.1 -101.2,66a397.2,397.2 0,0 0,-86.8 112,392.9 392.9,0 0,0 -37.2,107c-8.2,42.7 -9.3,86.7 -3.2,129.9 5.6,40.1 17.5,79.2 35.1,115.7a395.9,395.9 0,0 0,81.7 113c35.4,34.1 77.1,61.6 122.6,80.6a396.6,396.6 0,0 0,151.3 30c51.8,0 103.5,-10.2 151.3,-30a397.3,397.3 0,0 0,122.6 -80.6,395.7 395.7,0 0,0 81.7,-113 392.1,392.1 0,0 0,35.1 -115.7c6,-43.2 4.9,-87.2 -3.2,-129.9a393,393 0,0 0,-37.2 -107,396.8 396.8,0 0,0 -86.8,-112 399.2,399.2 0,0 0,-101.2 -66,393 393,0 0,0 -104.7,-30.7 372,372 0,0 0,-55.1 -4.1c-2.6,-0.2 -2.6,-0.2 -5.1,0zM591.7,351.6a85.2,85.2 0,0 1,85.4 85.3c0,9.6 -7.6,17.1 -17.1,17.1 -9.5,0 -17.1,-7.5 -17.1,-17.1v0.2c0,-28.3 -22.9,-51.4 -51.2,-51.4h-34.1a51.2,51.2 0,0 0,-51.2 51.4v170.3c0,28.5 22.9,51.4 51.2,51.4h34.1a51.1,51.1 0,0 0,51.2 -51.4v0.2a17.1,17.1 0,0 1,34.1 0v0.2c0,47.1 -38.2,85.2 -85.4,85.2h-34.1a85.1,85.1 0,0 1,-85.4 -85.2L472.3,436.9c0,-47.1 38.2,-85.3 85.4,-85.3h34.1zM369.9,351.6a68.3,68.3 0,1 0,0 136.5,68.3 68.3,0 0,0 0,-136.5zM369.9,454c-18.8,0 -34.1,-15.2 -34.1,-34.1 0,-18.8 15.3,-34.1 34.1,-34.1s34.1,15.4 34.1,34.1c0,18.9 -15.3,34.1 -34.1,34.1z"/>
</vector>

View File

@@ -1,12 +1,222 @@
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="环境" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/environment_bg"
app:contentInsetStart="0dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="2019-8-18"
android:textColor="#FFF"
android:textSize="16sp" />
</android.support.v7.widget.Toolbar>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"
android:background="@color/environment_bg"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="采集数据时间:"
android:textColor="@color/white_text"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="2019-8-20 15:58"
android:textColor="@color/white_text"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/environment_bg"
android:gravity="center"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center">
<me.itangqi.waveloadingview.WaveLoadingView
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
app:wlv_borderColor="#71d7b6"
app:wlv_borderWidth="8dp"
app:wlv_progressValue="0"
app:wlv_round_rectangle="true"
app:wlv_shapeType="circle"
app:wlv_titleCenter=""
app:wlv_titleCenterColor="@android:color/white"
app:wlv_titleCenterSize="15sp"
app:wlv_titleCenterStrokeColor="#2fb689"
app:wlv_titleCenterStrokeWidth="3dp"
app:wlv_triangle_direction="north"
app:wlv_waveAmplitude="70"
app:wlv_waveColor="#2fb689" />
<LinearLayout
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="28dp"
android:layout_height="28dp"
android:src="@drawable/ic_temperature" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginTop="3dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/temperature_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="26.4"
android:textColor="#FFF"
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="℃"
android:textColor="#FFF"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<TextView
android:layout_width="30dp"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center">
<me.itangqi.waveloadingview.WaveLoadingView
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
app:wlv_borderColor="#71d7b6"
app:wlv_borderWidth="8dp"
app:wlv_progressValue="0"
app:wlv_round_rectangle="true"
app:wlv_shapeType="circle"
app:wlv_titleCenter=""
app:wlv_titleCenterColor="@android:color/white"
app:wlv_titleCenterSize="15sp"
app:wlv_titleCenterStrokeColor="#2fb689"
app:wlv_titleCenterStrokeWidth="3dp"
app:wlv_triangle_direction="north"
app:wlv_waveAmplitude="70"
app:wlv_waveColor="#2fb689" />
<LinearLayout
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/ic_humidity" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginTop="3dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/humidity_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="78"
android:textColor="#FFF"
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="%"
android:textColor="#FFF"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.2"
android:orientation="vertical"
android:padding="5dp">
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/temperature_chart"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</com.github.mikephil.charting.charts.LineChart>
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/humidity_chart"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="1">
</com.github.mikephil.charting.charts.LineChart>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@@ -8,7 +8,7 @@
<color name="step_string">#e66d4a</color>
<color name="sleep_bg">#3d4eca</color>
<color name="heart_rate_bg">#d63f9c</color>
<color name="environment_bg">#5adeb2</color>
<color name="environment_bg">#2fb689</color>
<color name="place_holder">#dfdede</color>

View File

@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1566287149357" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4202" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M514.816 83.285333c20.0192 0.170667 39.9872 1.536 59.8016 4.437334 39.236267 5.802667 77.653333 17.066667 113.800533 33.450666a429.738667 429.738667 0 0 1 117.469867 78.677334 431.616 431.616 0 0 1 85.504 112.298666 426.496 426.496 0 0 1 41.642667 118.613334c8.738133 45.568 10.0352 92.501333 3.8912 138.410666a425.1648 425.1648 0 0 1-37.393067 126.122667 430.6432 430.6432 0 0 1-88.081067 123.221333 429.806933 429.806933 0 0 1-132.608 88.405334 429.738667 429.738667 0 0 1-328.789333 1.877333 428.936533 428.936533 0 0 1-116.5312-71.168c-39.8336-34.133333-73.335467-75.434667-98.372267-121.514667a425.352533 425.352533 0 0 1-40.789333-107.52 430.813867 430.813867 0 0 1-8.772267-140.458666c4.386133-43.178667 15.36-85.674667 32.529067-125.44a427.639467 427.639467 0 0 1 83.677867-126.464 431.274667 431.274667 0 0 1 129.160533-93.013334c35.072-16.384 72.362667-27.818667 110.557867-34.133333 20.5824-3.413333 41.3696-5.290667 62.225066-5.802667 3.703467 0 7.389867-0.170667 11.076267 0z m-5.3248 34.133334c-18.432 0-36.829867 1.365333-55.074133 4.096-36.078933 5.290667-71.424 15.701333-104.6528 30.72-36.864 16.725333-71.082667 39.082667-101.1712 66.048a397.2096 397.2096 0 0 0-86.818134 111.957333 392.9088 392.9088 0 0 0-37.205333 107.008c-8.192 42.666667-9.2672 86.698667-3.242667 129.877333 5.632 40.106667 17.5104 79.189333 35.106134 115.712a395.946667 395.946667 0 0 0 81.749333 112.981334c35.413333 34.133333 77.141333 61.610667 122.5728 80.554666a396.612267 396.612267 0 0 0 151.296 30.037334c51.797333 0 103.458133-10.24 151.278933-30.037334a397.312 397.312 0 0 0 122.5728-80.554666 395.6736 395.6736 0 0 0 81.749334-112.981334 392.055467 392.055467 0 0 0 35.106133-115.712c6.0416-43.178667 4.949333-87.210667-3.242667-129.877333a392.96 392.96 0 0 0-37.205333-107.008 396.834133 396.834133 0 0 0-86.801067-111.957333 399.2064 399.2064 0 0 0-101.1712-66.048 393.0112 393.0112 0 0 0-104.669866-30.72 371.950933 371.950933 0 0 0-55.074134-4.096c-2.56-0.170667-2.56-0.170667-5.12 0zM591.701333 351.573333a85.248 85.248 0 0 1 85.367467 85.333334c0 9.557333-7.6288 17.066667-17.066667 17.066666-9.506133 0-17.066667-7.509333-17.066666-17.066666v0.170666c0-28.330667-22.869333-51.370667-51.234134-51.370666h-34.065066a51.217067 51.217067 0 0 0-51.234134 51.370666v170.325334c0 28.501333 22.852267 51.370667 51.234134 51.370666h34.065066a51.114667 51.114667 0 0 0 51.234134-51.370666v0.170666a17.083733 17.083733 0 0 1 34.133333 0v0.170667c0 47.104-38.1952 85.162667-85.367467 85.162667h-34.065066a85.111467 85.111467 0 0 1-85.367467-85.162667V436.906667c0-47.104 38.1952-85.333333 85.367467-85.333334h34.065066z m-221.832533 0a68.266667 68.266667 0 1 0 0 136.533334 68.266667 68.266667 0 0 0 0-136.533334z m0 102.4c-18.8416 0-34.133333-15.189333-34.133333-34.133333 0-18.773333 15.291733-34.133333 34.133333-34.133333s34.133333 15.36 34.133333 34.133333c0 18.944-15.291733 34.133333-34.133333 34.133333z" p-id="4203" fill="#ffffff"></path></svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1566287185652" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5009" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M512.23 964.458c-105.085 0-207.088-55.216-266.206-144.094-56.376-84.75-65.805-188.237-25.919-284.054 41.01-75.514 86.42-144.106 130.35-210.45 34.079-51.479 69.324-104.708 102.15-160.647 11.984-20.335 23.372-42.862 34.394-64.646 7.666-15.167 15.494-30.654 23.55-45.433l54.66 108.1 0.268 0.45c32.243 54.916 68.96 107.487 104.47 158.331 50.95 72.955 99.077 141.866 132.55 214.096 40.904 88.911 32.712 193.842-21.933 280.646-57.12 90.743-155.445 145.942-263.004 147.656-1.788 0.03-3.56 0.045-5.33 0.045z m40.026-731.162c-21.221-29.56-64.986-30.04-86.823-0.929-65.628 87.493-148.787 213.121-184.73 281.417-39.498 78.571-40.05 178.02 9.08 259.813 48.297 80.395 135.76 136.023 228.424 138.178l1.02-0.008c88.579-3.392 180.612-65.862 224.218-146.338 46.51-85.822 33.948-185.787-23.333-281.491l-0.477-0.748c-18.553-27.546-44.65-68.564-72.275-111.988-24.875-39.095-64.758-95.634-95.104-137.906z" p-id="5010" fill="#ffffff"></path><path d="M743.661 589.7c-51.596-11.877-144.6-20.184-245.463 33.726-90.857 48.56-179.554 20.807-226.283-1.396-2.256 50.44 10.69 102.826 38.522 149.162 45.145 75.147 120.706 119.403 207.32 121.417l0.953-0.008c71.576-2.741 140.881-41.012 184.7-99.918 10.846-16.894 20.61-34.331 29.257-51.516 19.955-47.712 23.573-99.291 10.994-151.466z" p-id="5011" fill="#ffffff"></path></svg>

After

Width:  |  Height:  |  Size: 1.6 KiB