Пример #1
0
 @Override
 public void onScanResult(HRDeviceRef device) {
   log(
       hrProvider.getProviderName()
           + "::onScanResult("
           + device.getAddress()
           + ", "
           + device.getName()
           + ")");
   deviceAdapter.deviceList.add(device);
   deviceAdapter.notifyDataSetChanged();
 }
Пример #2
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View row;
      if (convertView == null) {
        row = inflater.inflate(android.R.layout.simple_list_item_single_choice, null);
      } else {
        row = convertView;
      }
      TextView tv = (TextView) row.findViewById(android.R.id.text1);
      tv.setTextColor(resources.getColor(R.color.black));

      HRDeviceRef btDevice = deviceList.get(position);
      tv.setTag(btDevice);
      tv.setText(btDevice.getName());

      return tv;
    }
Пример #3
0
  void connect() {
    stopTimer();
    if (hrProvider == null || btName == null || btAddress == null) {
      updateView();
      return;
    }
    if (hrProvider.isConnecting() || hrProvider.isConnected()) {
      log(hrProvider.getProviderName() + ".disconnect()");
      hrProvider.disconnect();
      updateView();
      return;
    }

    tvBTName.setText(getName());
    tvHR.setText("?");
    String name = btName;
    if (name == null || name.length() == 0) {
      name = btAddress;
    }
    log(hrProvider.getProviderName() + ".connect(" + name + ")");
    hrProvider.connect(HRDeviceRef.create(btProviderName, btName, btAddress));
    updateView();
  }