@@ -82,20 +82,25 @@ protected RequestToken doInBackground(Void... params) {
82
82
83
83
@ Override
84
84
protected void onPostExecute (final RequestToken token ) {
85
- mTwitterView .setWebViewClient (new WebViewClient () {
86
- @ Override
87
- public void onPageFinished (final WebView view , final String url ) {
88
- if (url .startsWith ("oauth://cb" )) {
89
- mTwitterView .destroy ();
90
- if (url .contains ("oauth_verifier" )) {
91
- getTwitterOAuthTokenAndLogin (token , Uri .parse (url ).getQueryParameter ("oauth_verifier" ));
92
- } else if (url .contains ("denied" )) {
93
- sendResultError (TwitterActions .USER_ERROR , FirebaseResponse .LOGIN_CANCELLED .ordinal (), "User denied access to their account." );
85
+ if (token == null ) {
86
+ // Then doInBackground failed and triggered error, so just return
87
+ return ;
88
+ } else {
89
+ mTwitterView .setWebViewClient (new WebViewClient () {
90
+ @ Override
91
+ public void onPageFinished (final WebView view , final String url ) {
92
+ if (url .startsWith ("oauth://cb" )) {
93
+ mTwitterView .destroy ();
94
+ if (url .contains ("oauth_verifier" )) {
95
+ getTwitterOAuthTokenAndLogin (token , Uri .parse (url ).getQueryParameter ("oauth_verifier" ));
96
+ } else if (url .contains ("denied" )) {
97
+ sendResultError (TwitterActions .USER_ERROR , FirebaseResponse .LOGIN_CANCELLED .ordinal (), "User denied access to their account." );
98
+ }
94
99
}
95
100
}
96
- }
97
- } );
98
- mTwitterView . loadUrl ( token . getAuthorizationURL ());
101
+ });
102
+ mTwitterView . loadUrl ( token . getAuthorizationURL () );
103
+ }
99
104
}
100
105
}.execute ();
101
106
}
0 commit comments