Source:
<code>protected void onActivityResult(int requestCode, int resultCode, Intent data) { <START> if (requestCode == OAUTH_ACTIVITY_CODE) { <END> AuthorizationResponse authResponse = AuthorizationResponse.fromIntent(data); AuthorizationException authException = AuthorizationException.fromIntent(data); if (authResponse != null) { String userEmail = authResponse.additionalParameters.get("user"); String spToken = authResponse.additionalParameters.get("token"); String wpToken = authResponse.additionalParameters.get("wp_token"); if (userEmail == null || spToken == null || !StrUtils.isSameStr(authResponse.state, mAuthState)) { showErrorDialog(getString(R.string.wpcom_sign_in_error_generic)); return; } Simplenote app = (Simplenote)getApplication(); User user = app.getSimperium().getUser(); user.setAccessToken(spToken); user.setEmail(userEmail); user.setStatus(User.Status.AUTHORIZED); SharedPreferences.Editor editor = AndroidClient.sharedPreferences(this).edit(); editor.putString(USER_ACCESS_TOKEN_PREFERENCE, user.getAccessToken()); editor.putString(USER_EMAIL_PREFERENCE, user.getEmail()); editor.apply(); if (wpToken != null) { SharedPreferences preferences = getSharedPreferences( PREFS_PRIVATE_NAME, Context.MODE_PRIVATE ); SharedPreferences.Editor spEditor = preferences.edit(); spEditor.putString(PrefUtils.PREF_WP_TOKEN, wpToken); spEditor.apply(); } finish(); } else if (authException != null) { Uri dataUri = data.getData(); if (dataUri != null) { if (StrUtils.isSameStr(dataUri.getQueryParameter("code"), "1")) { showErrorDialog(getString(R.string.wpcom_sign_in_error_unverified)); } else { showErrorDialog(getString(R.string.wpcom_sign_in_error_generic)); } } } } }</code><technical_language>I a problem nesting personally. I find early-abort pattern confusing times too. said, I understand preference for flat style. do a lot in simplenote-android WordPress-Android. fine in this case</technical_language>

Target:
protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode != OAUTH_ACTIVITY_CODE || data == null) { return; } AuthorizationResponse authResponse = AuthorizationResponse.fromIntent(data); AuthorizationException authException = AuthorizationException.fromIntent(data); if (authResponse != null) { String userEmail = authResponse.additionalParameters.get("user"); String spToken = authResponse.additionalParameters.get("token"); String wpToken = authResponse.additionalParameters.get("wp_token"); if (userEmail == null || spToken == null || !StrUtils.isSameStr(authResponse.state, mAuthState)) { showErrorDialog(getString(R.string.wpcom_sign_in_error_generic)); return; } Simplenote app = (Simplenote)getApplication(); User user = app.getSimperium().getUser(); user.setAccessToken(spToken); user.setEmail(userEmail); user.setStatus(User.Status.AUTHORIZED); SharedPreferences.Editor editor = AndroidClient.sharedPreferences(this).edit(); editor.putString(USER_ACCESS_TOKEN_PREFERENCE, user.getAccessToken()); editor.putString(USER_EMAIL_PREFERENCE, user.getEmail()); editor.apply(); if (wpToken != null) { SharedPreferences.Editor appEditor = PreferenceManager.getDefaultSharedPreferences(this).edit(); appEditor.putString(PrefUtils.PREF_WP_TOKEN, wpToken); appEditor.apply(); } AnalyticsTracker.track( AnalyticsTracker.Stat.WPCC_LOGIN_SUCCEEDED, AnalyticsTracker.CATEGORY_USER, "wpcc_login_succeeded_signin_activity" ); finish(); } else if (authException != null) { Uri dataUri = data.getData(); if (dataUri == null) { return; } if (StrUtils.isSameStr(dataUri.getQueryParameter("code"), "1")) { showErrorDialog(getString(R.string.wpcom_sign_in_error_unverified)); } else { showErrorDialog(getString(R.string.wpcom_sign_in_error_generic)); } } }