mirror of
https://gitee.com/openharmony/applications_settings
synced 2024-11-27 08:30:34 +00:00
蓝牙模块优化
Signed-off-by: yansong <yansong14@huawei.com>
This commit is contained in:
parent
04e2fddec0
commit
fb22877aa3
@ -101,7 +101,9 @@ export default class BluetoothDeviceController extends BaseSettingsController {
|
||||
BluetoothModel.enableBluetooth();
|
||||
} else {
|
||||
BluetoothModel.disableBluetooth();
|
||||
this.availableDevices = []
|
||||
|
||||
// remove all elements from availableDevices array
|
||||
this.availableDevices.splice(0, this.availableDevices.length)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -649,7 +649,7 @@ struct AvailableDeviceComponent {
|
||||
* AvailableDevicesDataSource For Lazy Loading
|
||||
*/
|
||||
class AvailableDevicesDataSource extends BasicDataSource {
|
||||
private availableDevicesArray: BluetoothDevice[] = [];
|
||||
private availableDevicesArray: BluetoothDevice[] = null;
|
||||
|
||||
constructor(availableDevicesArray:BluetoothDevice[]){
|
||||
super();
|
||||
@ -657,10 +657,17 @@ class AvailableDevicesDataSource extends BasicDataSource {
|
||||
}
|
||||
|
||||
public totalCount(): number {
|
||||
return this.availableDevicesArray.length;
|
||||
if(this.availableDevicesArray) {
|
||||
return this.availableDevicesArray.length;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public getData(index: number): any {
|
||||
public getData(index: number): BluetoothDevice {
|
||||
if(index < 0 || index >= this.totalCount()) {
|
||||
LogUtil.log(ConfigData.TAG + 'index out of range.');
|
||||
return null;
|
||||
}
|
||||
return this.availableDevicesArray[index];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user