本文整理汇总了Java中org.fdroid.fdroid.localrepo.peers.Peer类的典型用法代码示例。如果您正苦于以下问题:Java Peer类的具体用法?Java Peer怎么用?Java Peer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Peer类属于org.fdroid.fdroid.localrepo.peers包,在下文中一共展示了Peer类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectTo
import org.fdroid.fdroid.localrepo.peers.Peer; //导入依赖的package包/类
public void connectTo(@NonNull Peer peer, boolean requestSwapBack) {
if (peer != this.peer) {
Log.e(TAG, "Oops, got a different peer to swap with than initially planned.");
}
peerRepo = ensureRepoExists(peer);
// Only ask server to swap with us, if we are actually running a local repo service.
// It is possible to have a swap initiated without first starting a swap, in which
// case swapping back is pointless.
if (isEnabled() && requestSwapBack) {
askServerToSwapWithUs(peerRepo);
}
UpdateService.updateRepoNow(peer.getRepoAddress(), this);
}
示例2: ensureRepoExists
import org.fdroid.fdroid.localrepo.peers.Peer; //导入依赖的package包/类
private Repo ensureRepoExists(@NonNull Peer peer) {
// TODO: newRepoConfig.getParsedUri() will include a fingerprint, which may not match with
// the repos address in the database. Not sure on best behaviour in this situation.
Repo repo = RepoProvider.Helper.findByAddress(this, peer.getRepoAddress());
if (repo == null) {
ContentValues values = new ContentValues(6);
// The name/description is not really required, as swap repos are not shown in the
// "Manage repos" UI on other device. Doesn't hurt to put something there though,
// on the off chance that somebody is looking through the sqlite database which
// contains the repos...
values.put(Schema.RepoTable.Cols.NAME, peer.getName());
values.put(Schema.RepoTable.Cols.ADDRESS, peer.getRepoAddress());
values.put(Schema.RepoTable.Cols.DESCRIPTION, "");
String fingerprint = peer.getFingerprint();
if (!TextUtils.isEmpty(fingerprint)) {
values.put(Schema.RepoTable.Cols.FINGERPRINT, peer.getFingerprint());
}
values.put(Schema.RepoTable.Cols.IN_USE, 1);
values.put(Schema.RepoTable.Cols.IS_SWAP, true);
Uri uri = RepoProvider.Helper.insert(this, values);
repo = RepoProvider.Helper.get(this, uri);
}
return repo;
}
示例3: uiInitPeers
import org.fdroid.fdroid.localrepo.peers.Peer; //导入依赖的package包/类
/**
* 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.
*/
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);
peopleNearbyList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Peer peer = peopleNearbyAdapter.getItem(position);
onPeerSelected(peer);
}
});
}
示例4: ensureRepoExists
import org.fdroid.fdroid.localrepo.peers.Peer; //导入依赖的package包/类
private Repo ensureRepoExists(@NonNull Peer peer) {
// TODO: newRepoConfig.getParsedUri() will include a fingerprint, which may not match with
// the repos address in the database. Not sure on best behaviour in this situation.
Repo repo = RepoProvider.Helper.findByAddress(this, peer.getRepoAddress());
if (repo == null) {
ContentValues values = new ContentValues(6);
// The name/description is not really required, as swap repos are not shown in the
// "Manage repos" UI on other device. Doesn't hurt to put something there though,
// on the off chance that somebody is looking through the sqlite database which
// contains the repos...
values.put(RepoProvider.DataColumns.NAME, peer.getName());
values.put(RepoProvider.DataColumns.ADDRESS, peer.getRepoAddress());
values.put(RepoProvider.DataColumns.DESCRIPTION, "");
String fingerprint = peer.getFingerprint();
if (!TextUtils.isEmpty(fingerprint)) {
values.put(RepoProvider.DataColumns.FINGERPRINT, peer.getFingerprint());
}
values.put(RepoProvider.DataColumns.IN_USE, true);
values.put(RepoProvider.DataColumns.IS_SWAP, true);
Uri uri = RepoProvider.Helper.insert(this, values);
repo = RepoProvider.Helper.findByUri(this, uri);
}
return repo;
}
示例5: connectTo
import org.fdroid.fdroid.localrepo.peers.Peer; //导入依赖的package包/类
public void connectTo(@NonNull Peer peer, boolean requestSwapBack) {
if (peer != this.peer) {
Log.e(TAG, "Oops, got a different peer to swap with than initially planned.");
}
peerRepo = ensureRepoExists(peer);
// Only ask server to swap with us, if we are actually running a local repo service.
// It is possible to have a swap initiated without first starting a swap, in which
// case swapping back is pointless.
if (isEnabled() && requestSwapBack) {
askServerToSwapWithUs(peerRepo);
}
UpdateService.updateRepoNow(this, peer.getRepoAddress());
}
示例6: swapWith
import org.fdroid.fdroid.localrepo.peers.Peer; //导入依赖的package包/类
/**
* 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 (getService().getStep() == SwapService.STEP_INTRO || getService().getStep() == SwapService.STEP_CONFIRM_SWAP) {
// This will force the "Select apps to swap" workflow to begin.
// TODO: Find a better way to decide whether we need to select the apps. Not sure if we
// can or cannot be in STEP_INTRO with a full blown repo ready to swap.
swapWith(peer);
} else {
getService().swapWith(repoConfig.toPeer());
startSwappingWithPeer();
}
}
示例7: getView
import org.fdroid.fdroid.localrepo.peers.Peer; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getContext())
.inflate(R.layout.swap_peer_list_item, parent, false);
}
Peer peer = getItem(position);
((TextView) convertView.findViewById(R.id.peer_name)).setText(peer.getName());
((ImageView) convertView.findViewById(R.id.icon))
.setImageDrawable(getResources().getDrawable(peer.getIcon()));
return convertView;
}
示例8: getView
import org.fdroid.fdroid.localrepo.peers.Peer; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.swap_peer_list_item, parent, false);
}
Peer peer = getItem(position);
((TextView) convertView.findViewById(R.id.peer_name)).setText(peer.getName());
((ImageView) convertView.findViewById(R.id.icon)).setImageDrawable(getResources().getDrawable(peer.getIcon()));
return convertView;
}
示例9: PeopleNearbyAdapter
import org.fdroid.fdroid.localrepo.peers.Peer; //导入依赖的package包/类
PeopleNearbyAdapter(Context context) {
super(context, 0, new ArrayList<Peer>());
}
示例10: onNext
import org.fdroid.fdroid.localrepo.peers.Peer; //导入依赖的package包/类
@Override
public void onNext(Peer peer) {
Utils.debugLog(TAG, "Found peer: " + peer + ", adding to list of peers in UI.");
peopleNearbyAdapter.add(peer);
}
示例11: onPeerSelected
import org.fdroid.fdroid.localrepo.peers.Peer; //导入依赖的package包/类
private void onPeerSelected(Peer peer) {
getActivity().swapWith(peer);
}
示例12: swapWith
import org.fdroid.fdroid.localrepo.peers.Peer; //导入依赖的package包/类
public void swapWith(Peer peer) {
this.peer = peer;
}
示例13: getPeer
import org.fdroid.fdroid.localrepo.peers.Peer; //导入依赖的package包/类
@Nullable
public Peer getPeer() {
return peer;
}
示例14: scanForPeers
import org.fdroid.fdroid.localrepo.peers.Peer; //导入依赖的package包/类
/**
* Call {@link Observable#subscribe()} on this in order to be notified of peers
* which are found. Call {@link Subscription#unsubscribe()} on the resulting
* subscription when finished and you no longer want to scan for peers.
*
* The returned object will scan for peers on a background thread, and emit
* found peers on the mian thread.
*
* Invoking this in multiple places will return the same, cached, peer finder.
* That is, if in the past it already found some peers, then you subscribe
* to it in the future, the future subscriber will still receive the peers
* that were found previously.
* TODO: What about removing peers that no longer are present?
*/
public Observable<Peer> scanForPeers() {
Utils.debugLog(TAG, "Scanning for nearby devices to swap with...");
if (peerFinder == null) {
peerFinder = PeerFinder.createObservable(getApplicationContext())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.distinct();
}
return peerFinder;
}