Browse Source

update code

master
陈福行 2 years ago
parent
commit
d9dfe78080
2 changed files with 51 additions and 7 deletions
  1. 2
    2
      app/build.gradle
  2. 49
    5
      app/src/main/java/aicare/net/cn/iweightdemo/MyActivity.java

+ 2
- 2
app/build.gradle View File

applicationId "aicare.net.cn.sdk.iweightdemo" applicationId "aicare.net.cn.sdk.iweightdemo"
minSdkVersion 18 minSdkVersion 18
targetSdkVersion 29 targetSdkVersion 29
versionCode 17
versionName "1.3.7"
versionCode 18
versionName "1.3.8"
} }
buildTypes { buildTypes {
debug { debug {

+ 49
- 5
app/src/main/java/aicare/net/cn/iweightdemo/MyActivity.java View File



import static aicare.net.cn.iweightdemo.R.string.weight; import static aicare.net.cn.iweightdemo.R.string.weight;


/**
*
* @author xing
* @date 2022/11/11
*/
public class MyActivity extends BleProfileServiceReadyActivity implements DeviceDialog.OnDeviceScanListener, View.OnClickListener { public class MyActivity extends BleProfileServiceReadyActivity implements DeviceDialog.OnDeviceScanListener, View.OnClickListener {


private final static String TAG = "MyActivity"; private final static String TAG = "MyActivity";


private void initData() { private void initData() {
user = new User(1, 2, 28, 170, 768, 551); user = new User(1, 2, 28, 170, 768, 551);
User user2 = new User(2, 1, 25, 165, 650, 500);
User user3 = new User(3, 1, 15, 150, 450, 600);
userList.add(user); userList.add(user);
// Add multiple users for generating offline history
userList.add(user2);
userList.add(user3);
} }


private void initViews() { private void initViews() {
case R.id.rb_jin: case R.id.rb_jin:
unit = AicareBleConfig.UNIT_JIN; unit = AicareBleConfig.UNIT_JIN;
binder.syncUnit(AicareBleConfig.UNIT_JIN); binder.syncUnit(AicareBleConfig.UNIT_JIN);
break;
default:

break; break;
} }
} }
case R.id.rb_female: case R.id.rb_female:
user.setSex(2); user.setSex(2);
break; break;

default:
break;
} }
} }
}); });
if (isDeviceConnected()) { if (isDeviceConnected()) {
switch (v.getId()) { switch (v.getId()) {
case R.id.btn_sync_history: case R.id.btn_sync_history:
//Get weighing data in disconnected state
binder.syncHistory(); binder.syncHistory();
break; break;
case R.id.btn_sync_list: case R.id.btn_sync_list:
binder.syncDate(); binder.syncDate();
break; break;



case R.id.btn_query_did: case R.id.btn_query_did:
binder.queryDID(); binder.queryDID();
break; break;
binder.queryBleVersion(); binder.queryBleVersion();
break; break;


default:
break;

} }
} else if (v.getId() == R.id.btn_version) { } else if (v.getId() == R.id.btn_version) {
mGetVersion = true; mGetVersion = true;
} }
} }
break; break;

default:

break;
} }


return true; return true;
rg_change_unit.check(R.id.rb_st); rg_change_unit.check(R.id.rb_st);
weightData.setDecimalInfo(new DecimalInfo(1, 1, 1, 1, 1, 1)); weightData.setDecimalInfo(new DecimalInfo(1, 1, 1, 1, 1, 1));
break; break;

default:

break;
} }
weightData.setWeight(data.getWeight()); weightData.setWeight(data.getWeight());
weightData.setTemp(data.getTemp()); weightData.setTemp(data.getTemp());
case BleProfileService.STATE_CONNECTING: case BleProfileService.STATE_CONNECTING:
showInfo(getString(R.string.state_connecting), true); showInfo(getString(R.string.state_connecting), true);
break; break;

default:

break;
} }
} }


private void showInfo(String str, boolean showSnackBar) { private void showInfo(String str, boolean showSnackBar) {
if (showSnackBar)
if (showSnackBar) {
showSnackBar(str); showSnackBar(str);
}
String time = ParseData.getCurrentTime() + "\n----" + str; String time = ParseData.getCurrentTime() + "\n----" + str;
dataList.add(time); dataList.add(time);
listAdapter.notifyDataSetChanged(); listAdapter.notifyDataSetChanged();
toolbar.setSubtitle(deviceAddress); toolbar.setSubtitle(deviceAddress);
menu.getItem(0).setTitle(R.string.unbound); menu.getItem(0).setTitle(R.string.unbound);
break; break;

default:
break;
} }
} }




@Override @Override
public void onGetWeightData(final WeightData weightData) { public void onGetWeightData(final WeightData weightData) {
if (weightData == null)
if (weightData == null) {
return; return;
}
L.i(TAG,"WeightData:"+weightData.toString()); L.i(TAG,"WeightData:"+weightData.toString());
setWeighDataText(AicareBleConfig.getWeight(weightData.getWeight(), unit, weightData.getDecimalInfo())); setWeighDataText(AicareBleConfig.getWeight(weightData.getWeight(), unit, weightData.getDecimalInfo()));
if (weightData.getTemp() != Double.MAX_VALUE) { if (weightData.getTemp() != Double.MAX_VALUE) {
case AicareBleConfig.SettingStatus.DATA_SEND_END: case AicareBleConfig.SettingStatus.DATA_SEND_END:
showInfo(getString(R.string.settings_status, getString(R.string.data_send_end)), true); showInfo(getString(R.string.settings_status, getString(R.string.data_send_end)), true);
break; break;

default:
break;
} }
} }


case WBYService.ADC: case WBYService.ADC:
showInfo(getString(R.string.adc, result), true); showInfo(getString(R.string.adc, result), true);
break; break;

default:
break;
} }
} }




@Override @Override
protected void onGetDecimalInfo(DecimalInfo decimalInfo) { protected void onGetDecimalInfo(DecimalInfo decimalInfo) {
if (decimalInfo == null)
if (decimalInfo == null) {
return; return;
}
L.e(TAG, decimalInfo.toString()); L.e(TAG, decimalInfo.toString());
String decimalStr = (getString(R.string.source_decimal, decimalInfo.getSourceDecimal())) + (getString(R.string.kg_decimal, decimalInfo String decimalStr = (getString(R.string.source_decimal, decimalInfo.getSourceDecimal())) + (getString(R.string.kg_decimal, decimalInfo
.getKgDecimal())) + (getString(R.string.lb_decimal, decimalInfo.getLbDecimal())) + (getString(R.string.st_decimal, decimalInfo .getKgDecimal())) + (getString(R.string.lb_decimal, decimalInfo.getLbDecimal())) + (getString(R.string.st_decimal, decimalInfo


@Override @Override
protected void onGetAlgorithmInfo(AlgorithmInfo algorithmInfo) { protected void onGetAlgorithmInfo(AlgorithmInfo algorithmInfo) {
if (algorithmInfo == null)
if (algorithmInfo == null) {
return; return;
}
String algorithmStr = (getString(R.string.adc, String.valueOf(algorithmInfo.getAdc())) + (getString(R.string.algorithm_id, algorithmInfo.getAlgorithmId()))); String algorithmStr = (getString(R.string.adc, String.valueOf(algorithmInfo.getAdc())) + (getString(R.string.algorithm_id, algorithmInfo.getAlgorithmId())));
showInfo(algorithmStr, true); showInfo(algorithmStr, true);
if (user != null) { if (user != null) {

Loading…
Cancel
Save