heartrate
This commit is contained in:
@@ -17,6 +17,7 @@ import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.scorpiomiku.oldpeoplehome.R;
|
||||
import com.scorpiomiku.oldpeoplehome.base.BaseActivity;
|
||||
@@ -41,7 +42,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import butterknife.BindView;
|
||||
@@ -59,12 +59,18 @@ public class OldPeopleMainActivity extends BaseActivity {
|
||||
BottomNavigationView navigation;
|
||||
@BindView(R.id.floating_button)
|
||||
FloatingActionButton floatingButton;
|
||||
|
||||
private String step;
|
||||
private String cal;
|
||||
private String distance;
|
||||
private String sportTime;
|
||||
private String curHeartRate;
|
||||
private String[] heartRates = new String[6];
|
||||
private String sleepType;
|
||||
private String bloodPressureShrink;
|
||||
private String bloodPressureDiastole;
|
||||
private String oxygen;
|
||||
|
||||
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener;
|
||||
private FragmentManager fragmentManager;
|
||||
private BaseFragment[] fragments = {
|
||||
@@ -94,6 +100,9 @@ public class OldPeopleMainActivity extends BaseActivity {
|
||||
//蓝牙获取信息
|
||||
loadData();
|
||||
break;
|
||||
case 2:
|
||||
((HeartRateFragment) fragments[2]).changeText(curHeartRate, bloodPressureShrink, bloodPressureDiastole, oxygen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -328,8 +337,14 @@ public class OldPeopleMainActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetSenserData(int i, long l, int i1, int i2) throws RemoteException {
|
||||
|
||||
public void onGetSenserData(int result, long timestamp, int heartrate, int sleepstatu)
|
||||
throws RemoteException {
|
||||
Date date = new Date(timestamp * 1000);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
|
||||
String time = sdf.format(date);
|
||||
curHeartRate = heartrate + "";
|
||||
LogUtils.logd("onGetSenserData-" + "result: " + result + ",time:" + time + ",heartrate:" + heartrate + ",sleepstatu:" + sleepstatu);
|
||||
handler.sendEmptyMessage(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -400,8 +415,17 @@ public class OldPeopleMainActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceiveSensorData(int i, int i1, int i2, int i3, int i4) throws RemoteException {
|
||||
|
||||
public void onReceiveSensorData(int arg0, int arg1, int arg2, int arg3,
|
||||
int arg4) throws RemoteException {
|
||||
LogUtils.logd("onReceiveSensorData" + "result:" + arg0 + " , " + arg1 + " , " + arg2 + " , " + arg3 + " , " + arg4);
|
||||
if (arg2 != 0) {
|
||||
LogUtils.shortToast("测量成功");
|
||||
}
|
||||
curHeartRate = arg0 + "";
|
||||
bloodPressureShrink = arg1 + "";
|
||||
bloodPressureDiastole = arg2 + "";
|
||||
oxygen = arg3 + "";
|
||||
handler.sendEmptyMessage(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -472,8 +496,8 @@ public class OldPeopleMainActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName componentName, IBinder service) {
|
||||
LogUtils.shortToast("Service connected");
|
||||
|
||||
mService = IRemoteService.Stub.asInterface(service);
|
||||
|
||||
try {
|
||||
mService.registerCallback(mServiceCallback);
|
||||
mService.openSDKLog(bSave, pathLog, "blue.log");
|
||||
@@ -617,8 +641,7 @@ public class OldPeopleMainActivity extends BaseActivity {
|
||||
private void getNewHandData() {
|
||||
try {
|
||||
mService.getCurSportData();
|
||||
mService.getDataByDay(2, 0); //获取心率
|
||||
// mService.getDataByDay(1, 0);
|
||||
// mService.getDataByDay(2, 0); //获取心率
|
||||
for (int i = 5; i >= 0; i--) {
|
||||
|
||||
}
|
||||
@@ -632,10 +655,34 @@ public class OldPeopleMainActivity extends BaseActivity {
|
||||
getNewHandData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新UI调用
|
||||
*/
|
||||
private void loadData() {
|
||||
for (int i = 0; i < fragments.length; i++) {
|
||||
refreshUi(step, cal, distance, sportTime, heartRates, sleepType, fragments[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean heartRateOpen = false;
|
||||
|
||||
/**
|
||||
* 测试心率按钮点击事件
|
||||
*/
|
||||
public void setHeartRateMode(TextView begin) {
|
||||
if (heartRateOpen) {
|
||||
//关闭
|
||||
begin.setText("开启");
|
||||
} else {
|
||||
//开启
|
||||
begin.setText("关闭");
|
||||
}
|
||||
heartRateOpen = !heartRateOpen;
|
||||
try {
|
||||
mService.setHeartRateMode(heartRateOpen, 120);
|
||||
mService.setBloodPressureMode(heartRateOpen);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ 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.modules.oldpeople.activity.OldPeopleMainActivity;
|
||||
import com.scorpiomiku.oldpeoplehome.utils.ChartUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -35,6 +36,13 @@ public class HeartRateFragment extends BaseFragment {
|
||||
@BindView(R.id.chart)
|
||||
LineChart chart;
|
||||
Unbinder unbinder;
|
||||
@BindView(R.id.diastolic)
|
||||
TextView diastolic;
|
||||
@BindView(R.id.systolic)
|
||||
TextView systolic;
|
||||
@BindView(R.id.oxy)
|
||||
TextView oxy;
|
||||
|
||||
|
||||
@Override
|
||||
protected Handler initHandle() {
|
||||
@@ -89,4 +97,23 @@ public class HeartRateFragment extends BaseFragment {
|
||||
super.refreshUi(step, cal, distance, sportTime, heartRate, sleepType);
|
||||
heartRateText.setText(heartRate[5]);
|
||||
}
|
||||
|
||||
|
||||
@OnClick(R.id.begin)
|
||||
public void onViewClicked() {
|
||||
assert ((OldPeopleMainActivity) getContext()) != null;
|
||||
((OldPeopleMainActivity) getContext()).setHeartRateMode(begin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数值
|
||||
*
|
||||
* @param heart
|
||||
*/
|
||||
public void changeText(String heart, String systolic, String diastolic, String oxy) {
|
||||
heartRateText.setText(heart);
|
||||
this.diastolic.setText(diastolic);
|
||||
this.systolic.setText(systolic);
|
||||
this.oxy.setText(oxy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<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="#d63f9c" 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="M591.9,558.1h-4.8a366.9,366.9 0,0 1,-122.9 -71.7,13.4 13.4,0 0,1 -4.6,-11.9v-4.8a50.9,50.9 0,0 0,0 -6.5,125.2 125.2,0 0,0 -64.6,-108.9 13.7,13.7 0,0 1,-7.1 -11.4,113.8 113.8,0 0,1 62.3,-120.3c20.8,-8 74.8,-17.4 139.7,56.9 45.8,-51.5 95.3,-72.5 138,-56.9a109.5,109.5 0,0 1,65.4 108.1c0,75.1 -50.6,174.4 -197.4,227.6a16.2,16.2 0,0 1,-4 0zM489,469.3a339.6,339.6 0,0 0,103 59.2c129.4,-48.9 174.9,-134.8 174.1,-199.1A81.9,81.9 0,0 0,719.6 247.5c-33.8,-11.7 -76.8,11.1 -117.5,62.3a13.9,13.9 0,0 1,-11.1 5.4,13.9 13.9,0 0,1 -11.1,-5.4C540.4,257.4 496.1,235 461.7,248.3a85.3,85.3 0,0 0,-44.7 85.3,153.3 153.3,0 0,1 72.2,129.7 56.9,56.9 0,0 1,-0.3 6z"/>
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M335.6,616.1a153.9,153.9 0,1 1,153.6 -153.9,154.2 154.2,0 0,1 -153.6,153.9zM335.6,337.1a125.4,125.4 0,1 0,125.2 125.2,125.4 125.4,0 0,0 -125.2,-125.2z"/>
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M335.6,462.2m-27.9,0a27.9,27.9 0,1 0,55.8 0,27.9 27.9,0 1,0 -55.8,0Z"/>
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M323.1,464.5l-42.1,-77.1 64.6,59.7a14.8,14.8 0,0 1,0 20.5,14.2 14.2,0 0,1 -20.2,0 9.1,9.1 0,0 1,-2.3 -3.1zM341.3,682.7a28.4,28.4 0,0 1,-28.4 -28.4v-32.4a28.4,28.4 0,0 1,56.9 0V654.2a28.4,28.4 0,0 1,-28.4 28.4z"/>
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M533.9,743H398.2a72.2,72.2 0,0 1,-72.2 -72.2V640a14.2,14.2 0,0 1,28.4 0v30.7A43.8,43.8 0,0 0,398.2 714.5h134.5a14.2,14.2 0,0 1,0 28.4z"/>
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M662.5,812.7c-74.8,0 -142.2,-43 -142.2,-90.2s65.4,-90.2 142.2,-90.2 142.2,61.4 142.2,90.2 -65.1,90.2 -142.2,90.2zM662.5,660.8c-64.6,0 -113.8,33.3 -113.8,61.7s47.8,61.7 113.8,61.7a138.5,138.5 0,0 0,113.8 -61.4,142.2 142.2,0 0,0 -113.8,-62z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,9 @@
|
||||
<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="#d63f9c" android:pathData="M512,512m-481.9,0a481.9,481.9 0,1 0,963.8 0,481.9 481.9,0 1,0 -963.8,0Z"/>
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M853.4,764.9c-1.9,-0.9 -4.7,-2.8 -8.5,-2.8h-38.9c0.9,0 2.8,-2.8 3.8,-3.8 2.8,-3.8 7.6,-7.5 15.2,-13.2 7.6,-5.6 12.3,-10.3 16.1,-13.2 2.8,-2.8 6.6,-6.6 9.5,-11.3 2.9,-4.7 4.7,-10.3 4.7,-16.9 0,-3.8 -0.9,-7.5 -1.9,-11.3 -1.9,-3.8 -3.8,-6.6 -5.7,-9.4a34.1,34.1 0,0 0,-9.5 -6.6c-5.7,-1.9 -11.4,-3.8 -19,-3.8 -6.7,0 -11.4,0.9 -16.1,2.8a34.2,34.2 0,0 0,-11.4 7.5c-2.8,2.8 -5.7,6.6 -6.6,10.4 -1.9,3.8 -1.9,7.5 -1.9,10.3 0,2.8 0.9,4.7 2.9,6.6 1.9,1.9 3.8,2.8 5.7,2.8 2.9,0 4.8,-0.9 6.7,-2.8s2.8,-4.7 3.8,-7.5c0.9,-2.8 1.9,-5.6 2.8,-5.6 3.8,-5.6 8.5,-8.5 15.2,-8.5 2.9,0 5.7,0.9 8.5,1.9 2.9,0.9 4.8,2.8 5.7,5.6 1.9,2.8 1.9,5.6 1.9,8.5 0,2.8 -0.9,5.6 -1.9,8.5 -0.9,2.8 -3.8,5.6 -5.7,8.5 -2.8,2.8 -5.7,5.6 -10.4,8.5 -1.9,1.9 -5.7,4.7 -11.4,9.4 -5.7,4.7 -11.4,10.4 -18,16.9 -1.9,1.9 -2.8,3.8 -4.7,6.6 -0.9,2.8 -1.9,5.6 -1.9,6.6 0,2.8 0.9,4.7 2.9,7.5 1.9,1.9 4.7,2.8 8.5,2.8h54.1a10.8,10.8 0,0 0,7.6 -2.8,8.5 8.5,0 0,0 2.9,-6.6c-1.9,-0.9 -2.9,-3.8 -4.8,-5.6z"/>
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M413.7,560.2m15.1,0l182.5,0q15.1,0 15.1,15.1l0,0q0,15.1 -15.1,15.1l-182.5,0q-15.1,0 -15.1,-15.1l0,0q0,-15.1 15.1,-15.1Z"/>
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M535,484.7v180.7a15.1,15.1 0,1 1,-30.1 0v-180.7a15.1,15.1 0,0 1,30.1 0z"/>
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M647.8,756.5a234.1,234.1 0,0 1,-143.7 48.9C375.4,805.4 271.1,702.4 271.1,575.4c0,-84.4 76.5,-201.6 228.9,-354.2l10.4,-10.4 10.1,10.7c144.3,152.5 216.8,269.7 216.8,353.9v2.5a78.7,78.7 0,0 0,-28.4 -5.7c-1.9,-73 -68,-180.6 -199,-320.9 -140.4,142.4 -210.3,251.2 -210.3,324.1 0,111.5 91.6,201.9 204.7,201.9 48,0 92.2,-16.3 127.1,-43.6a103.5,103.5 0,0 0,16.6 22.8z"/>
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M707.8,768c-41.6,0 -75.3,-40.4 -75.3,-90.4s33.7,-90.4 75.3,-90.4 75.3,40.4 75.3,90.4 -33.7,90.4 -75.3,90.4zM707.8,737.9c25,0 45.2,-27 45.2,-60.2s-20.2,-60.2 -45.2,-60.2 -45.2,27 -45.2,60.2 20.2,60.2 45.2,60.2z"/>
|
||||
</vector>
|
||||
@@ -147,13 +147,13 @@
|
||||
<ImageView
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:src="@drawable/ic_heart_log" />
|
||||
android:src="@drawable/ic_bloodpressure" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="最小心率"
|
||||
android:text="血压(收缩压)"
|
||||
android:textColor="@color/heart_rate_bg"
|
||||
android:textSize="14sp" />
|
||||
|
||||
@@ -165,6 +165,7 @@
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/diastolic"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="0"
|
||||
@@ -177,12 +178,13 @@
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:gravity="center"
|
||||
android:text="BPM"
|
||||
android:text="mmHg"
|
||||
android:textColor="@color/heart_rate_bg"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="120dp"
|
||||
@@ -193,13 +195,13 @@
|
||||
<ImageView
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:src="@drawable/ic_heart_log" />
|
||||
android:src="@drawable/ic_bloodpressure" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="平均心率"
|
||||
android:text="血压(舒张压)"
|
||||
android:textColor="@color/heart_rate_bg"
|
||||
android:textSize="14sp" />
|
||||
|
||||
@@ -211,6 +213,7 @@
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/systolic"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="0"
|
||||
@@ -223,12 +226,13 @@
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:gravity="center"
|
||||
android:text="BPM"
|
||||
android:text="mmHg"
|
||||
android:textColor="@color/heart_rate_bg"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="120dp"
|
||||
@@ -239,13 +243,13 @@
|
||||
<ImageView
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:src="@drawable/ic_heart_log" />
|
||||
android:src="@drawable/ic_oxy" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="最大心率"
|
||||
android:text="血氧"
|
||||
android:textColor="@color/heart_rate_bg"
|
||||
android:textSize="14sp" />
|
||||
|
||||
@@ -257,6 +261,7 @@
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/oxy"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="0"
|
||||
@@ -269,7 +274,7 @@
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:gravity="center"
|
||||
android:text="BPM"
|
||||
android:text="HbO2"
|
||||
android:textColor="@color/heart_rate_bg"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
@@ -284,6 +289,7 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.2"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.github.mikephil.charting.charts.LineChart
|
||||
android:id="@+id/chart"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
Reference in New Issue
Block a user