コード例 #1
0
 /**
  * Looks for the device with the same address as given one in the list of bonded devices. If the
  * device has been found it updates its RSSI value.
  *
  * @param address the device address
  * @param rssi the RSSI of the scanned device
  */
 public void updateRssiOfBondedDevice(String address, int rssi) {
   comparator.address = address;
   final int indexInBonded = mListBondedValues.indexOf(comparator);
   if (indexInBonded >= 0) {
     ExtendedBluetoothDevice previousDevice = mListBondedValues.get(indexInBonded);
     previousDevice.rssi = rssi;
     notifyDataSetChanged();
   }
 }
コード例 #2
0
ファイル: DeviceListAdapter.java プロジェクト: Hanqing/X-BAG
 /**
  * If such device exists on the bonded device list, this method does nothing. If not then the
  * device is updated (rssi value) or added.
  *
  * @param results scan results
  */
 public void update(final List<ScanResult> results) {
   for (final ScanResult result : results) {
     final ExtendedBluetoothDevice device = findDevice(result);
     if (device == null) {
       mDevices.add(new ExtendedBluetoothDevice(result));
     } else {
       device.name =
           result.getScanRecord() != null ? result.getScanRecord().getDeviceName() : null;
       device.rssi = result.getRssi();
     }
   }
   notifyDataSetChanged();
 }
コード例 #3
0
  /**
   * If such device exists on the bonded device list, this method does nothing. If not then the
   * device is updated (rssi value) or added.
   *
   * @param device the device to be added or updated
   */
  public void addOrUpdateDevice(ExtendedBluetoothDevice device) {
    final boolean indexInBonded = mListBondedValues.contains(device);
    if (indexInBonded) {
      return;
    }

    final int indexInNotBonded = mListValues.indexOf(device);
    if (indexInNotBonded >= 0) {
      ExtendedBluetoothDevice previousDevice = mListValues.get(indexInNotBonded);
      previousDevice.rssi = device.rssi;
      notifyDataSetChanged();
      return;
    }
    mListValues.add(device);
    notifyDataSetChanged();
  }
コード例 #4
0
ファイル: DeviceListAdapter.java プロジェクト: Hanqing/X-BAG
 private ExtendedBluetoothDevice findDevice(final ScanResult result) {
   for (final ExtendedBluetoothDevice device : mDevices) if (device.matches(result)) return device;
   return null;
 }