Search in sources :

Example 1 with IdpProvider

use of com.firebase.ui.auth.provider.IdpProvider in project FirebaseUI-Android by firebase.

the class AuthMethodPickerActivity method populateIdpList.

private void populateIdpList(List<IdpConfig> providers) {
    mIdpProviders = new ArrayList<>();
    for (IdpConfig idpConfig : providers) {
        switch(idpConfig.getProviderId()) {
            case AuthUI.GOOGLE_PROVIDER:
                mIdpProviders.add(new GoogleProvider(this, idpConfig));
                break;
            case AuthUI.FACEBOOK_PROVIDER:
                mIdpProviders.add(new FacebookProvider(this, idpConfig, mActivityHelper.getFlowParams().themeId));
                break;
            case AuthUI.TWITTER_PROVIDER:
                mIdpProviders.add(new TwitterProvider(this));
                break;
            case AuthUI.EMAIL_PROVIDER:
                findViewById(R.id.email_provider).setVisibility(View.VISIBLE);
                break;
            default:
                Log.e(TAG, "Encountered unknown IDPProvider parcel with type: " + idpConfig.getProviderId());
        }
    }
    ViewGroup btnHolder = (ViewGroup) findViewById(R.id.btn_holder);
    for (final IdpProvider provider : mIdpProviders) {
        View loginButton = null;
        switch(provider.getProviderId()) {
            case GoogleAuthProvider.PROVIDER_ID:
                loginButton = getLayoutInflater().inflate(R.layout.idp_button_google, btnHolder, false);
                break;
            case FacebookAuthProvider.PROVIDER_ID:
                loginButton = getLayoutInflater().inflate(R.layout.idp_button_facebook, btnHolder, false);
                break;
            case TwitterAuthProvider.PROVIDER_ID:
                loginButton = getLayoutInflater().inflate(R.layout.idp_button_twitter, btnHolder, false);
                break;
            default:
                Log.e(TAG, "No button for provider " + provider.getProviderId());
        }
        if (loginButton != null) {
            loginButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    mActivityHelper.showLoadingDialog(R.string.progress_dialog_loading);
                    provider.startLogin(AuthMethodPickerActivity.this);
                }
            });
            provider.setAuthenticationCallback(this);
            btnHolder.addView(loginButton, 0);
        }
    }
}
Also used : IdpConfig(com.firebase.ui.auth.AuthUI.IdpConfig) IdpProvider(com.firebase.ui.auth.provider.IdpProvider) TwitterProvider(com.firebase.ui.auth.provider.TwitterProvider) ViewGroup(android.view.ViewGroup) GoogleProvider(com.firebase.ui.auth.provider.GoogleProvider) ImageView(android.widget.ImageView) View(android.view.View) FacebookProvider(com.firebase.ui.auth.provider.FacebookProvider)

Aggregations

View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 IdpConfig (com.firebase.ui.auth.AuthUI.IdpConfig)1 FacebookProvider (com.firebase.ui.auth.provider.FacebookProvider)1 GoogleProvider (com.firebase.ui.auth.provider.GoogleProvider)1 IdpProvider (com.firebase.ui.auth.provider.IdpProvider)1 TwitterProvider (com.firebase.ui.auth.provider.TwitterProvider)1