Java 类com.google.android.gms.common.api.ResultCallbacks 实例源码

项目:castscreen    文件:ConnectionManager.java   
/**
 * connect to the remote display, and show the {@link CastScreenPresentation} if successful
 */
private void connectToRemoteDisplayApi() {
    PendingResult<CastRemoteDisplay.CastRemoteDisplaySessionResult> result =
            CastRemoteDisplay.CastRemoteDisplayApi.startRemoteDisplay(mApiClient, mAppId);
    result.setResultCallback(new ResultCallbacks<CastRemoteDisplay.CastRemoteDisplaySessionResult>() {
        @Override
        public void onSuccess(@NonNull CastRemoteDisplay.CastRemoteDisplaySessionResult castRemoteDisplaySessionResult) {
            Display remoteDisplay = castRemoteDisplaySessionResult.getPresentationDisplay();
            mPresentation = new CastScreenPresentation(mService, remoteDisplay, mProjectionManager);
            mPresentation.show();
            mPresentationShowing = true;
            Log.d(TAG, "Created presentation");
        }

        @Override
        public void onFailure(@NonNull Status status) {
            Log.i(TAG, "Stop Casting because startRemoteDisplay failed");
            deselectRoute();
        }
    });
}
项目:castscreen    文件:ConnectionManager.java   
/**
 * disconnect and cleanup all resources
 */
public void disconnect() {
    if (apiClientConnected()) {
        // Disconnect from remote display
        PendingResult<CastRemoteDisplay.CastRemoteDisplaySessionResult> result =
                CastRemoteDisplay.CastRemoteDisplayApi.stopRemoteDisplay(mApiClient);
        result.setResultCallback(new ResultCallbacks<CastRemoteDisplay.CastRemoteDisplaySessionResult>() {
            @Override
            public void onSuccess(@NonNull CastRemoteDisplay.CastRemoteDisplaySessionResult castRemoteDisplaySessionResult) {
                Log.i(TAG, "Success disconnecting from CastRemoteDisplayApi");
            }

            @Override
            public void onFailure(@NonNull Status status) {
                Log.w(TAG, "Failed disconnecting from CastRemoteDisplayApi");
            }
        });

        // Disconnect from Google API
        mApiClient.disconnect();
    }

    // Stop listening for routes
    mRouter.removeCallback(mStopCallback);

    // Clean up MediaProjection resources
    if (mPresentation != null) mPresentation.dismiss();
    if (mProjectionManager != null) mProjectionManager.release();
}
项目:android-testdpc    文件:SafetyNetFragment.java   
private void runSaftyNetTest() {
    final byte[] nonce = generateNonce();
    SafetyNet.SafetyNetApi.attest(mGoogleApiClient, nonce)
            .setResultCallback(new ResultCallbacks<AttestationResult>() {
                @Override
                public void onSuccess(@NonNull AttestationResult attestationResult) {
                    if (isDetached()) {
                        return;
                    }
                    final String jws = attestationResult.getJwsResult();
                    try {
                        final JSONObject jsonObject = retrievePayloadFromJws(jws);
                        final String jsonString = jsonObject.toString(4);
                        final String verifyOnServerString
                                = getString(R.string.safetynet_verify_on_server);
                        updateMessageView(verifyOnServerString + "\n" + jsonString, false);
                    } catch (JSONException ex) {
                        updateMessageView(R.string.safetynet_fail_reason_invalid_jws, true);
                    }
                }

                @Override
                public void onFailure(@NonNull Status status) {
                    if (isDetached()) {
                        return;
                    }
                    updateMessageView(R.string.safetynet_fail_to_run_api, true);
                }
            });
}
项目:react-native-region-monitor    文件:GeofenceManager.java   
public void addGeofences(@NonNull List<Geofence> geofences, @NonNull ResultCallbacks<Status> callback) throws InterruptedException
{
    countDownLatch.await();
    GeofencingRequest request = new GeofencingRequest.Builder().addGeofences(geofences).setInitialTrigger(Geofence.GEOFENCE_TRANSITION_ENTER).build();
    LocationServices.GeofencingApi.addGeofences(googleApiClient, request, geofencePendingIntent).setResultCallback(callback);
}
项目:react-native-region-monitor    文件:GeofenceManager.java   
public void clearGeofences(@NonNull ResultCallbacks<Status> callback) throws InterruptedException
{
    countDownLatch.await();
    LocationServices.GeofencingApi.removeGeofences(googleApiClient, geofencePendingIntent).setResultCallback(callback);
}
项目:react-native-region-monitor    文件:GeofenceManager.java   
public void removeGeofence(@NonNull String id, @NonNull ResultCallbacks<Status> callback) throws InterruptedException
{
    countDownLatch.await();
    LocationServices.GeofencingApi.removeGeofences(googleApiClient, Collections.singletonList(id)).setResultCallback(callback);
}