RS: catch BT not on while scanning
This commit is contained in:
parent
351d4ea4df
commit
a04b674a48
1 changed files with 13 additions and 7 deletions
|
@ -15,9 +15,9 @@ import android.widget.BaseAdapter
|
|||
import android.widget.TextView
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||
import info.nightscout.androidaps.danars.R
|
||||
import info.nightscout.androidaps.danars.events.EventDanaRSDeviceChange
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.pump.common.ble.BlePreCheck
|
||||
import info.nightscout.androidaps.danars.events.EventDanaRSDeviceChange
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import kotlinx.android.synthetic.main.danars_blescanner_activity.*
|
||||
import java.util.*
|
||||
|
@ -63,13 +63,17 @@ class BLEScanActivity : NoSplashAppCompatActivity() {
|
|||
stopScan()
|
||||
}
|
||||
|
||||
private fun startScan() {
|
||||
if (bluetoothLeScanner != null) bluetoothLeScanner!!.startScan(mBleScanCallback)
|
||||
}
|
||||
private fun startScan() =
|
||||
try {
|
||||
bluetoothLeScanner?.startScan(mBleScanCallback)
|
||||
} catch (e: IllegalStateException) {
|
||||
} // ignore BT not on
|
||||
|
||||
private fun stopScan() {
|
||||
if (bluetoothLeScanner != null) bluetoothLeScanner!!.stopScan(mBleScanCallback)
|
||||
}
|
||||
private fun stopScan() =
|
||||
try {
|
||||
bluetoothLeScanner?.stopScan(mBleScanCallback)
|
||||
} catch (e: IllegalStateException) {
|
||||
} // ignore BT not on
|
||||
|
||||
private fun addBleDevice(device: BluetoothDevice?) {
|
||||
if (device == null || device.name == null || device.name == "") {
|
||||
|
@ -90,6 +94,7 @@ class BLEScanActivity : NoSplashAppCompatActivity() {
|
|||
}
|
||||
|
||||
internal inner class ListAdapter : BaseAdapter() {
|
||||
|
||||
override fun getCount(): Int = devices.size
|
||||
override fun getItem(i: Int): BluetoothDeviceItem = devices[i]
|
||||
override fun getItemId(i: Int): Long = 0
|
||||
|
@ -111,6 +116,7 @@ class BLEScanActivity : NoSplashAppCompatActivity() {
|
|||
}
|
||||
|
||||
private inner class ViewHolder internal constructor(v: View) : View.OnClickListener {
|
||||
|
||||
private lateinit var item: BluetoothDeviceItem
|
||||
private val name: TextView = v.findViewById(R.id.ble_name)
|
||||
private val address: TextView = v.findViewById(R.id.ble_address)
|
||||
|
|
Loading…
Reference in a new issue