| | |
| | | |
| | | private QMUIEmptyView mEmptyView; |
| | | private ListView homeList; |
| | | private android.widget.ProgressBar pbScanning; |
| | | private BluetoothScanManager scanManager; |
| | | private BluetoothLeDeviceStore mDeviceStore; |
| | | private BluetoothUtils mBluetoothUtils; |
| | |
| | | View view = inflater.inflate(R.layout.fragment_device_list, container, false); |
| | | mEmptyView = view.findViewById(R.id.emptyView); |
| | | homeList = view.findViewById(R.id.homeList); |
| | | pbScanning = view.findViewById(R.id.pb_scanning); |
| | | return view; |
| | | } |
| | | |
| | |
| | | scanManager.setScanOverListener(new ScanOverListener() { |
| | | @Override |
| | | public void onScanOver() { |
| | | if (pbScanning != null) pbScanning.setVisibility(View.GONE); |
| | | } |
| | | }); |
| | | |
| | |
| | | @Override |
| | | public void onScanFailed(final int errorCode) { |
| | | super.onScanFailed(errorCode); |
| | | if (pbScanning != null) pbScanning.setVisibility(View.GONE); |
| | | Toast.makeText(getContext(), "扫描失败:" + errorCode, Toast.LENGTH_SHORT).show(); |
| | | } |
| | | |
| | |
| | | mDeviceStore.clear(); |
| | | EventBus.getDefault().post(new UpdateEvent(UpdateEvent.Type.SCAN_UPDATE)); |
| | | ((BaseActivity) getActivity()).Toast("开始扫描..."); |
| | | if (pbScanning != null) pbScanning.setVisibility(View.VISIBLE); |
| | | scanManager.startScanNow(); |
| | | } |
| | | } |
| | |
| | | if (scanManager != null) { |
| | | scanManager.setScanCallbackCompat(null); |
| | | scanManager.setScanOverListener(null); |
| | | // 释放资源 |
| | | scanManager.release(); |
| | | } |
| | | } |
| | | } |