{"action":"created","comment":{"url":"https://api.github.com/repos/firebase/FirebaseUI-Android/pulls/comments/93687864","pull_request_review_id":14219919,"id":93687864,"diff_hunk":"@@ -127,83 +123,71 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {\n     }\n \n     @Override\n-    public void onClick(View view) {\n-        next(mPrevIdpResponse);\n-    }\n-\n-    @Override\n-    public void onSuccess(IdpResponse idpResponse) {\n-        next(idpResponse);\n-    }\n-\n-    @Override\n-    public void onFailure(Bundle extra) {\n-        Toast.makeText(getApplicationContext(), \"Error signing in\", Toast.LENGTH_LONG).show();\n-        finish(ResultCodes.CANCELED, IdpResponse.getErrorCodeIntent(ErrorCodes.UNKNOWN_ERROR));\n-    }\n-\n-    private String getProviderIdFromIntent() {\n-        return getIntent().getStringExtra(ExtraConstants.EXTRA_PROVIDER);\n-    }\n-\n-    private String getEmailFromIntent() {\n-        return getIntent().getStringExtra(ExtraConstants.EXTRA_EMAIL);\n-    }\n-\n-    private void next(final IdpResponse newIdpResponse) {\n-        if (newIdpResponse == null) {\n+    public void onSuccess(final IdpResponse idpResponse) {\n+        if (idpResponse == null) {\n             return; // do nothing\n         }\n \n-        AuthCredential newCredential = AuthCredentialHelper.getAuthCredential(newIdpResponse);\n+        AuthCredential newCredential = AuthCredentialHelper.getAuthCredential(idpResponse);\n         if (newCredential == null) {\n             Log.e(TAG, \"No credential returned\");\n             finish(ResultCodes.CANCELED, IdpResponse.getErrorCodeIntent(ErrorCodes.UNKNOWN_ERROR));\n             return;\n         }\n \n-        final FirebaseAuth firebaseAuth = mActivityHelper.getFirebaseAuth();\n-        FirebaseUser currentUser = firebaseAuth.getCurrentUser();\n-\n+        FirebaseUser currentUser = mActivityHelper.getCurrentUser();\n         if (currentUser == null) {\n-            Task<AuthResult> authResultTask = firebaseAuth.signInWithCredential(newCredential);\n-            authResultTask.addOnCompleteListener(new OnCompleteListener<AuthResult>() {\n-                @Override\n-                public void onComplete(@NonNull Task<AuthResult> task) {\n-                    if (task.isSuccessful() && mPrevCredential != null) {\n-                        FirebaseUser firebaseUser = task.getResult().getUser();\n-                        firebaseUser.linkWithCredential(mPrevCredential);\n-                        firebaseAuth.signOut();\n-                        firebaseAuth\n-                                .signInWithCredential(mPrevCredential)\n-                                .addOnFailureListener(new TaskFailureLogger(\n-                                        TAG, \"Error signing in with previous credential\"))\n-                                .addOnCompleteListener(new FinishListener(newIdpResponse));\n-                    } else {\n-                        finish(ResultCodes.OK, IdpResponse.getIntent(newIdpResponse));\n-                    }\n-                }\n-            }).addOnFailureListener(\n-                    new TaskFailureLogger(TAG, \"Error signing in with new credential\"));\n+            mActivityHelper.getFirebaseAuth()\n+                    .signInWithCredential(newCredential)\n+                    .addOnSuccessListener(new OnSuccessListener<AuthResult>() {\n+                        @Override\n+                        public void onSuccess(AuthResult result) {\n+                            if (mPrevCredential != null) {\n+                                result.getUser()\n+                                        .linkWithCredential(mPrevCredential)\n+                                        .addOnFailureListener(new TaskFailureLogger(\n+                                                TAG, \"Error signing in with previous credential\"))\n+                                        .addOnCompleteListener(new FinishListener(idpResponse));\n+                            } else {\n+                                finish(ResultCodes.OK, IdpResponse.getIntent(idpResponse));\n+                            }\n+                        }\n+                    })\n+                    .addOnFailureListener(new OnFailureListener() {\n+                        @Override\n+                        public void onFailure(@NonNull Exception e) {\n+                            finishWithError();","path":"auth/src/main/java/com/firebase/ui/auth/ui/accountlink/WelcomeBackIdpPrompt.java","position":161,"original_position":161,"commit_id":"9541c6c79184883b1ef516d857a225562b09286c","original_commit_id":"076e3c08484c148796dba9cbaad9e6858a22b7b1","user":{"login":"SUPERCILEX","id":9490724,"avatar_url":"https://avatars.githubusercontent.com/u/9490724?v=3","gravatar_id":"","url":"https://api.github.com/users/SUPERCILEX","html_url":"https://github.com/SUPERCILEX","followers_url":"https://api.github.com/users/SUPERCILEX/followers","following_url":"https://api.github.com/users/SUPERCILEX/following{/other_user}","gists_url":"https://api.github.com/users/SUPERCILEX/gists{/gist_id}","starred_url":"https://api.github.com/users/SUPERCILEX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SUPERCILEX/subscriptions","organizations_url":"https://api.github.com/users/SUPERCILEX/orgs","repos_url":"https://api.github.com/users/SUPERCILEX/repos","events_url":"https://api.github.com/users/SUPERCILEX/events{/privacy}","received_events_url":"https://api.github.com/users/SUPERCILEX/received_events","type":"User","site_admin":false},"body":"On failure, we fail.","created_at":"2016-12-22T20:01:34Z","updated_at":"2016-12-22T20:10:30Z","html_url":"https://github.com/firebase/FirebaseUI-Android/pull/469#discussion_r93687864","pull_request_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/pulls/469","_links":{"self":{"href":"https://api.github.com/repos/firebase/FirebaseUI-Android/pulls/comments/93687864"},"html":{"href":"https://github.com/firebase/FirebaseUI-Android/pull/469#discussion_r93687864"},"pull_request":{"href":"https://api.github.com/repos/firebase/FirebaseUI-Android/pulls/469"}}},"pull_request":{"url":"https://api.github.com/repos/firebase/FirebaseUI-Android/pulls/469","id":99035557,"html_url":"https://github.com/firebase/FirebaseUI-Android/pull/469","diff_url":"https://github.com/firebase/FirebaseUI-Android/pull/469.diff","patch_url":"https://github.com/firebase/FirebaseUI-Android/pull/469.patch","issue_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/issues/469","number":469,"state":"open","locked":false,"title":"Cleanup + make sure IdpResponse is never null if resultCode == ResultCodes.OK","user":{"login":"SUPERCILEX","id":9490724,"avatar_url":"https://avatars.githubusercontent.com/u/9490724?v=3","gravatar_id":"","url":"https://api.github.com/users/SUPERCILEX","html_url":"https://github.com/SUPERCILEX","followers_url":"https://api.github.com/users/SUPERCILEX/followers","following_url":"https://api.github.com/users/SUPERCILEX/following{/other_user}","gists_url":"https://api.github.com/users/SUPERCILEX/gists{/gist_id}","starred_url":"https://api.github.com/users/SUPERCILEX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SUPERCILEX/subscriptions","organizations_url":"https://api.github.com/users/SUPERCILEX/orgs","repos_url":"https://api.github.com/users/SUPERCILEX/repos","events_url":"https://api.github.com/users/SUPERCILEX/events{/privacy}","received_events_url":"https://api.github.com/users/SUPERCILEX/received_events","type":"User","site_admin":false},"body":"#468\r\n\r\nNote: this PR includes #447 to make my life easier. 😄","created_at":"2016-12-22T01:43:39Z","updated_at":"2016-12-22T20:10:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0f00fe8fb3737386d391958f6276a3c07d0db185","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/pulls/469/commits","review_comments_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/pulls/469/comments","review_comment_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/issues/469/comments","statuses_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/statuses/9541c6c79184883b1ef516d857a225562b09286c","head":{"label":"SUPERCILEX:IdpResponse","ref":"IdpResponse","sha":"9541c6c79184883b1ef516d857a225562b09286c","user":{"login":"SUPERCILEX","id":9490724,"avatar_url":"https://avatars.githubusercontent.com/u/9490724?v=3","gravatar_id":"","url":"https://api.github.com/users/SUPERCILEX","html_url":"https://github.com/SUPERCILEX","followers_url":"https://api.github.com/users/SUPERCILEX/followers","following_url":"https://api.github.com/users/SUPERCILEX/following{/other_user}","gists_url":"https://api.github.com/users/SUPERCILEX/gists{/gist_id}","starred_url":"https://api.github.com/users/SUPERCILEX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SUPERCILEX/subscriptions","organizations_url":"https://api.github.com/users/SUPERCILEX/orgs","repos_url":"https://api.github.com/users/SUPERCILEX/repos","events_url":"https://api.github.com/users/SUPERCILEX/events{/privacy}","received_events_url":"https://api.github.com/users/SUPERCILEX/received_events","type":"User","site_admin":false},"repo":{"id":67086210,"name":"FirebaseUI-Android","full_name":"SUPERCILEX/FirebaseUI-Android","owner":{"login":"SUPERCILEX","id":9490724,"avatar_url":"https://avatars.githubusercontent.com/u/9490724?v=3","gravatar_id":"","url":"https://api.github.com/users/SUPERCILEX","html_url":"https://github.com/SUPERCILEX","followers_url":"https://api.github.com/users/SUPERCILEX/followers","following_url":"https://api.github.com/users/SUPERCILEX/following{/other_user}","gists_url":"https://api.github.com/users/SUPERCILEX/gists{/gist_id}","starred_url":"https://api.github.com/users/SUPERCILEX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SUPERCILEX/subscriptions","organizations_url":"https://api.github.com/users/SUPERCILEX/orgs","repos_url":"https://api.github.com/users/SUPERCILEX/repos","events_url":"https://api.github.com/users/SUPERCILEX/events{/privacy}","received_events_url":"https://api.github.com/users/SUPERCILEX/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SUPERCILEX/FirebaseUI-Android","description":null,"fork":true,"url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android","forks_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/forks","keys_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/teams","hooks_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/hooks","issue_events_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/issues/events{/number}","events_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/events","assignees_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/assignees{/user}","branches_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/branches{/branch}","tags_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/tags","blobs_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/git/refs{/sha}","trees_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/statuses/{sha}","languages_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/languages","stargazers_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/stargazers","contributors_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/contributors","subscribers_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/subscribers","subscription_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/subscription","commits_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/commits{/sha}","git_commits_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/git/commits{/sha}","comments_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/comments{/number}","issue_comment_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/issues/comments{/number}","contents_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/contents/{+path}","compare_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/merges","archive_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/downloads","issues_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/issues{/number}","pulls_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/pulls{/number}","milestones_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/milestones{/number}","notifications_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/labels{/name}","releases_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/releases{/id}","deployments_url":"https://api.github.com/repos/SUPERCILEX/FirebaseUI-Android/deployments","created_at":"2016-09-01T01:14:01Z","updated_at":"2016-11-14T02:05:15Z","pushed_at":"2016-12-22T20:09:19Z","git_url":"git://github.com/SUPERCILEX/FirebaseUI-Android.git","ssh_url":"git@github.com:SUPERCILEX/FirebaseUI-Android.git","clone_url":"https://github.com/SUPERCILEX/FirebaseUI-Android.git","svn_url":"https://github.com/SUPERCILEX/FirebaseUI-Android","homepage":null,"size":17440,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"firebase:version-1.1.0-dev","ref":"version-1.1.0-dev","sha":"e074facb5c5ce61f8b8a7fd27af8c3d468a6645a","user":{"login":"firebase","id":1335026,"avatar_url":"https://avatars.githubusercontent.com/u/1335026?v=3","gravatar_id":"","url":"https://api.github.com/users/firebase","html_url":"https://github.com/firebase","followers_url":"https://api.github.com/users/firebase/followers","following_url":"https://api.github.com/users/firebase/following{/other_user}","gists_url":"https://api.github.com/users/firebase/gists{/gist_id}","starred_url":"https://api.github.com/users/firebase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firebase/subscriptions","organizations_url":"https://api.github.com/users/firebase/orgs","repos_url":"https://api.github.com/users/firebase/repos","events_url":"https://api.github.com/users/firebase/events{/privacy}","received_events_url":"https://api.github.com/users/firebase/received_events","type":"Organization","site_admin":false},"repo":{"id":38835213,"name":"FirebaseUI-Android","full_name":"firebase/FirebaseUI-Android","owner":{"login":"firebase","id":1335026,"avatar_url":"https://avatars.githubusercontent.com/u/1335026?v=3","gravatar_id":"","url":"https://api.github.com/users/firebase","html_url":"https://github.com/firebase","followers_url":"https://api.github.com/users/firebase/followers","following_url":"https://api.github.com/users/firebase/following{/other_user}","gists_url":"https://api.github.com/users/firebase/gists{/gist_id}","starred_url":"https://api.github.com/users/firebase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firebase/subscriptions","organizations_url":"https://api.github.com/users/firebase/orgs","repos_url":"https://api.github.com/users/firebase/repos","events_url":"https://api.github.com/users/firebase/events{/privacy}","received_events_url":"https://api.github.com/users/firebase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/firebase/FirebaseUI-Android","description":"UI bindings for Firebase","fork":false,"url":"https://api.github.com/repos/firebase/FirebaseUI-Android","forks_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/forks","keys_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/teams","hooks_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/hooks","issue_events_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/issues/events{/number}","events_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/events","assignees_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/assignees{/user}","branches_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/branches{/branch}","tags_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/tags","blobs_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/git/refs{/sha}","trees_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/statuses/{sha}","languages_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/languages","stargazers_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/stargazers","contributors_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/contributors","subscribers_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/subscribers","subscription_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/subscription","commits_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/commits{/sha}","git_commits_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/git/commits{/sha}","comments_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/comments{/number}","issue_comment_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/issues/comments{/number}","contents_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/contents/{+path}","compare_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/merges","archive_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/downloads","issues_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/issues{/number}","pulls_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/pulls{/number}","milestones_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/milestones{/number}","notifications_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/labels{/name}","releases_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/releases{/id}","deployments_url":"https://api.github.com/repos/firebase/FirebaseUI-Android/deployments","created_at":"2015-07-09T17:31:09Z","updated_at":"2016-12-22T12:07:47Z","pushed_at":"2016-12-22T20:09:20Z","git_url":"git://github.com/firebase/FirebaseUI-Android.git","ssh_url":"git@github.com:firebase/FirebaseUI-Android.git","clone_url":"https://github.com/firebase/FirebaseUI-Android.git","svn_url":"https://github.com/firebase/FirebaseUI-Android","homepage":"","size":17056,"stargazers_count":1322,"watchers_count":1322,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":441,"mirror_url":null,"open_issues_count":47,"forks":441,"open_issues":47,"watchers":1322,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/firebase/FirebaseUI-Android/pulls/469"},"html":{"href":"https://github.com/firebase/FirebaseUI-Android/pull/469"},"issue":{"href":"https://api.github.com/repos/firebase/FirebaseUI-Android/issues/469"},"comments":{"href":"https://api.github.com/repos/firebase/FirebaseUI-Android/issues/469/comments"},"review_comments":{"href":"https://api.github.com/repos/firebase/FirebaseUI-Android/pulls/469/comments"},"review_comment":{"href":"https://api.github.com/repos/firebase/FirebaseUI-Android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/firebase/FirebaseUI-Android/pulls/469/commits"},"statuses":{"href":"https://api.github.com/repos/firebase/FirebaseUI-Android/statuses/9541c6c79184883b1ef516d857a225562b09286c"}}}}
{"actor":{"display_login":"SUPERCILEX"}}