private ActivityAnimalHeatBinding heatBinding;
+ //是否有配戴,如果没有配戴,就不更新UI了。
+ private boolean mHasWear = false;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//接收到了佩戴的广播去获取数据
//true表示没佩戴了,false表示有佩戴
boolean isAntiOff = SystemUtils.getSystemPropertiesBoolean("persist.sys.ic_antioff", true);
+ this.mHasWear = !isAntiOff;
IcLog.i(TAG, "isAntiOff == > " + isAntiOff);
//如果已经佩戴了,就去获取数据
if (!isAntiOff && mService == null) {
IcLog.i(TAG, "tempOut -- > " + tempOut);
//这里有个瞬间过大的bug,人腕温不可能大于45度的。
currentTestType = type;
- //
+ if (!mHasWear) {
+ //没有配戴,不对数据进行更新
+ IcLog.d(TAG, "has not wear device.");
+ return;
+ }
switch (type) {
case STATE_TESTING:
if (heatBinding.getDisableWristTemp()) {
mService = ITempRemoteService.Stub.asInterface(service);
//把回调接口设置给对方
mService.registerCallback(tempInterface);
- //调用开始查询温度
- mService.onStartQueryTemp();
- //展示Loading,也 就是进度条那个
- heatBinding.setShowLoading(true);
- //设置UI正在检测中
- heatBinding.setCheckTips(tipsCheck);
+ getRemoteData();
} catch (Exception e) {
e.printStackTrace();
}
if (state == STATE_ANTI_OFF) {
heatBinding.setCheckTips(getString(R.string.no_wearing_device_tips_text));
//脱落了,给出提示
+ //停止Loading
+ heatBinding.setShowLoading(false);
} else if (state == STATE_ANTI_ON && mService == null) {
bindWorkService(AnimalHeatActivity.this);
}
- if (state == STATE_ANTI_ON && currentTestType == STATE_TEST_END) {
+ mHasWear = state == STATE_ANTI_ON;
+ if (mHasWear) {
//判断状态,如果已经检测完了,就显示检测完成
// 按客户需求,马上进来显示检测完成,看起来不爽
//那就再次检测吧,底层做了处理,多次调用测试也没关系,如果判断到繁忙的话会不处理的。
//heatBinding.setCheckTips(getString(R.string.activity_temp_tips_end));
-
+ getRemoteData();
}
}
};
private void getRemoteData() {
-
+ IcLog.d(TAG, "getRemoteData...");
if (mService == null) {
return;
}
try {
+ //调用开始查询温度
mService.onStartQueryTemp();
+ //展示Loading,也 就是进度条那个
+ heatBinding.setShowLoading(true);
+ //设置UI正在检测中
+ heatBinding.setCheckTips(tipsCheck);
} catch (Exception e) {
e.printStackTrace();
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="app_name_heart">爱健康</string>
+ <string name="app_name_heart">爱健康</string>
<string name="app_name_heartRate">心率监控</string>
- <string name="error_start_activity">应用程序启动失败</string>
+ <string name="error_start_activity">应用程序启动失败</string>
<string name="app_name">手表</string>
<string name="activity_temp_tips_check">正在测量</string>
<string name="activity_temp_tips_end">测量完成</string>
<string name="activity_temp_outside">环境</string>
+ <string name="no_wearing_device_tips_text">未配戴设备</string>
</resources>
\ No newline at end of file