| showInfo(getString(R.string.state_error, errMsg, errCode), true); | showInfo(getString(R.string.state_error, errMsg, errCode), true); | ||||
| } | } | ||||
| private long mOldBM15DataTime = 0; | |||||
| private String mOldData = ""; | |||||
| @Override | @Override | ||||
| public void onGetWeightData(final WeightData weightData) { | public void onGetWeightData(final WeightData weightData) { | ||||
| if (weightData == null) | if (weightData == null) | ||||
| } | } | ||||
| if (weightData.getDeviceType() == AicareBleConfig.BM_15) { | if (weightData.getDeviceType() == AicareBleConfig.BM_15) { | ||||
| if (weightData.getCmdType() != 3) { | if (weightData.getCmdType() != 3) { | ||||
| long time = System.currentTimeMillis(); | |||||
| isNewBM15TestData = true; | isNewBM15TestData = true; | ||||
| showInfo(weightData.toString(), false); | |||||
| if (weightData.toString().equalsIgnoreCase(mOldData)) { | |||||
| if (time - mOldBM15DataTime > 1000) { | |||||
| mOldBM15DataTime = time; | |||||
| showInfo(weightData.toString(), false); | |||||
| } | |||||
| } else { | |||||
| mOldBM15DataTime = time; | |||||
| showInfo(weightData.toString(), false); | |||||
| } | |||||
| mOldData = weightData.toString(); | |||||
| } | } | ||||
| if (weightData.getCmdType() == 3 && weightData.getAdc() > 0 && isNewBM15TestData) { | if (weightData.getCmdType() == 3 && weightData.getAdc() > 0 && isNewBM15TestData) { | ||||
| isNewBM15TestData = false; | isNewBM15TestData = false; | ||||
| switch (index) { | switch (index) { | ||||
| case WBYService.BLE_VERSION: | case WBYService.BLE_VERSION: | ||||
| showInfo(getString(R.string.ble_version, result), true); | showInfo(getString(R.string.ble_version, result), true); | ||||
| tv_version.setText(getString(R.string.ble_version, result)); | |||||
| break; | break; | ||||
| case WBYService.USER_ID: | case WBYService.USER_ID: | ||||
| showInfo(getString(R.string.user_id, result), true); | showInfo(getString(R.string.user_id, result), true); |