app/src/main/java/com/smedic/tubtub/fragments/PlaylistsFragment.java
@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        switch (requestCode) {
            case REQUEST_AUTHORIZATION:
                if (resultCode != Activity.RESULT_OK) {
                    chooseAccount();
                }
                break;
            case REQUEST_ACCOUNT_PICKER:
                if (resultCode == Activity.RESULT_OK && data != null
                        && data.getExtras() != null) {
                    String accountName = data.getExtras().getString(
                            AccountManager.KEY_ACCOUNT_NAME);
                    if (accountName != null) {
                        mChosenAccountName = accountName;
                        youTubeSearch.setAuthSelectedAccountName(accountName);
                        userNameTextView.setText(extractUserName(mChosenAccountName));
                        Toast.makeText(getContext(), "Hi " + extractUserName(mChosenAccountName), Toast.LENGTH_SHORT).show();
                        saveAccount();
                    }

                    youTubeSearch.searchPlaylists();
                }
                break;
        }
    }
/**
     * Handles Google OAuth 2.0 authorization or account chosen result
     *
     * @param requestCode
     * @param resultCode
     * @param data
     */
Handles Google OAuth 2.0 authorization or account chosen result
@param requestCode
@param resultCode
@param data
Handles Google OAuth 2 . 0 authorization or account chosen result @param requestCode @param resultCode @param data
@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case REQUEST_AUTHORIZATION:
                if (resultCode != Activity.RESULT_OK) {
                    chooseAccount();
                }
                break;
            case REQUEST_ACCOUNT_PICKER:
                if (resultCode == Activity.RESULT_OK && data != null
                        && data.getExtras() != null) {
                    String accountName = data.getExtras().getString(
                            AccountManager.KEY_ACCOUNT_NAME);
                    if (accountName != null) {
                        mChosenAccountName = accountName;
                        youTubeSearch.setAuthSelectedAccountName(accountName);
                        userNameTextView.setText(extractUserName(mChosenAccountName));
                        Toast.makeText(getContext(), "Hi " + extractUserName(mChosenAccountName), Toast.LENGTH_SHORT).show();
                        saveAccount();
                    }
                    youTubeSearch.searchPlaylists();
                }
                break;
        }
    }
@ Override public void onActivityResult ( int requestCode , int resultCode , Intent data ) { super . onActivityResult ( requestCode , resultCode , data ) ; switch ( requestCode ) { case REQUEST_AUTHORIZATION : if ( resultCode != Activity . RESULT_OK ) { chooseAccount ( ) ; } break ; case REQUEST_ACCOUNT_PICKER : if ( resultCode == Activity . RESULT_OK && data != null && data . getExtras ( ) != null ) { String accountName = data . getExtras ( ) . getString ( AccountManager . KEY_ACCOUNT_NAME ) ; if ( accountName != null ) { mChosenAccountName = accountName ; youTubeSearch . setAuthSelectedAccountName ( accountName ) ; userNameTextView . setText ( extractUserName ( mChosenAccountName ) ) ; Toast . makeText ( getContext ( ) , "Hi " + extractUserName ( mChosenAccountName ) , Toast . LENGTH_SHORT ) . show ( ) ; saveAccount ( ) ; } youTubeSearch . searchPlaylists ( ) ; } break ; } }
Handles Google OAuth 2.0 authorization or account chosen result
 @param requestCode
 @param resultCode
 @param data
Handles Google OAuth 2 . 0 authorization or account chosen result @param requestCode @param resultCode @param data