當前位置: 首頁>>代碼示例>>Java>>正文


Java Peer類代碼示例

本文整理匯總了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);
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:17,代碼來源:SwapService.java

示例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;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:27,代碼來源:SwapService.java

示例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);
        }
    });
}
 
開發者ID:CmDnoEdition,項目名稱:fdroid,代碼行數:22,代碼來源:StartSwapView.java

示例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;
}
 
開發者ID:CmDnoEdition,項目名稱:fdroid,代碼行數:27,代碼來源:SwapService.java

示例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());
}
 
開發者ID:f-droid,項目名稱:fdroidclient,代碼行數:17,代碼來源:SwapService.java

示例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();
    }
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:21,代碼來源:SwapWorkflowActivity.java

示例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;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:15,代碼來源:StartSwapView.java

示例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;
}
 
開發者ID:CmDnoEdition,項目名稱:fdroid,代碼行數:13,代碼來源:StartSwapView.java

示例9: PeopleNearbyAdapter

import org.fdroid.fdroid.localrepo.peers.Peer; //導入依賴的package包/類
PeopleNearbyAdapter(Context context) {
    super(context, 0, new ArrayList<Peer>());
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:4,代碼來源:StartSwapView.java

示例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);
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:6,代碼來源:StartSwapView.java

示例11: onPeerSelected

import org.fdroid.fdroid.localrepo.peers.Peer; //導入依賴的package包/類
private void onPeerSelected(Peer peer) {
    getActivity().swapWith(peer);
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:4,代碼來源:StartSwapView.java

示例12: swapWith

import org.fdroid.fdroid.localrepo.peers.Peer; //導入依賴的package包/類
public void swapWith(Peer peer) {
    this.peer = peer;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:4,代碼來源:SwapService.java

示例13: getPeer

import org.fdroid.fdroid.localrepo.peers.Peer; //導入依賴的package包/類
@Nullable
public Peer getPeer() {
    return peer;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:5,代碼來源:SwapService.java

示例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;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:25,代碼來源:SwapService.java


注:本文中的org.fdroid.fdroid.localrepo.peers.Peer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。