use of org.fdroid.fdroid.nearby.peers.Peer in project fdroidclient by f-droid.
the class SwapWorkflowActivity method swapWith.
/**
* This is for when we initiate a swap by viewing the "Are you sure you want to swap with" view
* This can arise either:
* * As a result of scanning a QR code (in which case we likely already have a repo setup) or
* * As a result of the other device selecting our device in the "start swap" screen, in which
* case we are likely just sitting on the start swap screen also, and haven't configured
* anything yet.
*/
public void swapWith(NewRepoConfig repoConfig) {
Peer peer = repoConfig.toPeer();
if (currentSwapViewLayoutRes == R.layout.swap_start_swap || currentSwapViewLayoutRes == R.layout.swap_confirm_receive) {
// This will force the "Select apps to swap" workflow to begin.
swapWith(peer);
} else {
getSwapService().swapWith(peer);
startSwappingWithPeer();
}
}
use of org.fdroid.fdroid.nearby.peers.Peer in project fdroidclient by f-droid.
the class StartSwapView method uiInitPeers.
/**
* Setup the list of nearby peers with an adapter, and hide or show it and the associated
* message for when no peers are nearby depending on what is happening.
*
* @see SwapWorkflowActivity#bonjourFound
* @see SwapWorkflowActivity#bluetoothFound
*/
private void uiInitPeers() {
peopleNearbyText = (TextView) findViewById(R.id.text_people_nearby);
peopleNearbyList = (ListView) findViewById(R.id.list_people_nearby);
peopleNearbyProgress = (ProgressBar) findViewById(R.id.searching_people_nearby);
peopleNearbyAdapter = new PeopleNearbyAdapter(getContext());
peopleNearbyList.setAdapter(peopleNearbyAdapter);
for (Peer peer : getActivity().getSwapService().getActivePeers()) {
if (peopleNearbyAdapter.getPosition(peer) == -1) {
peopleNearbyAdapter.add(peer);
}
}
peopleNearbyList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Peer peer = peopleNearbyAdapter.getItem(position);
onPeerSelected(peer);
}
});
}
Aggregations