• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TaskCompletionSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.android.gms.tasks.TaskCompletionSource的典型用法代码示例。如果您正苦于以下问题:Java TaskCompletionSource类的具体用法?Java TaskCompletionSource怎么用?Java TaskCompletionSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TaskCompletionSource类属于com.google.android.gms.tasks包,在下文中一共展示了TaskCompletionSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: deleteRegistrationToken

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
/**
 * Deletes the current registration token.
 *
 * @param instanceId The instance ID which generated the registration token.
 * @param senderId   The sender ID to revoke the registration token from.
 * @return A task that can be resolved upon deletion of the token.
 */
private Task<Void> deleteRegistrationToken(final InstanceID instanceId, final String senderId) {
    final TaskCompletionSource<Void> future = new TaskCompletionSource<>();
    new AsyncTask<Object, Integer, String>() {
        @Override
        protected String doInBackground(final Object[] ignored) {

            try {
                instanceId.deleteToken(senderId, GoogleCloudMessaging.INSTANCE_ID_SCOPE);
            } catch (final IOException e) {
                Log.e(TAG, "Error deleting GCM registration token", e);
                future.setException(e);
                return null;
            }

            future.setResult(null);
            return null;
        }
    }.execute();

    return future.getTask();
}
 
开发者ID:mongodb,项目名称:stitch-android-sdk,代码行数:29,代码来源:GCMPushClient.java


示例2: getRegistrationToken

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
/**
 * Gets or creates a registration token.
 *
 * @param instanceId The instance ID which should generate the registration token.
 * @param senderId   The sender ID to generate the registration token for.
 * @return A task that can be resolved upon creating/retrieval of the token.
 */
private Task<String> getRegistrationToken(final InstanceID instanceId, final String senderId) {
    final TaskCompletionSource<String> future = new TaskCompletionSource<>();
    new AsyncTask<Object, Integer, String>() {
        @Override
        protected String doInBackground(final Object[] ignored) {

            final String registrationToken;
            try {
                registrationToken = instanceId.getToken(senderId, GoogleCloudMessaging.INSTANCE_ID_SCOPE);
            } catch (final IOException e) {
                Log.e(TAG, "Error getting GCM registration token", e);
                future.setException(e);
                return null;
            }

            future.setResult(registrationToken);
            return null;
        }
    }.execute();

    return future.getTask();
}
 
开发者ID:mongodb,项目名称:stitch-android-sdk,代码行数:30,代码来源:GCMPushClient.java


示例3: start

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
public Task<Map<DatabaseReference, DataSnapshot>> start() {
    // Create a Task<DataSnapshot> to trigger in response to each database listener.
    //
    final ArrayList<Task<DataSnapshot>> tasks = new ArrayList<>(refs.size());
    for (final DatabaseReference ref : refs) {
        final TaskCompletionSource<DataSnapshot> source = new TaskCompletionSource<>();
        final ValueEventListener listener = new MyValueEventListener(ref, source);
        ref.addListenerForSingleValueEvent(listener);
        listeners.put(ref, listener);
        tasks.add(source.getTask());
    }

    // Return a single Task that triggers when all queries are complete.  It contains
    // a map of all original DatabaseReferences originally given here to their resulting
    // DataSnapshot.
    //
    return Tasks.whenAll(tasks).continueWith(new Continuation<Void, Map<DatabaseReference, DataSnapshot>>() {
        @Override
        public Map<DatabaseReference, DataSnapshot> then(@NonNull Task<Void> task) throws Exception {
            task.getResult();
            return new HashMap<>(snaps);
        }
    });
}
 
开发者ID:CodingDoug,项目名称:white-label-event-app,代码行数:25,代码来源:FirebaseMultiQuery.java


示例4: subscribeToTopic

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
/**
 * Subscribes the client to a specific topic.
 * /topics/ prefix is not necessary.
 *
 * @param topic The topic to subscribe to
 *
 * @return A task that can resolved upon subscribing.
 */
public Task<Void> subscribeToTopic(final String topic) {
    final GcmPubSub pubSub = GcmPubSub.getInstance(getContext());
    final String topicKey = String.format("/topics/%s", topic);
    final InstanceID instanceId = InstanceID.getInstance(getContext());

    final TaskCompletionSource<Void> future = new TaskCompletionSource<>();

    getRegistrationToken(instanceId, _info.getSenderId()).addOnCompleteListener(new OnCompleteListener<String>() {
        @Override
        public void onComplete(@NonNull final Task<String> task) {
            if (!task.isSuccessful()) {
                future.setException(task.getException());
            }

            new AsyncTask<Object, Integer, String>() {
                @Override
                protected String doInBackground(final Object[] ignored) {

                    try {
                        pubSub.subscribe(task.getResult(), topicKey, null);
                    } catch (final IOException e) {
                        Log.e(TAG, "Error subscribing to " + topicKey, e);
                        future.setException(e);
                        return null;
                    }

                    future.setResult(null);
                    return null;
                }
            }.execute();
        }
    });

    return future.getTask();
}
 
开发者ID:mongodb,项目名称:stitch-android-sdk,代码行数:44,代码来源:GCMPushClient.java


示例5: unsubscribeFromTopic

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
/**
 * Subscribes the client to a specific topic.
 * /topics/ prefix is not necessary.
 *
 * @param topic The topic to unsubscribe from
 *
 * @return A task that can resolved upon subscribing.
 */
public Task<Void> unsubscribeFromTopic(final String topic) {
    final GcmPubSub pubSub = GcmPubSub.getInstance(getContext());
    final String topicKey = String.format("/topics/%s", topic);
    final InstanceID instanceId = InstanceID.getInstance(getContext());

    final TaskCompletionSource<Void> future = new TaskCompletionSource<>();

    getRegistrationToken(instanceId, _info.getSenderId()).addOnCompleteListener(new OnCompleteListener<String>() {
        @Override
        public void onComplete(@NonNull final Task<String> task) {
            if (!task.isSuccessful()) {
                future.setException(task.getException());
            }

            new AsyncTask<Object, Integer, String>() {
                @Override
                protected String doInBackground(final Object[] ignored) {

                    try {
                        pubSub.unsubscribe(task.getResult(), topicKey);
                    } catch (final IOException e) {
                        Log.e(TAG, "Error unsubscribing from " + topicKey, e);
                        future.setException(e);
                        return null;
                    }

                    future.setResult(null);
                    return null;
                }
            }.execute();
        }
    });

    return future.getTask();
}
 
开发者ID:mongodb,项目名称:stitch-android-sdk,代码行数:44,代码来源:GCMPushClient.java


示例6: register

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
/**
 * Registers the current user using email and password.
 *
 * @param email    email for the given user
 * @param password password for the given user
 * @return A task containing whether or not registration was successful.
 */
public Task<Boolean> register(@NonNull String email, @NonNull String password) {
    final EmailPasswordAuthProvider provider = new EmailPasswordAuthProvider(email, password);

    final TaskCompletionSource<Boolean> future = new TaskCompletionSource<>();
    final String url = String.format(
            "%s/%s",
            getResourcePath(routes.AUTH),
            routes.USERPASS_REGISTER
    );

    final JsonStringRequest request = new JsonStringRequest(
            Request.Method.POST,
            url,
            getAuthRequest(provider.getRegistrationPayload()).toJson(),
            new Response.Listener<String>() {
                @Override
                public void onResponse(final String response) {
                    future.setResult(response != null);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(final VolleyError error) {
                    Log.e(TAG, "Error while logging in with auth provider", error);
                    future.setException(parseRequestError(error));
                }
            }
    );

    request.setTag(this);
    _queue.add(request);

    return future.getTask();
}
 
开发者ID:mongodb,项目名称:stitch-android-sdk,代码行数:42,代码来源:StitchClient.java


示例7: emailConfirm

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
/**
 * Confirm a newly registered email in this context
 *
 * @param token   confirmation token emailed to new user
 * @param tokenId confirmation tokenId emailed to new user
 * @return A task containing whether or not the email was confirmed successfully
 */
public Task<Boolean> emailConfirm(@NonNull final String token, @NonNull final String tokenId) {
    final TaskCompletionSource<Boolean> future = new TaskCompletionSource<>();

    final String url = String.format(
            "%s/%s",
            getResourcePath(routes.AUTH),
            routes.USERPASS_CONFIRM
    );

    final Document params = new Document();

    params.put("token", token);
    params.put("tokenId", tokenId);

    final JsonStringRequest request = new JsonStringRequest(
            Request.Method.POST,
            url,
            params.toJson(),
            new Response.Listener<String>() {
                @Override
                public void onResponse(final String response) {
                    future.setResult(response != null);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(final VolleyError error) {
                    Log.e(TAG, "Error while confirming email", error);
                    future.setException(parseRequestError(error));
                }
            }
    );

    request.setTag(this);
    _queue.add(request);

    return future.getTask();
}
 
开发者ID:mongodb,项目名称:stitch-android-sdk,代码行数:46,代码来源:StitchClient.java


示例8: sendEmailConfirm

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
/**
 * Send a confirmation email for a newly registered user
 *
 * @param email email address of user
 * @return A task containing whether or not the email was sent successfully.
 */
public Task<Boolean> sendEmailConfirm(@NonNull final String email) {
    final TaskCompletionSource<Boolean> future = new TaskCompletionSource<>();

    final String url = String.format(
            "%s/%s",
            getResourcePath(routes.AUTH),
            routes.USERPASS_CONFIRM_SEND
    );

    final JsonStringRequest request = new JsonStringRequest(
            Request.Method.POST,
            url,
            new Document("email", email).toJson(),
            new Response.Listener<String>() {
                @Override
                public void onResponse(final String response) {
                    future.setResult(response != null);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(final VolleyError error) {
                    Log.e(TAG, "Error while sending confirmation email", error);
                    future.setException(parseRequestError(error));
                }
            }
    );

    request.setTag(this);
    _queue.add(request);

    return future.getTask();
}
 
开发者ID:mongodb,项目名称:stitch-android-sdk,代码行数:40,代码来源:StitchClient.java


示例9: sendResetPassword

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
/**
 * Send a reset password email to a given email address
 *
 * @param email email address to reset password for
 * @return A task containing whether or not the reset email was sent successfully
 */
public Task<Boolean> sendResetPassword(@NonNull final String email) {
    final TaskCompletionSource<Boolean> future = new TaskCompletionSource<>();

    final String url = String.format(
            "%s/%s",
            getResourcePath(routes.AUTH),
            routes.USERPASS_RESET_SEND
    );

    final JsonStringRequest request = new JsonStringRequest(
            Request.Method.POST,
            url,
            new Document("email", email).toJson(),
            new Response.Listener<String>() {
                @Override
                public void onResponse(final String response) {
                    future.setResult(response != null);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(final VolleyError error) {
                    Log.e(TAG, "Error while sending reset password email", error);
                    future.setException(parseRequestError(error));
                }
            }
    );

    request.setTag(this);
    _queue.add(request);

    return future.getTask();
}
 
开发者ID:mongodb,项目名称:stitch-android-sdk,代码行数:40,代码来源:StitchClient.java


示例10: getLineAccessCode

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
private Task<String> getLineAccessCode(final Activity activity) {
    final TaskCompletionSource<String> source = new TaskCompletionSource<>();

    // STEP 1: User logins with LINE and get their LINE access token
    LineSdkContext sdkContext = LineSdkContextManager.getSdkContext();
    LineAuthManager authManager = sdkContext.getAuthManager();
    LineLoginFuture loginFuture = authManager.login(activity);
    loginFuture.addFutureListener(new LineLoginFutureListener() {
        @Override
        public void loginComplete(LineLoginFuture future) {
            switch(future.getProgress()) {
                case SUCCESS: //Login successfully
                    String lineAccessToken = future.getAccessToken().accessToken;
                    Log.d(TAG, "LINE Access token = " + lineAccessToken);
                    source.setResult(lineAccessToken);
                    break;
                case CANCELED: // Login canceled by user
                    Exception e = new Exception("User cancelled LINE Login.");
                    source.setException(e);
                    break;
                default: // Error
                    Throwable cause = future.getCause();
                    if (cause instanceof LineSdkLoginException) {
                        LineSdkLoginException loginException = (LineSdkLoginException) cause;
                        Log.e(TAG, loginException.getMessage());
                        source.setException(loginException);
                    } else {
                        source.setException(new Exception("Unknown error occurred in LINE SDK."));
                    }
                    break;
            }
        }
    });

    return source.getTask();
}
 
开发者ID:firebase,项目名称:custom-auth-samples,代码行数:37,代码来源:LineLoginHelper.java


示例11: getFirebaseAuthToken

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
private Task<String> getFirebaseAuthToken(Context context, final String lineAccessToken) {
    final TaskCompletionSource<String> source = new TaskCompletionSource<>();

    // STEP 2: Exchange LINE access token for Firebase Custom Auth token
    HashMap<String, String> validationObject = new HashMap<>();
    validationObject.put("token", lineAccessToken);

    // Exchange LINE Access Token for Firebase Auth Token
    Response.Listener<JSONObject> responseListener = new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            try {
                String firebaseToken = response.getString("firebase_token");
                Log.d(TAG, "Firebase Token = " + firebaseToken);
                source.setResult(firebaseToken);
            } catch (Exception e) {
                source.setException(e);
            }
        }
    };

    Response.ErrorListener errorListener = new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e(TAG, error.toString());
            source.setException(error);
        }
    };

    JsonObjectRequest fbTokenRequest = new JsonObjectRequest(
            Request.Method.POST, mLineAcessscodeVerificationEndpoint,
            new JSONObject(validationObject),
            responseListener, errorListener);

    NetworkSingleton.getInstance(context).addToRequestQueue(fbTokenRequest);

    return source.getTask();
}
 
开发者ID:firebase,项目名称:custom-auth-samples,代码行数:39,代码来源:LineLoginHelper.java


示例12: getFirebaseJwt

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
/**
 *
 * @param kakaoAccessToken Access token retrieved after successful Kakao Login
 * @return Task object that will call validation server and retrieve firebase token
 */
private Task<String> getFirebaseJwt(final String kakaoAccessToken) {
    final TaskCompletionSource<String> source = new TaskCompletionSource<>();

    RequestQueue queue = Volley.newRequestQueue(this);
    String url = getResources().getString(R.string.validation_server_domain) + "/verifyToken";
    HashMap<String, String> validationObject = new HashMap<>();
    validationObject.put("token", kakaoAccessToken);

    JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, url, new JSONObject(validationObject), new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            try {
                String firebaseToken = response.getString("firebase_token");
                source.setResult(firebaseToken);
            } catch (Exception e) {
                source.setException(e);
            }

        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e(TAG, error.toString());
            source.setException(error);
        }
    }) {
        @Override
        protected Map<String, String> getParams() {
            Map<String, String> params = new HashMap<>();
            params.put("token", kakaoAccessToken);
            return params;
        }
    };

    queue.add(request);
    return source.getTask();
}
 
开发者ID:firebase,项目名称:custom-auth-samples,代码行数:43,代码来源:MainActivity.java


示例13: signOut

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
public Task<Status> signOut() {
    final TaskCompletionSource<Status> statusTask = new TaskCompletionSource<>();
    getConnectedApiTask().addOnCompleteListener(new ExceptionForwarder<>(
            statusTask,
            new OnSuccessListener<Bundle>() {
                @Override
                public void onSuccess(Bundle status) {
                    Auth.GoogleSignInApi.signOut(mClient)
                            .setResultCallback(new TaskResultCaptor<>(statusTask));
                }
            }));
    return statusTask.getTask();
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:14,代码来源:GoogleSignInHelper.java


示例14: disableAutoSignIn

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
public Task<Status> disableAutoSignIn() {
    final TaskCompletionSource<Status> statusTask = new TaskCompletionSource<>();
    getConnectedApiTask().addOnCompleteListener(new ExceptionForwarder<>(
            statusTask,
            new OnSuccessListener<Bundle>() {
                @Override
                public void onSuccess(Bundle status) {
                    Auth.CredentialsApi.disableAutoSignIn(mClient)
                            .setResultCallback(new TaskResultCaptor<>(statusTask));
                }
            }));
    return statusTask.getTask();
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:14,代码来源:GoogleSignInHelper.java


示例15: delete

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
public Task<Status> delete(final Credential credential) {
    final TaskCompletionSource<Status> statusTask = new TaskCompletionSource<>();
    getConnectedApiTask().addOnCompleteListener(new ExceptionForwarder<>(
            statusTask,
            new OnSuccessListener<Bundle>() {
                @Override
                public void onSuccess(Bundle status) {
                    Auth.CredentialsApi.delete(mClient, credential)
                            .setResultCallback(new TaskResultCaptor<>(statusTask));
                }
            }));
    return statusTask.getTask();
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:14,代码来源:GoogleSignInHelper.java


示例16: waitForClosed

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
/**
 * Returns a task that will complete when given file is closed.  Returns immediately if the
 * file is not open.
 *
 * @param filename - the file name in question.
 */
public Task<Result> waitForClosed(String filename) {
  final TaskCompletionSource<Result> taskCompletionSource = new TaskCompletionSource<>();

  final CountDownLatch latch;
  synchronized (this) {
    latch = opened.get(filename);
  }

  if (latch == null) {
    taskCompletionSource.setResult(null);

    return taskCompletionSource.getTask();
  }

  new AsyncTask<Void, Void, Void>() {
    @Override
    protected Void doInBackground(Void... voids) {
      Result result = new CountDownTask(latch).await();
      taskCompletionSource.setResult(result);

      return null;
    }
  }.execute();

  return taskCompletionSource.getTask();
}
 
开发者ID:playgameservices,项目名称:android-basic-samples,代码行数:33,代码来源:SnapshotCoordinator.java


示例17: setIsOpeningTask

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
@NonNull
private Task<Void> setIsOpeningTask(String filename) {
  TaskCompletionSource<Void> source = new TaskCompletionSource<>();

  if (isAlreadyOpen(filename)) {
    source.setException(new IllegalStateException(filename + " is already open!"));
  } else if (isAlreadyClosing(filename)) {
    source.setException(new IllegalStateException(filename + " is current closing!"));
  } else {
    setIsOpening(filename);
    source.setResult(null);
  }
  return source.getTask();
}
 
开发者ID:playgameservices,项目名称:android-basic-samples,代码行数:15,代码来源:SnapshotCoordinator.java


示例18: setIsClosingTask

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
@NonNull
private Task<Void> setIsClosingTask(String filename) {
  TaskCompletionSource<Void> source = new TaskCompletionSource<>();

  if (!isAlreadyOpen(filename)) {
    source.setException(new IllegalStateException(filename + " is already closed!"));
  } else if (isAlreadyClosing(filename)) {
    source.setException(new IllegalStateException(filename + " is current closing!"));
  } else {
    setIsClosing(filename);
    source.setResult(null);
  }
  return source.getTask();
}
 
开发者ID:playgameservices,项目名称:android-basic-samples,代码行数:15,代码来源:SnapshotCoordinator.java


示例19: logInWithProvider

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
/**
 * Logs the current user in using a specific auth provider.
 *
 * @param authProvider The provider that will handle the login.
 * @return A task containing an {@link AuthInfo} session that can be resolved on completion of log in.
 */
public Task<String> logInWithProvider(AuthProvider authProvider) {

    if (isAuthenticated()) {
        Log.d(TAG, "Already logged in. Returning cached token");
        return Tasks.forResult(_auth.getAuthInfo().getUserId());
    }

    final TaskCompletionSource<String> future = new TaskCompletionSource<>();

    final JsonStringRequest request = new JsonStringRequest(
            Request.Method.POST,
            getResourcePath(routes.getAuthProvidersLoginRoute(authProvider.getType())),
            getAuthRequest(authProvider).toJson(),
            new Response.Listener<String>() {
                @Override
                public void onResponse(final String response) {
                    try {
                        _auth = new Auth(
                                StitchClient.this,
                                _objMapper.readValue(response, AuthInfo.class));
                        final RefreshTokenHolder refreshToken =
                                _objMapper.readValue(response, RefreshTokenHolder.class);
                        _preferences.edit().putString(PREF_AUTH_JWT_NAME, response).apply();
                        _preferences.edit().putString(PREF_AUTH_REFRESH_TOKEN_NAME, refreshToken.getToken()).apply();
                        _preferences.edit().putString(PREF_DEVICE_ID_NAME, _auth.getAuthInfo().getDeviceId()).apply();
                        future.setResult(_auth.getAuthInfo().getUserId());
                        onLogin();
                    } catch (final IOException e) {
                        Log.e(TAG, "Error parsing auth response", e);
                        future.setException(new StitchException(e));
                    }
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(final VolleyError error) {
                    Log.e(TAG, "Error while logging in with auth provider", error);
                    future.setException(parseRequestError(error));
                }
            });
    request.setTag(this);
    _queue.add(request);

    return future.getTask();
}
 
开发者ID:mongodb,项目名称:stitch-android-sdk,代码行数:52,代码来源:StitchClient.java


示例20: resetPassword

import com.google.android.gms.tasks.TaskCompletionSource; //导入依赖的package包/类
/**
 * Reset a given user's password
 *
 * @param token token associated with this user
 * @param tokenId id of the token associated with this user
 * @return A task containing whether or not the reset was successful
 */
public Task<Boolean> resetPassword(@NonNull final String token,
                                   @NonNull final String tokenId,
                                   @NonNull final String password) {
    final TaskCompletionSource<Boolean> future = new TaskCompletionSource<>();

    final String url = String.format(
            "%s/%s",
            getResourcePath(routes.AUTH),
            routes.USERPASS_RESET
    );

    final Document params = new Document();

    params.put(RegistrationFields.TOKEN, token);
    params.put(RegistrationFields.TOKEN_ID, tokenId);
    params.put(RegistrationFields.PASSWORD, password);

    final JsonStringRequest request = new JsonStringRequest(
            Request.Method.POST,
            url,
            params.toJson(),
            new Response.Listener<String>() {
                @Override
                public void onResponse(final String response) {
                    future.setResult(response != null);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(final VolleyError error) {
                    Log.e(TAG, "Error while reseting password", error);
                    future.setException(parseRequestError(error));
                }
            }
    );

    request.setTag(this);
    _queue.add(request);

    return future.getTask();
}
 
开发者ID:mongodb,项目名称:stitch-android-sdk,代码行数:49,代码来源:StitchClient.java



注:本文中的com.google.android.gms.tasks.TaskCompletionSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LocalizedTextUtil类代码示例发布时间:2022-05-23
下一篇:
Java MQVPublicParameters类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap