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


Java UserInfo类代码示例

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


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

示例1: signOut

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
public static void signOut(GoogleApiClient mGoogleApiClient, FragmentActivity fragmentActivity) {
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if (user != null) {
        DatabaseHelper.getInstance(fragmentActivity.getApplicationContext())
                .removeRegistrationToken(FirebaseInstanceId.getInstance().getToken(), user.getUid());

        for (UserInfo profile : user.getProviderData()) {
            String providerId = profile.getProviderId();
            logoutByProvider(providerId, mGoogleApiClient, fragmentActivity);
        }
        logoutFirebase(fragmentActivity.getApplicationContext());
    }

    if (clearImageCacheAsyncTask == null) {
        clearImageCacheAsyncTask = new ClearImageCacheAsyncTask(fragmentActivity.getApplicationContext());
        clearImageCacheAsyncTask.execute();
    }
}
 
开发者ID:rozdoum,项目名称:social-app-android,代码行数:19,代码来源:LogoutHelper.java

示例2: getProviderData

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
private void getProviderData() {
    // [START get_provider_data]
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if (user != null) {
        for (UserInfo profile : user.getProviderData()) {
            // Id of the provider (ex: google.com)
            String providerId = profile.getProviderId();

            // UID specific to the provider
            String uid = profile.getUid();

            // Name, email address, and profile photo Url
            String name = profile.getDisplayName();
            String email = profile.getEmail();
            Uri photoUrl = profile.getPhotoUrl();
        };
    }
    // [END get_provider_data]
}
 
开发者ID:firebase,项目名称:snippets-android,代码行数:20,代码来源:MainActivity.java

示例3: syncUserProfiles

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
private void syncUserProfiles() {
        String uid = mFirebaseUser.getUid();
        final DatabaseReference user = mDatabase.getReference("/users").child(uid);
        user.child("email").setValue(mFirebaseUser.getEmail());
        user.child("name").setValue(mFirebaseUser.getDisplayName());
        setDisplayName(mFirebaseUser.getDisplayName());
        for (UserInfo userInfo : mFirebaseUser.getProviderData()) {
            if (!userInfo.getProviderId().equals("firebase")) {
                user.child(userInfo.getProviderId().split("\\.")[0]).setValue(userInfo.getUid());
            }
        }
//        if (isUsingInstagram()) {
//            if (instagramEngine == null) {
//                setupInstagram();
//            }
//            instagramEngine.getUserDetails(new InstagramUserIdCallback(user));
//        }
    }
 
开发者ID:cache117,项目名称:social-journal,代码行数:19,代码来源:MainActivity.java

示例4: saveUserInfo

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
@Override
public void saveUserInfo() {
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if (user != null) {
        String id = "";
        String name = user.getDisplayName();
        String email = user.getEmail();
        String photoUrl = user.getPhotoUrl().toString();

        for (UserInfo profile : user.getProviderData()) {
            String providerId = profile.getProviderId();
            if (providerId.compareToIgnoreCase("facebook.com") == 0) {
                id = profile.getUid();
                break;
            }
        }
        userInfo.put(USERINFO.ID, id);
        userInfo.put(USERINFO.FIRSTNAME, name.split(" ")[0]);
        userInfo.put(USERINFO.FULLNAME, name);
        userInfo.put(USERINFO.IMAGE_URL, photoUrl);
        userInfo.put(USERINFO.EMAIL, email);
    }

}
 
开发者ID:Danihelsan,项目名称:MikuyConcept,代码行数:25,代码来源:SessionHandler.java

示例5: doInBackground

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
@Override
protected Void doInBackground(Void... voids) {
    final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if(user != null) {
        for(UserInfo info : user.getProviderData()) {
            switch(info.getProviderId()) {
                case GoogleAuthProvider.PROVIDER_ID:
                    logoutGoogle();
                    break;
                case FacebookAuthProvider.PROVIDER_ID:
                    logoutFacebook();
                    break;
                case TwitterAuthProvider.PROVIDER_ID:
                    logoutTwitter();
                    break;
            }
        }
        FirebaseAuth.getInstance().signOut();
    }
    return null;
}
 
开发者ID:ultramega,项目名称:flavordex,代码行数:22,代码来源:SettingsActivity.java

示例6: showProviders

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
private void showProviders(FirebaseUser user) {
    List<? extends UserInfo> providers = user.getProviderData();

    for (int i = 0; i < providers.size(); i++) {
        UserInfo userInfo = providers.get(i);

        RadioButton radioButton = createRadio(userInfo.getProviderId());
        radioButton.setId(i);
        if(userInfo.getPhotoUrl()!= null && userInfo.getPhotoUrl().equals(user.getPhotoUrl())) {
            radioButton.setChecked(true);
        }
        providersLayout.addView(radioButton);
    }

    providersLayout.setOnCheckedChangeListener((group, checkedId) -> {
        Uri uri = providers.get(checkedId).getPhotoUrl();
        showImageAvatar(uri);
    });
}
 
开发者ID:open-roboclub,项目名称:roboclub-amu,代码行数:20,代码来源:AdminFragment.java

示例7: getCredentialsFromFirebaseUser

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
/**
 * Make a list of {@link Credential} from a FirebaseUser. Useful for deleting Credentials, not
 * for saving since we don't have access to the password.
 */
private static List<Credential> getCredentialsFromFirebaseUser(@NonNull FirebaseUser user) {
    if (TextUtils.isEmpty(user.getEmail()) && TextUtils.isEmpty(user.getPhoneNumber())) {
        return Collections.emptyList();
    }

    List<Credential> credentials = new ArrayList<>();
    for (UserInfo userInfo : user.getProviderData()) {
        if (FirebaseAuthProvider.PROVIDER_ID.equals(userInfo.getProviderId())) {
            continue;
        }

        String type = ProviderUtils.providerIdToAccountType(userInfo.getProviderId());

        credentials.add(new Credential.Builder(
                user.getEmail() == null ? user.getPhoneNumber() : user.getEmail())
                .setAccountType(type)
                .build());
    }

    return credentials;
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:26,代码来源:AuthUI.java

示例8: DashboardAdapter

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
public DashboardAdapter(Context context) {
    Calendar calendar = Calendar.getInstance();
    int today = calendar.get(Calendar.DAY_OF_WEEK);

    // Today is default
    rowItems.add(new Section(context.getString(R.string.section_title_today), getSectionDate(calendar)));
    calendar.add(Calendar.DAY_OF_YEAR, 1);

    if (today >= Calendar.MONDAY && today <= Calendar.WEDNESDAY) {
        rowItems.add(new Section(context.getString(R.string.section_title_tomorrow), getSectionDate(calendar)));
        calendar.add(Calendar.DAY_OF_YEAR, 1);
        rowItems.add(new Section(context.getString(R.string.section_title_this_week), getSectionDate(calendar)));
    } else if (today == Calendar.THURSDAY) {
        rowItems.add(new Section(context.getString(R.string.section_title_tomorrow), getSectionDate(calendar)));
        calendar.add(Calendar.DAY_OF_YEAR, 1);
        rowItems.add(new Section(context.getString(R.string.section_title_weekend), getSectionDate(calendar)));
    } else if (today == Calendar.FRIDAY)
        rowItems.add(new Section(context.getString(R.string.section_title_weekend), getSectionDate(calendar)));
    else if (today == Calendar.SATURDAY)
        rowItems.add(new Section(context.getString(R.string.section_title_tomorrow), getSectionDate(calendar)));

    calendar = Calendar.getInstance();
    calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);

    if (calendar.getFirstDayOfWeek() != Calendar.SUNDAY || today != Calendar.SUNDAY)
        calendar.add(Calendar.WEEK_OF_YEAR, 1);

    rowItems.add(new Section(context.getString(R.string.section_title_next_week), getSectionDate(calendar)));

    // TODO: Holiday and interval sections (between two holidays, to give a clearer overview over whats happening in the long run)
    calendar.add(Calendar.WEEK_OF_YEAR, 1);
    rowItems.add(new Section("Until the end of the universe", getSectionDate(calendar)));

    // TODO: Listen on login
    UserInfo userInfo = FirebaseAuth.getInstance().getCurrentUser();
    if (userInfo != null) {
        DocumentReference userReference = FirebaseFirestore.getInstance()
                .collection("users")
                .document(userInfo.getUid());

        userReference.collection("groups")
                .addSnapshotListener(this);
        userReference.collection("items")
                .addSnapshotListener(new GroupItemsChangeListener(FirebaseAuth.getInstance().getCurrentUser().getUid()));
    }
}
 
开发者ID:whirlwind-studios,项目名称:School1-Android,代码行数:47,代码来源:DashboardAdapter.java

示例9: init

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
public void init() {
	// Initialize listener.
	// ...

	FacebookSdk.sdkInitialize(activity);
	// FacebookSdk.setApplicationId(activity.getString(R.string.facebook_app_id));

	mAuth = FirebaseAuth.getInstance();
	mAuthListener = new FirebaseAuth.AuthStateListener() {

		@Override
		public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
			FirebaseUser user = firebaseAuth.getCurrentUser();
			if (user != null) {
				for (UserInfo usr : user.getProviderData()) {
					if (usr.getProviderId().equals("facebook.com")) {
						Utils.d("FB:AuthStateChanged:signed_in:"+
						user.getUid());
						successLogin(user);
					}
				}
			} else {
				// User is signed out
				Utils.d("FB:onAuthStateChanged:signed_out");
				successLogOut();
			}

			// update user details;
		}
	};

	// AppEventsLogger.activityApp(activity);

	initCallbacks();
	onStart();

	Utils.d("Facebook auth initialized.");
}
 
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:39,代码来源:FacebookSignIn.java

示例10: init

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
public void init() {
	TwitterAuthConfig authConfig = new TwitterAuthConfig(
	activity.getString(R.string.twitter_consumer_key),
	activity.getString(R.string.twitter_consumer_secret));

	Fabric.with(activity, new Twitter(authConfig));

	mAuth = FirebaseAuth.getInstance();

	twitterAuthClient = new TwitterAuthClient();
	mAuthListener = new FirebaseAuth.AuthStateListener() {
		@Override
		public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
			FirebaseUser user = firebaseAuth.getCurrentUser();

			if (user != null) {
				// User is signed in
				for (UserInfo usr : user.getProviderData()) {
					if (usr.getProviderId().equals("twitter.com")) {
						Utils.d("Twitter:AuthStateChanged:signed_in:"+
						user.getUid());

						successSignIn(user);
					}
				}

			} else {
				// User is signed out
				Utils.d("Twitter:onAuthStateChanged:signed_out");
				successSignOut();
			}

			// update firebase auth dets.
		}
	};

	onStart();
}
 
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:39,代码来源:TwitterSignIn.java

示例11: setupUserFirstTime

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
public static User setupUserFirstTime(FirebaseUser firebaseUser, Context context) {

        User user = new User(firebaseUser.getUid(),
                firebaseUser.getEmail(),
                firebaseUser.getDisplayName(),
                firebaseUser.getPhotoUrl() == null ? null : firebaseUser.getPhotoUrl().toString(),
                DateUtils.getCurrentTimeString());

        try {
            if (user.getPhotoUrl() == null) {
                for (UserInfo userInfo : firebaseUser.getProviderData()) {
                    if (userInfo.getPhotoUrl() != null) {
                        user.setPhotoUrl(userInfo.getPhotoUrl().toString());
                        break;
                    }
                }
            }
        } catch (Exception ex) {

        }

        Folder myBooksFolder = new Folder();
        myBooksFolder.setId(UUID.randomUUID().toString());
        myBooksFolder.setDescription(context.getResources().getString(R.string.tab_my_books));
        myBooksFolder.setCustom(false);

        user.setFolders(Collections.singletonMap(FirebaseDatabaseHelper.REF_MY_BOOKS_FOLDER, myBooksFolder));

        return user;

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

示例12: firebaseUserToJSONObject

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
private static JSONObject firebaseUserToJSONObject(FirebaseUser firebaseUser) throws Exception {
    JSONObject jsonUser = userInfoToJSONObject((UserInfo) firebaseUser);
    jsonUser.put("isAnonymous", firebaseUser.isAnonymous());

    JSONArray providerDataArray = new JSONArray();
    for (UserInfo userInfo : firebaseUser.getProviderData()) {
        providerDataArray.put(userInfoToJSONObject(userInfo));
    }
    jsonUser.put("providerData", providerDataArray);

    return jsonUser;
}
 
开发者ID:jsayol,项目名称:cordova-plugin-firebase-sdk,代码行数:13,代码来源:AuthComponent.java

示例13: userInfoToJSONObject

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
private static JSONObject userInfoToJSONObject(UserInfo userInfo) throws Exception {
    Uri photoUrl = userInfo.getPhotoUrl();

    JSONObject jsonUser = new JSONObject();
    jsonUser.put("uid", userInfo.getUid());
    jsonUser.put("displayName", userInfo.getDisplayName());
    jsonUser.put("email", userInfo.getEmail());
    jsonUser.put("photoURL", (photoUrl != null) ? photoUrl.toString() : null);
    jsonUser.put("providerId", userInfo.getProviderId());
    jsonUser.put("emailVerified", userInfo.isEmailVerified());
    return jsonUser;
}
 
开发者ID:jsayol,项目名称:cordova-plugin-firebase-sdk,代码行数:13,代码来源:AuthComponent.java

示例14: onAuthStateChanged

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
    FirebaseUser user = firebaseAuth.getCurrentUser();
    if (user != null && firebaseBugFlag) {
        firebaseBugFlag = false;
        for (UserInfo profile : user.getProviderData()) {
            String providerId = profile.getProviderId();
            if (providerId.equals(FIREBASE_PROVIDER_ID)) {
                if (!user.isAnonymous()) {
                    if (context != null) {
                        String name = profile.getDisplayName();
                        String email = profile.getEmail();
                        Uri photoUrl = profile.getPhotoUrl();
                        String photo = photoUrl != null ? photoUrl.toString() : "";

                        SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(context);
                        SharedPreferences.Editor editor = shared.edit();
                        editor.putString(SSConstants.SS_USER_NAME_INDEX, name);
                        editor.putString(SSConstants.SS_USER_EMAIL_INDEX, email);
                        editor.putString(SSConstants.SS_USER_PHOTO_INDEX, photo);
                        editor.commit();
                    }
                }

                SSEvent.track(SSConstants.SS_EVENT_APP_OPEN);

                openApp();
            }
        }
    }
}
 
开发者ID:Adventech,项目名称:sabbath-school-android,代码行数:32,代码来源:SSLoginViewModel.java

示例15: invalidateEditAccountPref

import com.google.firebase.auth.UserInfo; //导入依赖的package包/类
/**
 * Update the visibility of the edit account preference based on whether the current user
 * is authenticated using the email provider.
 */
private void invalidateEditAccountPref() {
    mPrefEditAccount.setVisible(false);
    final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if(user != null) {
        for(UserInfo info : user.getProviderData()) {
            if(info.getProviderId().equals(EmailAuthProvider.PROVIDER_ID)) {
                mPrefEditAccount.setVisible(true);
                return;
            }
        }
    }
}
 
开发者ID:ultramega,项目名称:flavordex,代码行数:17,代码来源:SettingsActivity.java


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