private <T> T await(@NonNull Task<T> curTask) { try { Tasks.await(curTask, mTimeoutMs, TimeUnit.MILLISECONDS); return curTask.getResult(); } catch (ExecutionException | InterruptedException | TimeoutException e) { if (BuildConfig.DEBUG) { Log.w(TAG, "API request dispatch failed", e); } return null; } }
@Override @WorkerThread @Nullable public FirebaseUser createUserWithEmailAndPassword( @NonNull String emailAddress, @NonNull String password) throws ExecutionException, InterruptedException { Task<AuthResult> curTask; curTask = mFirebaseAuth.createUserWithEmailAndPassword(emailAddress, password); Tasks.await(curTask); return curTask.getResult().getUser(); }
@Override @WorkerThread public boolean resetPasswordForEmail(@NonNull String emailAddress) { Task<Void> curTask = mFirebaseAuth.sendPasswordResetEmail(emailAddress); try { Tasks.await(curTask); } catch (ExecutionException | InterruptedException e) { Log.w(TAG, "attempt to reset password failed", e); return false; } return true; }