当前位置: 首页>>代码示例>>Java>>正文


Java ErrorCodes类代码示例

本文整理汇总了Java中com.firebase.ui.auth.ErrorCodes的典型用法代码示例。如果您正苦于以下问题:Java ErrorCodes类的具体用法?Java ErrorCodes怎么用?Java ErrorCodes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ErrorCodes类属于com.firebase.ui.auth包,在下文中一共展示了ErrorCodes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleSignInResponse

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
private void handleSignInResponse(int resultCode, IdpResponse response) {
    if (resultCode == ResultCodes.OK) {
        updateAuthUI();
        return;
    } else {
        if (response == null) {
            showSnackBar("Sign in cancelled");
            return;
        }

        if (response.getErrorCode() == ErrorCodes.NO_NETWORK) {
            showSnackBar("No internet connection");
            return;
        }

        if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
            showSnackBar("Unknown error");
            return;
        }
    }

    showSnackBar("Unknown sign_in response");
}
 
开发者ID:GDG-Trondheim,项目名称:firebase-ui-quickstart-android,代码行数:24,代码来源:DemoActivity.java

示例2: onReceiveFirebaseAuthResult

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
private void onReceiveFirebaseAuthResult(int resultCode, Intent data) {
        IdpResponse response = IdpResponse.fromResultIntent(data);

        // Successfully signed in
        if (resultCode == RESULT_OK) {
            FirebaseAuthHelper.getIdTokenForCurrentUser(firebaseAuthCallback);
            return;
        } else {
             //Sign in failed
            if (response == null) {
                // User pressed back button
                Log.i(TAG, "BACK button pressed");
                return;
            }

            if (response.getErrorCode() == ErrorCodes.NO_NETWORK || response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
                showSnackbar(R.string.dlg_internet_connection_error, Snackbar.LENGTH_INDEFINITE);
                return;
            }
        }
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:22,代码来源:BaseAuthActivity.java

示例3: onActivityResult

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // If this is for the sign in activity:
    if (requestCode == RC_SIGN_IN) {
        IdpResponse response = IdpResponse.fromResultIntent(data);
        if (resultCode == ResultCodes.OK) {
            Log.d(TAG, "Login was successful");
            // Now that the user is signed in, update currentUser:
            currentUser = mAuth.getCurrentUser();
            // Transition to the home/settings fragment based on what the user needs to do from here:
            navigateBasedOnUser();
        } else {
            // If there is not a success, try to figure out what went wrong:
            if (response == null) Log.e(TAG, "User pressed back button");
            else if (response.getErrorCode() == ErrorCodes.NO_NETWORK) {
                Log.e(TAG, "Network connection error");
                Toast.makeText(this, R.string.network_connection_error, Toast.LENGTH_SHORT).show();
            } else if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
                Log.e(TAG, "Unknown error");
                Toast.makeText(this, R.string.unknown_auth_error, Toast.LENGTH_SHORT).show();
                showSignIn();
            } else Log.e(TAG, "Unknown response");
        }
        // Debug currentUser again:
        Log.d(TAG, "Is the user not signed in? " + Boolean.toString(currentUser == null));
    }
}
 
开发者ID:brianjaustin,项目名称:permitlog-android,代码行数:28,代码来源:MainActivity.java

示例4: onActivityResult

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // RC_SIGN_IN is the request code you passed into startActivityForResult(...) when starting the sign in flow.
    if (requestCode == RC_SIGN_IN) {
        IdpResponse response = IdpResponse.fromResultIntent(data);

        // Successfully signed in
        if (resultCode == ResultCodes.OK) {
            SharedPreferences.Editor editor = getSharedPreferences(FIRST_TIME_LOGIN, MODE_PRIVATE).edit();
            editor.putBoolean(Constants.IS_FIRST_TIME, true);
            editor.apply();
            googleLoginButton.setVisibility(View.INVISIBLE);
            showWhiteSnackBar(R.string.sign_in_successful);
            linearLayout.setVisibility(View.GONE);
            Utils.fetchDataFromFirebase(LoginActivity.this);
            return;
        } else {
            if (response == null) {
                showWhiteSnackBar(R.string.sign_in_cancelled);
                return;
            }

            if (response.getErrorCode() == ErrorCodes.NO_NETWORK) {
                showWhiteSnackBar(R.string.no_internet_connection);
                return;
            }

            if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
                showWhiteSnackBar(R.string.unknown_error);
                return;
            }
        }

        showWhiteSnackBar(R.string.unknown_sign_in_response);
    }
}
 
开发者ID:vixir,项目名称:Perfect-Day,代码行数:37,代码来源:LoginActivity.java

示例5: onActivityResult

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RC_SIGN_IN) {
        // get Idpi Response codes
        IdpResponse idpResponse = IdpResponse.fromResultIntent(data);

        if (resultCode == RESULT_OK) {
            // goto main activity
            // FIXME: for testing purposes only
            startActivity(new Intent(SplashPageActivity.this, ChooseTypeActivity.class));

        } else {
            if (idpResponse == null) {
                // user pressed back button
                showToast("Sign in Cancelled by user.");
                return;
            } else if (idpResponse.getErrorCode() == ErrorCodes.NO_NETWORK) {
                showToast("No internet Connection");
                return;
            } else if (idpResponse.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
                showToast("Some Error Occured!");
                return;
            }

            showToast("Couldn't sign in. Unknown Response, Please try again later.");
        }
    }
}
 
开发者ID:rumaan,项目名称:AcademApp,代码行数:30,代码来源:SplashPageActivity.java

示例6: onActivityResult

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // RC_SIGN_IN is the request code you passed into startActivityForResult(...) when starting the sign in flow.
    if (requestCode == RC_SIGN_IN) {
        IdpResponse response = IdpResponse.fromResultIntent(data);

        // Successfully signed in
        if (resultCode == ResultCodes.OK) {
            showSnackbar(R.string.signed_in);
            return;
        } else {
            // Sign in failed
            if (response == null) {
                // User pressed back button
                showSnackbar(R.string.sign_in_cancelled);
                return;
            }

            if (response.getErrorCode() == ErrorCodes.NO_NETWORK) {
                showSnackbar(R.string.no_internet_connection);
                return;
            }

            if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
                showSnackbar(R.string.unknown_error);
                return;
            }
        }

        showSnackbar(R.string.unknown_sign_in_response);
    }
}
 
开发者ID:open-roboclub,项目名称:roboclub-amu,代码行数:33,代码来源:AdminFragment.java

示例7: handleSignInResponse

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
@MainThread
private void handleSignInResponse(int resultCode, Intent data) {
    IdpResponse response = IdpResponse.fromResultIntent(data);

    // Successfully signed in
    if (resultCode == RESULT_OK) {
        startSignedInActivity(response);
        finish();
        return;
    } else {
        // Sign in failed
        if (response == null) {
            // User pressed back button
            showSnackbar(R.string.sign_in_cancelled);
            return;
        }

        if (response.getErrorCode() == ErrorCodes.NO_NETWORK) {
            showSnackbar(R.string.no_internet_connection);
            return;
        }

        if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
            showSnackbar(R.string.unknown_error);
            return;
        }
    }

    showSnackbar(R.string.unknown_sign_in_response);
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:31,代码来源:AuthUiActivity.java

示例8: onClick

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
@Override
public void onClick(View view) {
    final int id = view.getId();
    if (id == R.id.button_done) {
        validateAndSignIn();
    } else if (id == R.id.trouble_signing_in) {
        startActivity(RecoverPasswordActivity.createIntent(
                this,
                getFlowParams(),
                mEmail));
        finish(RESULT_CANCELED, IdpResponse.getErrorCodeIntent(ErrorCodes.UNKNOWN_ERROR));
    }
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:14,代码来源:WelcomeBackPasswordPrompt.java

示例9: onComplete

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
    if (task.isSuccessful()) {
        FirebaseUser firebaseUser = task.getResult().getUser();
        mActivity.saveCredentialsOrFinish(mSmartLock, firebaseUser, mResponse);
    } else {
        if (task.getException() instanceof FirebaseAuthUserCollisionException) {
            String email = mResponse.getEmail();
            if (email != null) {
                FirebaseAuth auth = mActivity.getAuthHelper().getFirebaseAuth();
                ProviderUtils.fetchTopProvider(auth, email)
                        .addOnSuccessListener(new StartWelcomeBackFlow())
                        .addOnFailureListener(new OnFailureListener() {
                            @Override
                            public void onFailure(@NonNull Exception e) {
                                Intent intent = IdpResponse.getErrorCodeIntent(ErrorCodes.UNKNOWN_ERROR);
                                mActivity.finish(Activity.RESULT_CANCELED, intent);
                            }
                        });
                return;
            }
        } else {
            Log.e(TAG,
                  "Unexpected exception when signing in with credential "
                          + mResponse.getProviderType()
                          + " unsuccessful. Visit https://console.firebase.google.com to enable it.",
                  task.getException());
        }

        mActivity.getDialogHolder().dismissDialog();
    }
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:33,代码来源:CredentialSignInHandler.java

示例10: onCreate

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSaveSmartLock = getAuthHelper().getSaveSmartLockInstance(mActivity);

    User user = User.getUser(getArguments());
    String provider = user.getProviderId();

    AuthUI.IdpConfig providerConfig = null;
    for (AuthUI.IdpConfig config : getFlowParams().providerInfo) {
        if (config.getProviderId().equalsIgnoreCase(provider)) {
            providerConfig = config;
            break;
        }
    }

    if (providerConfig == null) {
        // we don't have a provider to handle this
        finish(Activity.RESULT_CANCELED, IdpResponse.getErrorCodeIntent(ErrorCodes.UNKNOWN_ERROR));
        return;
    }

    if (provider.equalsIgnoreCase(GoogleAuthProvider.PROVIDER_ID)) {
        mIdpProvider = new GoogleProvider(
                getActivity(),
                providerConfig,
                user.getEmail());
    } else if (provider.equalsIgnoreCase(FacebookAuthProvider.PROVIDER_ID)) {
        mIdpProvider = new FacebookProvider(providerConfig, getFlowParams().themeId);
    } else if (provider.equalsIgnoreCase(TwitterAuthProvider.PROVIDER_ID)) {
        mIdpProvider = new TwitterProvider(getContext());
    }

    mIdpProvider.setAuthenticationCallback(this);

    if (savedInstanceState == null) {
        mIdpProvider.startLogin(getActivity());
    }
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:40,代码来源:IdpSignInContainer.java

示例11: onActivityResult

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RC_SIGN_IN) {

        if (resultCode == ErrorCodes.UNKNOWN_ERROR) {
            AuthUI.getInstance().signOut(this);
        }

        if (resultCode == ErrorCodes.NO_NETWORK) {

            showStatus(NO_INTERNET);

        } else {
            checkUserIsLoged();
        }

    } else if (requestCode == RC_BARCODE_CAPTURE && resultCode == CommonStatusCodes.SUCCESS) {

        if (data != null) {

            Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject);

            Fragment searchFragment = SearchResultFragment.newInstance(mFolderId, barcode.displayValue, R.menu.menu_search_result);

            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.replace(R.id.fragment_main_container, searchFragment).commitAllowingStateLoss();

        }
    }else if (requestCode == RC_PICKFILE && resultCode == CommonStatusCodes.SUCCESS_CACHE){
        Log.d(TAG,data.getDataString());

        try {

            Uri uri = data.getData();
            String mimeType = getContentResolver().getType(uri);

            Cursor returnCursor =
                    getContentResolver().query(uri, null, null, null, null);

            int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
            int sizeIndex = returnCursor.getColumnIndex(OpenableColumns.SIZE);
            returnCursor.moveToFirst();

            Log.d(TAG,"mimeType: " + mimeType);
            Log.d(TAG,"nameView: " + returnCursor.getString(nameIndex));
            Log.d(TAG,"sizeView: " + returnCursor.getLong(sizeIndex));

            File file = new File(PathUtils.getPath(mContext,uri));

            Log.d(TAG,"File path: " + PathUtils.getPath(mContext,uri));
            Log.d(TAG,"File absolute path: " + PathUtils.getPath(mContext,uri));
            Log.d(TAG,"File exists? : " + file.exists());

        } catch (Exception e) {
            e.printStackTrace();
            Log.e(TAG,e.getMessage());
        }

    }
}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:63,代码来源:MainActivity.java

示例12: onActivityResult

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);

  if (requestCode == RC_SIGN_IN) {

    IdpResponse response = IdpResponse.fromResultIntent(data);

    // Successfully signed in
    if (resultCode == ResultCodes.OK) {
      Intent startMainActivityIntent = new Intent(this, BookListsActivity.class);
      startActivity(startMainActivityIntent);
      finish();
      return;
    } else {
      // Sign in failed
      if (response == null) {
        // User pressed back button
        Log.e(TAG, "onActivityResult: sign_in_cancelled");
        showErrorMessage("To bad... It seems like you cancelled :/");
      }

      if (response.getErrorCode() == ErrorCodes.NO_NETWORK) {
        Log.e(TAG, "onActivityResult: no_internet_connection");
        showErrorMessage("Ups! There's no internet connection");
      }

      if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
        Log.e(TAG, "onActivityResult: unknown_error");
        showErrorMessage("Woot! Something unexpected just happend.");
      }
    }

    if (!errorShown) {
      Log.e(TAG, "onActivityResult: unknown_sign_in_response");
      showErrorMessage("Woot! Something unexpected just happend.");
    }

    new Handler().postDelayed(new Runnable() {
      @Override
      public void run() {
        finish(); // TODO: CHANGE THIS
      }
    }, Snackbar.LENGTH_SHORT);

  }
}
 
开发者ID:paulnunezm,项目名称:Boookito-Capstone-Project,代码行数:48,代码来源:DispatchActivity.java

示例13: onActivityResult

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // make sure that MainActivityFragment's onActivityResult() gets called
    super.onActivityResult(requestCode, resultCode, data);

    // RC_SIGN_IN is the request code you passed into startActivityForResult(...) when starting the sign in flow.
    if (requestCode == RC_SIGN_IN) {
        IdpResponse response = IdpResponse.fromResultIntent(data);

        // Successfully signed in
        if (resultCode == ResultCodes.OK) {
            Toast.makeText(this, "WelcomeBackActivity", Toast.LENGTH_SHORT).show();

            IdpResponse idpResponse = IdpResponse.fromResultIntent(data);
            fillUserProfileData();

            layoutLoggedIn.setVisibility(View.VISIBLE);
            layoutLogin.setVisibility(View.GONE);

            return;
        } else {
            // Sign in failed
            if (response == null) {
                // User pressed back button
                Toast.makeText(this, "sign_in_cancelled", Toast.LENGTH_SHORT).show();
                return;
            }

            if (response.getErrorCode() == ErrorCodes.NO_NETWORK) {
                Toast.makeText(this, "no_internet_connection", Toast.LENGTH_SHORT).show();
                return;
            }

            if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
                Toast.makeText(this, "unknown_error", Toast.LENGTH_SHORT).show();
                return;
            }
        }
        Toast.makeText(this, "unknown_sign_in_response", Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:malah-code,项目名称:Open-Quran-Radio,代码行数:42,代码来源:MainActivity.java

示例14: onCreate

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fui_welcome_back_idp_prompt_layout);

    IdpResponse newUserResponse = IdpResponse.fromResultIntent(getIntent());
    if (newUserResponse != null) {
        mPrevCredential = ProviderUtils.getAuthCredential(newUserResponse);
    }

    User oldUser = User.getUser(getIntent());

    String providerId = oldUser.getProviderId();
    for (IdpConfig idpConfig : getFlowParams().providerInfo) {
        if (providerId.equals(idpConfig.getProviderId())) {
            switch (providerId) {
                case GoogleAuthProvider.PROVIDER_ID:
                    mIdpProvider = new GoogleProvider(this, idpConfig, oldUser.getEmail());
                    break;
                case FacebookAuthProvider.PROVIDER_ID:
                    mIdpProvider = new FacebookProvider(
                            idpConfig, getFlowParams().themeId);
                    break;
                case TwitterAuthProvider.PROVIDER_ID:
                    mIdpProvider = new TwitterProvider(this);
                    break;
                default:
                    Log.w(TAG, "Unknown provider: " + providerId);
                    finish(RESULT_CANCELED,
                           IdpResponse.getErrorCodeIntent(ErrorCodes.UNKNOWN_ERROR));
                    return;
            }
        }
    }

    if (mIdpProvider == null) {
        Log.w(TAG, "Firebase login unsuccessful."
                + " Account linking failed due to provider not enabled by application: "
                + providerId);
        finish(RESULT_CANCELED, IdpResponse.getErrorCodeIntent(ErrorCodes.UNKNOWN_ERROR));
        return;
    }

    ((TextView) findViewById(R.id.welcome_back_idp_prompt))
            .setText(getIdpPromptString(oldUser.getEmail()));

    mIdpProvider.setAuthenticationCallback(this);
    findViewById(R.id.welcome_back_idp_button).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            getDialogHolder().showLoadingDialog(R.string.fui_progress_dialog_signing_in);
            mIdpProvider.startLogin(WelcomeBackIdpPrompt.this);
        }
    });
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:56,代码来源:WelcomeBackIdpPrompt.java

示例15: finishWithError

import com.firebase.ui.auth.ErrorCodes; //导入依赖的package包/类
private void finishWithError() {
    Toast.makeText(this, R.string.fui_general_error, Toast.LENGTH_LONG).show();
    finish(RESULT_CANCELED, IdpResponse.getErrorCodeIntent(ErrorCodes.UNKNOWN_ERROR));
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:5,代码来源:WelcomeBackIdpPrompt.java


注:本文中的com.firebase.ui.auth.ErrorCodes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。