@Override protected void onAfterViews() { super.onAfterViews(); AQuery q = new AQuery(getView()); // ハートレートモニター設定 { FitnessDeviceCallbackImpl callback = new FitnessDeviceCallbackImpl(FitnessDeviceType.HEARTRATE_MONITOR, heartrateDevices); heartrateController = FitnessDeviceType.HEARTRATE_MONITOR.createController(getActivity()); heartrateController.setBleScanCallback(callback); heartrateAdapter = new BasicSpinnerAdapter(getActivity()); q.id(R.id.Setting_RoadBikeProfile_HeartrateMonitor_Selector) .adapter(heartrateAdapter) .itemSelected(callback); } // ケイデンスセンサー設定 { FitnessDeviceCallbackImpl callback = new FitnessDeviceCallbackImpl(FitnessDeviceType.SPEED_CADENCE_SENSOR, cadenceDevices); cadenceSpeedController = FitnessDeviceType.SPEED_CADENCE_SENSOR.createController(getActivity()); cadenceSpeedController.setBleScanCallback(callback); cadenceAdapter = new BasicSpinnerAdapter(getActivity()); q.id(R.id.Setting_RoadBikeProfile_SpeedAndCadence_Selector) .adapter(cadenceAdapter) .itemSelected(callback); } }
@Override public void onPause() { super.onPause(); // スキャンを終了させる heartrateController.disconnect(); cadenceSpeedController.disconnect(); }
@OnClick(R.id.Setting_RoadBikeProfile_BleDevice_ScanRequest) void clickScanRequest() { if (requestRuntimePermission(PermissionUtil.PermissionType.BluetoothLE)) { return; } scanBleDevice = true; heartrateController.connect(); cadenceSpeedController.connect(); AQuery q = new AQuery(getView()); q.id(R.id.Setting_RoadBikeProfile_BleDevice_ScanRequest).gone(); q.id(R.id.Setting_RoadBikeProfile_BleDevice_ScanNowRoot).visible(); }
@Override public void onResume() { super.onResume(); // 必要であればスキャンを復旧させる if (scanBleDevice) { heartrateController.connect(); cadenceSpeedController.connect(); } // デバイスを読み込む loadDeviceCache(FitnessDeviceType.HEARTRATE_MONITOR); loadDeviceCache(FitnessDeviceType.SPEED_CADENCE_SENSOR); }