Пример #1
0
  public synchronized void removeDevice(Device d) {
    if (!DLNAUtil.isMediaRenderDevice(d)) {
      return;
    }
    int size = mDevices.size();
    for (int i = 0; i < size; i++) {
      String udnString = mDevices.get(i).getUDN();
      if (d.getUDN().equalsIgnoreCase(udnString)) {
        Device device = mDevices.remove(i);
        LogUtil.d(TAG, "Devices remove a device");

        boolean ret = false;
        if (mSelectedDevice != null) {
          ret = mSelectedDevice.getUDN().equalsIgnoreCase(device.getUDN());
        }
        if (ret) {
          mSelectedDevice = null;
        }
        if (mDeviceChangeListener != null) {
          mDeviceChangeListener.onDeviceChange(d);
        }
        break;
      }
    }
  }
Пример #2
0
  public synchronized void addDevice(Device d) {
    if (!DLNAUtil.isMediaRenderDevice(d)) return;
    int size = mDevices.size();
    for (int i = 0; i < size; i++) {
      String udnString = mDevices.get(i).getUDN();
      if (d.getUDN().equalsIgnoreCase(udnString)) {
        return;
      }
    }

    mDevices.add(d);
    LogUtil.d(TAG, "Devices add a device" + d.getDeviceType());
    if (mDeviceChangeListener != null) {
      mDeviceChangeListener.onDeviceChange(d);
    }
  }