本文整理汇总了Java中com.google.samples.apps.iosched.util.AccountUtils.getPlusName方法的典型用法代码示例。如果您正苦于以下问题:Java AccountUtils.getPlusName方法的具体用法?Java AccountUtils.getPlusName怎么用?Java AccountUtils.getPlusName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.samples.apps.iosched.util.AccountUtils
的用法示例。
在下文中一共展示了AccountUtils.getPlusName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupAccountBox
import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
/**
* Sets up the account box. The account box is the area at the top of the nav drawer that
* shows which account the user is logged in as, and lets them switch accounts. It also
* shows the user's Google+ cover photo as background.
*/
private void setupAccountBox() {
mAccountListContainer = (LinearLayout) findViewById(R.id.account_list);
if (mAccountListContainer == null) {
//This activity does not have an account box
return;
}
final View chosenAccountView = findViewById(R.id.chosen_account_view);
Account chosenAccount = AccountUtils.getActiveAccount(this);
if (chosenAccount == null) {
// No account logged in; hide account box
chosenAccountView.setVisibility(View.GONE);
mAccountListContainer.setVisibility(View.GONE);
return;
} else {
chosenAccountView.setVisibility(View.VISIBLE);
mAccountListContainer.setVisibility(View.INVISIBLE);
}
AccountManager am = AccountManager.get(this);
Account[] accountArray = am.getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
List<Account> accounts = new ArrayList<Account>(Arrays.asList(accountArray));
accounts.remove(chosenAccount);
ImageView coverImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_cover_image);
ImageView profileImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_image);
TextView nameTextView = (TextView) chosenAccountView.findViewById(R.id.profile_name_text);
TextView email = (TextView) chosenAccountView.findViewById(R.id.profile_email_text);
mExpandAccountBoxIndicator = (ImageView) findViewById(R.id.expand_account_box_indicator);
String name = AccountUtils.getPlusName(this);
if (name == null) {
nameTextView.setVisibility(View.GONE);
} else {
nameTextView.setVisibility(View.VISIBLE);
nameTextView.setText(name);
}
String imageUrl = AccountUtils.getPlusImageUrl(this);
if (imageUrl != null) {
mImageLoader.loadImage(imageUrl, profileImageView);
}
String coverImageUrl = AccountUtils.getPlusCoverUrl(this);
if (coverImageUrl != null) {
mImageLoader.loadImage(coverImageUrl, coverImageView);
} else {
coverImageView.setImageResource(R.color.nearby_header_color);
}
email.setText(chosenAccount.name);
if (accounts.isEmpty()) {
// There's only one account on the device, so no need for a switcher.
mExpandAccountBoxIndicator.setVisibility(View.GONE);
mAccountListContainer.setVisibility(View.GONE);
chosenAccountView.setEnabled(false);
return;
}
chosenAccountView.setEnabled(true);
mExpandAccountBoxIndicator.setVisibility(View.VISIBLE);
chosenAccountView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mAccountBoxExpanded = !mAccountBoxExpanded;
setupAccountBoxToggle();
}
});
setupAccountBoxToggle();
populateAccountList(accounts);
}