@Override public void dataReceived(long uniqueID) { NeighbourAdapter.AdapterItem item = neighbourAdapter.getItemByID(uniqueID); if (item == null) return; Toast.makeText( getActivity(), getString(R.string.neighbour_data_received, item.getName()), Toast.LENGTH_SHORT) .show(); }
public void askForPairing(final NeighbourAdapter.AdapterItem item) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle(R.string.neighbour_pairing_title); alert.setMessage(getString(R.string.neighbour_pairing_message, item.getName())); alert.setPositiveButton( android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { NeighbourDiscoverSending.sendPairAckMessage(udpSending, true, item.address); neighbourAdapter.setPaired(item, true); } }); alert.setNegativeButton( android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { NeighbourDiscoverSending.sendPairAckMessage(udpSending, false, item.address); } }); alert.show(); }
private void sendPairingRequest(NeighbourAdapter.AdapterItem item) { item.pairingRequest = true; NeighbourDiscoverSending.sendPairRequestMessage(udpSending, item.address); //noinspection ConstantConditions Toast.makeText(getActivity(), R.string.neighbour_pairing_request, Toast.LENGTH_SHORT).show(); }