@@ -276,32 +276,36 @@ public static int getDefaultTheme() {
276
276
*/
277
277
@ NonNull
278
278
public Task <Void > signOut (@ NonNull Context context ) {
279
- mAuth .signOut ();
280
-
281
279
Task <Void > maybeDisableAutoSignIn = GoogleApiUtils .getCredentialsClient (context )
282
280
.disableAutoSignIn ()
283
- .continueWithTask (new Continuation <Void , Task < Void > >() {
281
+ .continueWith (new Continuation <Void , Void >() {
284
282
@ Override
285
- public Task < Void > then (@ NonNull Task <Void > task ) {
283
+ public Void then (@ NonNull Task <Void > task ) {
286
284
// We want to ignore a specific exception, since it's not a good reason
287
285
// to fail (see Issue 1156).
288
- if (!task .isSuccessful () && (task .getException () instanceof ApiException )) {
289
- ApiException ae = (ApiException ) task .getException ();
290
- if (ae .getStatusCode () == CommonStatusCodes .CANCELED ) {
291
- Log .w (TAG , "Could not disable auto-sign in, maybe there are no " +
292
- "SmartLock accounts available?" , ae );
293
-
294
- return Tasks .forResult (null );
295
- }
286
+ Exception e = task .getException ();
287
+ if (e instanceof ApiException
288
+ && ((ApiException ) e ).getStatusCode () == CommonStatusCodes .CANCELED ) {
289
+ Log .w (TAG , "Could not disable auto-sign in, maybe there are no " +
290
+ "SmartLock accounts available?" , e );
291
+ return null ;
296
292
}
297
293
298
- return task ;
294
+ return task . getResult () ;
299
295
}
300
296
});
301
297
302
298
return Tasks .whenAll (
303
299
signOutIdps (context ),
304
- maybeDisableAutoSignIn );
300
+ maybeDisableAutoSignIn
301
+ ).continueWith (new Continuation <Void , Void >() {
302
+ @ Override
303
+ public Void then (@ NonNull Task <Void > task ) {
304
+ task .getResult (); // Propagate exceptions
305
+ mAuth .signOut ();
306
+ return null ;
307
+ }
308
+ });
305
309
}
306
310
307
311
/**
@@ -326,12 +330,6 @@ public Task<Void> delete(@NonNull Context context) {
326
330
327
331
// Ensure the order in which tasks are executed properly destructures the user.
328
332
return signOutIdps (context ).continueWithTask (new Continuation <Void , Task <Void >>() {
329
- @ Override
330
- public Task <Void > then (@ NonNull Task <Void > task ) {
331
- task .getResult (); // Propagate exception if there was one
332
- return currentUser .delete ();
333
- }
334
- }).continueWithTask (new Continuation <Void , Task <Void >>() {
335
333
@ Override
336
334
public Task <Void > then (@ NonNull Task <Void > task ) {
337
335
task .getResult (); // Propagate exception if there was one
@@ -341,9 +339,9 @@ public Task<Void> then(@NonNull Task<Void> task) {
341
339
credentialTasks .add (client .delete (credential ));
342
340
}
343
341
return Tasks .whenAll (credentialTasks )
344
- .continueWithTask (new Continuation <Void , Task < Void > >() {
342
+ .continueWith (new Continuation <Void , Void >() {
345
343
@ Override
346
- public Task < Void > then (@ NonNull Task <Void > task ) {
344
+ public Void then (@ NonNull Task <Void > task ) {
347
345
Exception e = task .getException ();
348
346
Throwable t = e == null ? null : e .getCause ();
349
347
if (!(t instanceof ApiException )
@@ -352,13 +350,19 @@ public Task<Void> then(@NonNull Task<Void> task) {
352
350
// one. This can occur if we failed to save the credential or it
353
351
// was deleted elsewhere. However, a lack of stored credential
354
352
// doesn't mean fully deleting the user failed.
355
- task .getResult ();
353
+ return task .getResult ();
356
354
}
357
355
358
- return Tasks . forResult ( null ) ;
356
+ return null ;
359
357
}
360
358
});
361
359
}
360
+ }).continueWithTask (new Continuation <Void , Task <Void >>() {
361
+ @ Override
362
+ public Task <Void > then (@ NonNull Task <Void > task ) {
363
+ task .getResult (); // Propagate exception if there was one
364
+ return currentUser .delete ();
365
+ }
362
366
});
363
367
}
364
368
0 commit comments