本文整理汇总了Java中com.google.firebase.auth.UserInfo.getPhotoUrl方法的典型用法代码示例。如果您正苦于以下问题:Java UserInfo.getPhotoUrl方法的具体用法?Java UserInfo.getPhotoUrl怎么用?Java UserInfo.getPhotoUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.firebase.auth.UserInfo
的用法示例。
在下文中一共展示了UserInfo.getPhotoUrl方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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]
}
示例2: 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);
});
}
示例3: 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;
}
示例4: 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;
}
示例5: 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();
}
}
}
}
示例6: onCreate
import com.google.firebase.auth.UserInfo; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_userprofile);
toolbarLayout= findViewById(R.id.tbprofile);
toolbar= findViewById(R.id.barprofileactivity);
toolbar.setNavigationIcon(R.mipmap.ic_arrow_back_white_24dp);
setSupportActionBar(toolbar);
profileimage= findViewById(R.id.imgprofile);
mAuth=FirebaseAuth.getInstance();
user=mAuth.getCurrentUser();
if (user !=null) {
for (UserInfo userdata: user.getProviderData()) {
profileDisplayName=userdata.getDisplayName();
toolbarLayout.setTitle(profileDisplayName);
profilePhotoUrl=userdata.getPhotoUrl();
}
if (profilePhotoUrl !=null){
String image=profilePhotoUrl.toString();
Picasso.with(Userprofile.this)
.load(image)
.fit()
.into(profileimage);
}else{
profileimage.setImageDrawable(ContextCompat.getDrawable(Userprofile.this,R.drawable.nouserimage));
}
}
tbs= findViewById(R.id.profiletabs);
tbs.setSelectedTabIndicatorColor(ContextCompat.getColor(Userprofile.this,R.color.colorAccent));
vwpgr= findViewById(R.id.profilevpgr);
adaptadortabs adaptador=new adaptadortabs(getSupportFragmentManager());
vwpgr.setAdapter(adaptador);
tbs.setupWithViewPager(vwpgr);
}