@Test public void googlePlayServicesAvailabilityExceptionShouldBeResolved() throws Exception { EnhancedShadowGooglePlayServicesUtil.mockDialog = mock(Dialog.class); GooglePlayServicesAvailabilityException stubException = mock(GooglePlayServicesAvailabilityException.class); sut.onError(stubException); verify(EnhancedShadowGooglePlayServicesUtil.mockDialog).show(); }
@Override public void onError(Throwable e) { if (e instanceof GooglePlayServicesAvailabilityException) { int statusCode = ((GooglePlayServicesAvailabilityException) e) .getConnectionStatusCode(); Dialog dialog = GooglePlayServicesUtil.getErrorDialog(statusCode, activity, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR); dialog.show(); } else if (e instanceof UserRecoverableAuthException) { Intent intent = ((UserRecoverableAuthException) e).getIntent(); activity.startActivityForResult(intent, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR); } else { callback.onError(e); } }
AuthObserver implements Observer<AuthToken> { @Override public void onError(Throwable e) { if (e instanceof GooglePlayServicesAvailabilityException) { int statusCode = ((GooglePlayServicesAvailabilityException) e) .getConnectionStatusCode(); Dialog dialog = GooglePlayServicesUtil.getErrorDialog(statusCode, activity, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR); dialog.show(); } else if (e instanceof UserRecoverableAuthException) { Intent intent = ((UserRecoverableAuthException) e).getIntent(); activity.startActivityForResult(intent, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR); } else { callback.onError(e); } } }
AuthObserver implements Observer<AuthToken> { @Override public void onError(Throwable e) { if (e instanceof GooglePlayServicesAvailabilityException) { int statusCode = ((GooglePlayServicesAvailabilityException) e) .getConnectionStatusCode(); Dialog dialog = GooglePlayServicesUtil.getErrorDialog(statusCode, activity, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR); dialog.show(); } else if (e instanceof UserRecoverableAuthException) { Intent intent = ((UserRecoverableAuthException) e).getIntent(); activity.startActivityForResult(intent, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR); } else { callback.onError(e); } } AuthObserver(Activity activity, AuthCallback callback); }
AuthObserver implements Observer<AuthToken> { @Override public void onError(Throwable e) { if (e instanceof GooglePlayServicesAvailabilityException) { int statusCode = ((GooglePlayServicesAvailabilityException) e) .getConnectionStatusCode(); Dialog dialog = GooglePlayServicesUtil.getErrorDialog(statusCode, activity, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR); dialog.show(); } else if (e instanceof UserRecoverableAuthException) { Intent intent = ((UserRecoverableAuthException) e).getIntent(); activity.startActivityForResult(intent, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR); } else { callback.onError(e); } } AuthObserver(Activity activity, AuthCallback callback); @Override void onCompleted(); @Override void onError(Throwable e); @Override void onNext(AuthToken token); }
AuthObserver implements Observer<AuthToken> { @Override public void onError(Throwable e) { if (e instanceof GooglePlayServicesAvailabilityException) { int statusCode = ((GooglePlayServicesAvailabilityException) e) .getConnectionStatusCode(); Dialog dialog = GooglePlayServicesUtil.getErrorDialog(statusCode, activity, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR); dialog.show(); } else if (e instanceof UserRecoverableAuthException) { Intent intent = ((UserRecoverableAuthException) e).getIntent(); activity.startActivityForResult(intent, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR); } else { callback.onError(e); } } AuthObserver(Activity activity, AuthCallback callback); @Override void onCompleted(); @Override void onError(Throwable e); @Override void onNext(AuthToken token); static final int REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR; }