|
|
@@ -52,6 +52,11 @@ import androidx.core.app.ActivityCompat; |
|
|
|
|
|
|
|
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 { |
|
|
|
|
|
|
|
private final static String TAG = "MyActivity"; |
|
|
@@ -119,7 +124,12 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
|
|
|
|
private void initData() { |
|
|
|
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); |
|
|
|
// Add multiple users for generating offline history |
|
|
|
userList.add(user2); |
|
|
|
userList.add(user3); |
|
|
|
} |
|
|
|
|
|
|
|
private void initViews() { |
|
|
@@ -241,6 +251,9 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
case R.id.rb_jin: |
|
|
|
unit = AicareBleConfig.UNIT_JIN; |
|
|
|
binder.syncUnit(AicareBleConfig.UNIT_JIN); |
|
|
|
break; |
|
|
|
default: |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@@ -257,6 +270,9 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
case R.id.rb_female: |
|
|
|
user.setSex(2); |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
@@ -352,6 +368,7 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
if (isDeviceConnected()) { |
|
|
|
switch (v.getId()) { |
|
|
|
case R.id.btn_sync_history: |
|
|
|
//Get weighing data in disconnected state |
|
|
|
binder.syncHistory(); |
|
|
|
break; |
|
|
|
case R.id.btn_sync_list: |
|
|
@@ -364,7 +381,6 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
binder.syncDate(); |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case R.id.btn_query_did: |
|
|
|
binder.queryDID(); |
|
|
|
break; |
|
|
@@ -372,6 +388,9 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
binder.queryBleVersion(); |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} else if (v.getId() == R.id.btn_version) { |
|
|
|
mGetVersion = true; |
|
|
@@ -406,6 +425,10 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
@@ -484,6 +507,10 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
rg_change_unit.check(R.id.rb_st); |
|
|
|
weightData.setDecimalInfo(new DecimalInfo(1, 1, 1, 1, 1, 1)); |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
weightData.setWeight(data.getWeight()); |
|
|
|
weightData.setTemp(data.getTemp()); |
|
|
@@ -605,12 +632,17 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
case BleProfileService.STATE_CONNECTING: |
|
|
|
showInfo(getString(R.string.state_connecting), true); |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void showInfo(String str, boolean showSnackBar) { |
|
|
|
if (showSnackBar) |
|
|
|
if (showSnackBar) { |
|
|
|
showSnackBar(str); |
|
|
|
} |
|
|
|
String time = ParseData.getCurrentTime() + "\n----" + str; |
|
|
|
dataList.add(time); |
|
|
|
listAdapter.notifyDataSetChanged(); |
|
|
@@ -634,6 +666,9 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
toolbar.setSubtitle(deviceAddress); |
|
|
|
menu.getItem(0).setTitle(R.string.unbound); |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -648,8 +683,9 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onGetWeightData(final WeightData weightData) { |
|
|
|
if (weightData == null) |
|
|
|
if (weightData == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
L.i(TAG,"WeightData:"+weightData.toString()); |
|
|
|
setWeighDataText(AicareBleConfig.getWeight(weightData.getWeight(), unit, weightData.getDecimalInfo())); |
|
|
|
if (weightData.getTemp() != Double.MAX_VALUE) { |
|
|
@@ -765,6 +801,9 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
case AicareBleConfig.SettingStatus.DATA_SEND_END: |
|
|
|
showInfo(getString(R.string.settings_status, getString(R.string.data_send_end)), true); |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -788,6 +827,9 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
case WBYService.ADC: |
|
|
|
showInfo(getString(R.string.adc, result), true); |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -834,8 +876,9 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onGetDecimalInfo(DecimalInfo decimalInfo) { |
|
|
|
if (decimalInfo == null) |
|
|
|
if (decimalInfo == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
L.e(TAG, decimalInfo.toString()); |
|
|
|
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 |
|
|
@@ -845,8 +888,9 @@ public class MyActivity extends BleProfileServiceReadyActivity implements Device |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onGetAlgorithmInfo(AlgorithmInfo algorithmInfo) { |
|
|
|
if (algorithmInfo == null) |
|
|
|
if (algorithmInfo == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
String algorithmStr = (getString(R.string.adc, String.valueOf(algorithmInfo.getAdc())) + (getString(R.string.algorithm_id, algorithmInfo.getAlgorithmId()))); |
|
|
|
showInfo(algorithmStr, true); |
|
|
|
if (user != null) { |