Some changes...

This commit is contained in:
Andy Rozman 2019-01-04 22:08:22 +01:00
parent 56eaacb3a2
commit 8935abf8a5
3 changed files with 78 additions and 79 deletions

View file

@ -128,7 +128,7 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
}
});
startScanBLE();
prepareForScanning();
}
@ -150,16 +150,19 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.rileylink_miScan:
case R.id.rileylink_miScan: {
// FIXME
scanLeDevice(true);
return true;
}
default:
return super.onOptionsItemSelected(item);
}
}
public void startScanBLE() {
public void prepareForScanning() {
// https://developer.android.com/training/permissions/requesting.html
// http://developer.radiusnetworks.com/2015/09/29/is-your-beacon-app-ready-for-android-6.html
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
@ -194,10 +197,11 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
filters = Arrays.asList(new ScanFilter.Builder().setServiceUuid(
ParcelUuid.fromString(GattAttributes.SERVICE_RADIO)).build());
scanLeDevice(true);
// scanLeDevice(true);
}
}
// disable currently selected RL, so that we can discover it
RileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkDisconnect);
}
@ -224,13 +228,9 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
Log.d(TAG, scanRecord.toString());
runOnUiThread(new Runnable() {
@Override
public void run() {
runOnUiThread(() -> {
if (addDevice(scanRecord))
mLeDeviceListAdapter.notifyDataSetChanged();
}
});
}
@ -238,10 +238,7 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
@Override
public void onBatchScanResults(final List<ScanResult> results) {
runOnUiThread(new Runnable() {
@Override
public void run() {
runOnUiThread(() -> {
boolean added = false;
@ -253,7 +250,6 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
if (added)
mLeDeviceListAdapter.notifyDataSetChanged();
}
});
}
@ -293,7 +289,6 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
private String getDeviceDebug(BluetoothDevice device) {
return "BluetoothDevice [name=" + device.getName() + ", address=" + device.getAddress() + //
", type=" + device.getType(); // + ", alias=" + device.getAlias();
}

View file

@ -252,15 +252,19 @@ public class MedtronicFragment extends SubscriberFragment {
pumpStatus.rileyLinkError = (RileyLinkError)checkStatusSet(pumpStatus.rileyLinkError, RileyLinkUtil.getError());
if (errorsView != null) {
if (pumpStatus.rileyLinkError != null) {
int resourceId = pumpStatus.rileyLinkError.getResourceId(getTargetDevice());
errorsView.setText(getTranslation(resourceId));
} else
errorsView.setText("-");
}
pumpStatus.pumpDeviceState = (PumpDeviceState)checkStatusSet(pumpStatus.pumpDeviceState,
MedtronicUtil.getPumpDeviceState());
if (pumpStatusIconView != null) {
if (pumpStatus.pumpDeviceState != null) {
// TODO Pump State
@ -292,8 +296,8 @@ public class MedtronicFragment extends SubscriberFragment {
if (cmd == MedtronicCommandType.GetHistoryData) {
if (MedtronicUtil.frameNumber == null) {
pumpStatusIconView.setText(MainApp.gs(R.string.medtronic_cmd_desc_get_history_request,
MedtronicUtil.pageNumber));
pumpStatusIconView.setText(MainApp.gs(
R.string.medtronic_cmd_desc_get_history_request, MedtronicUtil.pageNumber));
} else {
pumpStatusIconView.setText(MainApp.gs(resourceId, MedtronicUtil.pageNumber,
MedtronicUtil.frameNumber));
@ -327,6 +331,7 @@ public class MedtronicFragment extends SubscriberFragment {
} else {
pumpStatusIconView.setText("{fa-bed} ");
}
}
if (queueView != null) {
Spanned status = ConfigBuilderPlugin.getPlugin().getCommandQueue().spannedStatus();

View file

@ -5,7 +5,6 @@
<item
android:id="@+id/rileylink_miScan"
android:icon="@drawable/refresh"
app:showAsAction="ifRoom"
android:title="Scan"></item>
</menu>