本文整理汇总了Java中com.firebase.ui.auth.AuthUI类的典型用法代码示例。如果您正苦于以下问题:Java AuthUI类的具体用法?Java AuthUI怎么用?Java AuthUI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthUI类属于com.firebase.ui.auth包,在下文中一共展示了AuthUI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onOptionsItemSelected
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.subscribe:
FirebaseMessaging.getInstance().subscribeToTopic("pushNotifications");
Toast.makeText(MainActivity.this, "Subscribed to Topic: Push Notifications", Toast.LENGTH_SHORT).show();
break;
case R.id.unsubscribe:
FirebaseMessaging.getInstance().unsubscribeFromTopic("pushNotifications");
Toast.makeText(MainActivity.this, "Unsubscribed to Topic: Push Notifications", Toast.LENGTH_SHORT).show();
break;
case R.id.sign_out_menu:
AuthUI.getInstance().signOut(this);
break;
default:
return super.onOptionsItemSelected(item);
}
return true;}
示例2: launchLoginActivityResult
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
private void launchLoginActivityResult() {
//Test
if(mIdlingResource != null)
mIdlingResource.setIdleState(false);
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setTheme(R.style.LoginTheme)
.setIsSmartLockEnabled(!BuildConfig.DEBUG)
.setAvailableProviders(
Arrays.asList(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(),
new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build()))
.build(),
RC_SIGN_IN);
overridePendingTransition(R.anim.fui_slide_in_right, R.anim.fui_slide_in_right);
}
示例3: onCreate
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
counter =0;
mAuth = FirebaseAuth.getInstance();
databaseFamilies = FirebaseDatabase.getInstance().getReference("Families");
setContentView(R.layout.activity_app_login);
Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
//Signs in user with Google sign in
mEmailSignInButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
// Check if user is signed in (non-null)
FirebaseUser currentUser = mAuth.getCurrentUser();
// Add user to database
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build(),
RC_SIGN_IN);
}
});
}
示例4: onOptionsItemSelected
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_logout) {
AuthUI.getInstance()
.signOut(this)
.addOnCompleteListener(new OnCompleteListener<Void>() {
public void onComplete(@NonNull Task<Void> task) {
// user is now signed out
startActivity(new Intent(BookListsActivity.this, DispatchActivity.class));
finish();
}
});
return true;
}
return super.onOptionsItemSelected(item);
}
示例5: onOptionsItemSelected
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO: 10/30/17 respect the design remove repository from here.
MainRepository repository = viewModel.getRepository();
switch (item.getItemId()) {
case R.id.menu_add_items:
repository.addRestaurants(this);
break;
case R.id.menu_sign_out:
AuthUI.getInstance().signOut(this);
startSignIn();
break;
case R.id.menu_delete:
repository.deleteAll();
break;
}
return super.onOptionsItemSelected(item);
}
示例6: onOptionsItemSelected
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_add_items:
onAddItemsClicked();
break;
case R.id.menu_sign_out:
AuthUI.getInstance().signOut(this);
startSignIn();
break;
case R.id.menu_delete:
RestaurantUtil.deleteAll();
break;
}
return super.onOptionsItemSelected(item);
}
示例7: onOptionsItemSelected
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_admin_page:
Intent intent = new Intent(this, AdminPageActivity.class);
startActivity(intent);
return true;
case R.id.action_sign_out:
AuthUI.getInstance()
.signOut(this)
.addOnCompleteListener(new OnCompleteListener<Void>() {
public void onComplete(@NonNull Task<Void> task) {
// user is now signed out
startActivity(new Intent(WizardActivity.this, WizardActivity.class));
finish();
}
});
return true;
default:
return super.onOptionsItemSelected(item);
}
}
示例8: onOptionsItemSelected
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_sign_out:
AuthUI.getInstance()
.signOut(this)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
showSignIn();
finish();
}
});
return true;
default:
return super.onOptionsItemSelected(item);
}
}
示例9: logout
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
private void logout() {
Alert.showConfirm(this, R.string.drawer_logout_title, R.string.leave,
R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
AuthUI.getInstance()
.signOut(MainActivity.this)
.addOnCompleteListener(new OnCompleteListener<Void>() {
public void onComplete(@NonNull Task<Void> task) {
// user is now signed out
startActivity(new Intent(MainActivity.this, SplashActivity.class));
finish();
}
});
}
});
}
示例10: onCreate
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FirebaseAuth auth = FirebaseAuth.getInstance();
Intent intent;
if (auth.getCurrentUser() == null) {
startActivityForResult(
AuthUI.getInstance().createSignInIntentBuilder()
// .setTheme(getSelectedTheme())
// .setLogo(getSelectedLogo())
.setProviders(getSelectedProviders())
// .setTosUrl(getSelectedTosUrl())
.build(),
RC_SIGN_IN);
}else{
intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
}
示例11: signOut
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
/**
* This method to sign out, from both the email sign or google sign
*/
protected void signOut() {
AuthUI.getInstance()
.signOut(this)
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
// user is now sign out
// Get back to the sign in page
startActivity(new Intent(getBaseContext(), SignInUI.class));
finish();
}
});
}
示例12: onCreate
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FirebaseAuth auth = FirebaseAuth.getInstance();
if (auth.getCurrentUser() != null) {
// already signed in
} else {
// not signed in
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setProviders(
AuthUI.GOOGLE_PROVIDER
)
.setIsSmartLockEnabled(false)
.build(),
RESULT_CODE_ACTIVITY);
}
}
示例13: startSignInProcess
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
public void startSignInProcess() {
if (!checkGooglePlayServices()) {
return;
}
FirebaseAuth auth = FirebaseAuth.getInstance();
if (auth.getCurrentUser() != null) {
RxBus.INSTANCE.post(new SnackbarRequest(new SnackbarBundle(getString(R.string.sign_in_successful))));
} else {
ArrayList<AuthUI.IdpConfig> providers = new ArrayList<>();
providers.add(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build());
providers.add(new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build());
startActivityForResult(
// Get an instance of AuthUI based on the default app
AuthUI.getInstance()
.createSignInIntentBuilder()
.setProviders(providers)
.setLogo(R.drawable.logo)
.setTosUrl("https://github.com/jamieadkins95/Yennefr/blob/master/TOS.md")
.setIsSmartLockEnabled(!BuildConfig.DEBUG)
.setTheme(R.style.Theme_Gwent)
.build(),
REQUEST_CODE_SIGN_IN);
}
}
示例14: signOut
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
@OnClick(R.id.sign_out)
public void signOut() {
AuthUI.getInstance()
.signOut(this)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
startActivity(AuthUiActivity.createIntent(SignedInActivity.this));
finish();
} else {
showSnackbar(R.string.sign_out_failed);
}
}
});
}
示例15: providerIdToAccountType
import com.firebase.ui.auth.AuthUI; //导入依赖的package包/类
/**
* Translate a Firebase Auth provider ID (such as {@link GoogleAuthProvider#PROVIDER_ID}) to a
* Credentials API account type (such as {@link IdentityProviders#GOOGLE}).
*/
public static String providerIdToAccountType(@AuthUI.SupportedProvider @NonNull String providerId) {
switch (providerId) {
case GoogleAuthProvider.PROVIDER_ID:
return IdentityProviders.GOOGLE;
case FacebookAuthProvider.PROVIDER_ID:
return IdentityProviders.FACEBOOK;
case TwitterAuthProvider.PROVIDER_ID:
return IdentityProviders.TWITTER;
case PhoneAuthProvider.PROVIDER_ID:
return PHONE_IDENTITY;
// The account type for email/password creds is null
case EmailAuthProvider.PROVIDER_ID:
default:
return null;
}
}