Пример #1
0
        public void onPeersAvailable(WifiP2pDeviceList peers_list) {
          if (!keepUpdatingPeers) {
            logger.d("Ignoring peers update");
            Collection<WifiP2pDevice> devs = peers_list.getDeviceList();
            for (int i = 0; i < peers.size(); i++) {
              if (devs.contains(peers.get(i))) {
                for (WifiP2pDevice d : devs) {
                  // Update peers in the list
                  if (d.deviceAddress == peers.get(i).deviceAddress) {
                    peers.set(i, d);
                  }
                }
              }
            }
          } else {
            peers = new SynchronizedDevicesList();
            // Adds all found devices
            for (WifiP2pDevice device : peers_list.getDeviceList()) {
              peers.add(device);
            }
          }

          Message msg = new Message();
          msg.obj = peers;
          msg.what = GuiHandlerInterface.UPDATE_PEERS;
          guiHandler.sendMessage(msg);

          logger.d("Peers Added to the List");
        }
Пример #2
0
  @Override
  public void onPeersAvailable(WifiP2pDeviceList peers) {
    // When peers change status, update UI
    mPeerListAdapter.clear();

    if (peers.getDeviceList().isEmpty()) {
      Toast.makeText(FindPeerActivity.this, "Could not find any nearby peers.", Toast.LENGTH_SHORT)
          .show();
    } else {
      mPeerListAdapter.addAll(peers.getDeviceList());
    }
  }
 @Override
 public void onPeersAvailable(WifiP2pDeviceList peerList) {
   if (progressDialog != null && progressDialog.isShowing()) {
     progressDialog.dismiss();
   }
   peers.clear();
   peers.addAll(peerList.getDeviceList());
   ((WiFiPeerListAdapter) getListAdapter()).notifyDataSetChanged();
   if (peers.size() == 0) {
     Log.d(WiFiDirectActivity.TAG, "No devices found");
     return;
   }
 }