本文整理匯總了Java中com.google.android.gms.plus.model.people.Person類的典型用法代碼示例。如果您正苦於以下問題:Java Person類的具體用法?Java Person怎麽用?Java Person使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Person類屬於com.google.android.gms.plus.model.people包,在下文中一共展示了Person類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getProfileInformation
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
/**
* Fetching user's information name, email, profile pic
* */
private void getProfileInformation() {
ringProgressDialog.dismiss();
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi
.getCurrentPerson(mGoogleApiClient);
String personName = currentPerson.getDisplayName();
String personPhotoUrl = currentPerson.getImage().getUrl();
String personGooglePlusProfile = currentPerson.getUrl();
String birth = currentPerson.getBirthday();
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
// by default the profile url gives 50x50 px image only
// we can replace the value with whatever dimension we want by
// replacing sz=X
// personPhotoUrl = personPhotoUrl.substring(0,
// personPhotoUrl.length() - 2)
// + PROFILE_PIC_SIZE;
//new LoadProfileImage().execute(personPhotoUrl);
} else {
Toast.makeText(getApplicationContext(),
"Person information is null", Toast.LENGTH_LONG).show();
}
}
示例2: onConnected
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
@Override
public void onConnected(Bundle bundle) {
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
User user = new User();
user.setProvider(PROVIDER_NAME);
user.setProviderDisplayName("Google+");
user.setUserId(currentPerson.getId());
user.setUserName(currentPerson.getId());
user.setFirstName(currentPerson.getName().getGivenName());
user.setLastName(currentPerson.getName().getFamilyName());
user.setDisplayName(currentPerson.getDisplayName());
user.setMail(Plus.AccountApi.getAccountName(mGoogleApiClient));
this.mUserHelper.setCurrentUser(user);
if (this.mUserSessionCallback != null) {
this.mUserSessionCallback.onLogin();
}
}
示例3: onConnected
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
@Override
public void onConnected(Bundle bundle) {
updateConnectButtonState();
setProgressBarVisible(false);
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
User user = new User();
user.setProvider(PROVIDER_NAME);
user.setProviderDisplayName("Google+");
user.setUserId(currentPerson.getId());
user.setUserName(currentPerson.getId());
user.setFirstName(currentPerson.getName().getGivenName());
user.setLastName(currentPerson.getName().getFamilyName());
user.setDisplayName(currentPerson.getDisplayName());
this.mUserHelper.setCurrentUser(user);
if (this.mUserSessionCallback != null) {
this.mUserSessionCallback.onLogin();
}
onPlusClientSignIn();
}
示例4: onResult
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
@Override
public void onResult(@NonNull People.LoadPeopleResult loadPeopleResult) {
try {
if (loadPeopleResult.getStatus().isSuccess()) {
for (Person person : loadPeopleResult.getPersonBuffer()) {
mContacts.put(person.getId(), new Contact(person));
}
if (!TextUtils.isEmpty(loadPeopleResult.getNextPageToken())) {
Plus.PeopleApi.loadVisible(mGoogleApiClient, loadPeopleResult.getNextPageToken())
.setResultCallback(this);
return;
}
mUiHandler.sendEmptyMessage(MSG_CIRCLES_LOADED);
return;
}
Toast.makeText(DebtsListActivity.this, R.string.cannot_load_circles, Toast.LENGTH_SHORT).show();
} finally {
loadPeopleResult.release();
}
}
示例5: authComplete
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
private void authComplete(String token) {
if (token != null) {
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
String name = currentPerson.getDisplayName();
String image = currentPerson.getImage().getUrl();
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
/** Add additional logic here if you want to restrict access to subset of users **/
MobilizerApp.get().getUser().setName(name);
MobilizerApp.get().getUser().setEmail(email);
MobilizerApp.get().getUser().setImageUrl(image);
MobilizerApp.get().getUser().setAccessToken(token);
Intent home = new Intent(AuthActivity.this, HomeActivity.class);
startActivityForResult(home, RC_LOGOUT);
} else {
mSignInLayout.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.GONE);
}
} else {
mSignInLayout.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.GONE);
}
}
示例6: onConnected
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
@Override
public void onConnected(Bundle bundle) {
mSignInButton.setEnabled(false);
Timber.d("onConnected - Getting user details");
String accountName = Plus.AccountApi.getAccountName(mGoogleApiClient);
Person currentUser = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
UserDetails userDetails = UserDetails.builder()
.accountName(accountName)
.googlePlusId(currentUser.getId())
.displayName(currentUser.getDisplayName())
.firstName(currentUser.getName().getGivenName())
.lastName(currentUser.getName().getFamilyName())
.profileImage(currentUser.getImage().getUrl())
.build();
signIn(userDetails);
mSignInProgress = STATE_DEFAULT;
}
示例7: loadUserInfo
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
@Override
public void loadUserInfo() {
//Gdx.app.log(TAG, "Get Player Info : " + isSignedIn());
if (isSignedIn()) {
waitingToGetPlayerInfo = false;
Person person = Plus.PeopleApi.getCurrentPerson(gameHelper.getApiClient());
if(person != null){
try {
CurrentUser.getInstance().init(person.getDisplayName(), person.getImage().getUrl());
}catch (Exception e){
System.out.println(e.getStackTrace());
}
}
} else {
waitingToGetPlayerInfo = true;
//gameHelper.beginUserInitiatedSignIn();
}
}
示例8: get
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
/**
* Retrieve a {@link it.rainbowbreeze.playtog.domain.Player} from a Google+ user
*
* @param googleApiClient
* @param userId
* @return
*/
public Player get(GoogleApiClient googleApiClient, String userId) {
mLogFacility.v(LOG_TAG, "Retrieving G+ user for id " + userId);
People.LoadPeopleResult peopleResult = Plus.PeopleApi.load(googleApiClient, userId).await();
PersonBuffer personBuffer = peopleResult.getPersonBuffer();
Person person = null;
Player player = null;
if (personBuffer.getCount() > 0) {
person = personBuffer.get(0);
if (null != person) {
// Adds the person to the provider
player = Player.createFrom(person);
}
}
personBuffer.close();
if (null == person) {
mLogFacility.v(LOG_TAG, "Cannot find any public G+ profile");
}
return player;
}
示例9: createFrom
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
public static Player createFrom(Person person) {
if (null == person) return null;
Player player = new Player();
player.setBackendId("");
if (!TextUtils.isEmpty(person.getDisplayName())) {
player.setName(person.getDisplayName());
} else if (null != person.getName() && !TextUtils.isEmpty(person.getName().toString())) {
player.setName(person.getName().toString());
} else if (!TextUtils.isEmpty(person.getNickname())) {
player.setName(person.getNickname());
} else {
player.setName("Unknown name");
}
if (null != person.getImage()) {
player.setPictureUrl(person.getImage().getUrl());
//Workaround to obtain larger profile picture
player.setPictureUrl(player.getPictureUrl().replace("?sz=50", "?sz=300"));
}
player
.setSelected(false)
.setSocialId(person.getId());
return player;
}
示例10: onConnected
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
@Override
public void onConnected(Bundle bundle) {
if (!mClearingAccounts) {
String email = Plus.AccountApi.getAccountName(google);
Person person = Plus.PeopleApi.getCurrentPerson(google);
if (person != null) {
String personName = person.getDisplayName();
Person.Image avatar = person.getImage();
String photoURL = "false";
if (person.hasImage() && avatar.hasUrl()) {
photoURL = avatar.getUrl().split("\\?")[0];
}
OUser user = new OUser();
user.setUsername(email);
user.setPassword("odoo_mobile_shop_google_user");
user.setName(personName);
user.setAvatar(photoURL);
user.setDatabase(OConstants.publicUser().getDatabase());
new AccountCreator().execute(user);
}
} else {
Plus.AccountApi.clearDefaultAccount(google);
mClearingAccounts = false;
}
}
示例11: setProfileInfo
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
public void setProfileInfo() {
if (!mGoogleApiClient.isConnected()
|| Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) == null) {
((ImageView) getView().findViewById(R.id.avatar))
.setImageDrawable(null);
((TextView) getView().findViewById(R.id.display_name))
.setText(R.string.not_signed_in);
} else {
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
if (currentPerson.hasImage()) {
mImageFetcher.loadImage(currentPerson.getImage().getUrl(),
((ImageView) getView().findViewById(R.id.avatar)));
}
if (currentPerson.hasDisplayName()) {
((TextView) getView().findViewById(R.id.display_name))
.setText(currentPerson.getDisplayName());
}
}
}
示例12: build
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
public UserProfile build() {
UserProfile newUserProfile = new UserProfile();
String email = Plus.AccountApi.getAccountName(googleApiClient);
newUserProfile.setEmail(email);
if (Plus.PeopleApi.getCurrentPerson(googleApiClient) != null) {
Person currentPerson = Plus.PeopleApi.getCurrentPerson(googleApiClient);
newUserProfile.setUserName(currentPerson.getDisplayName());
newUserProfile.setFirstName(currentPerson.getName().getGivenName());
newUserProfile.setLastName(currentPerson.getName().getFamilyName());
newUserProfile.setImageURL(currentPerson.getImage().getUrl());
return (newUserProfile);
}
return null;
}
示例13: getProfileInformation
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
public void getProfileInformation() {
Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
Person currentPerson = Plus.PeopleApi
.getCurrentPerson(mGoogleApiClient);
String personName = currentPerson.getDisplayName();
String personPhotoUrl = currentPerson.getImage().getUrl();
String personGooglePlusProfile = currentPerson.getUrl();
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
textView_name.setText(personName);
textView_email.setText(email);
// by default the profile url gives 50x50 px image only
// we can replace the value with whatever dimension we want by
// replacing sz=X
personPhotoUrl = personPhotoUrl.substring(0,
personPhotoUrl.length() - 2)
+ 400;
new LoadProfileImage(imageView_profile_image).execute(personPhotoUrl);
Toast.makeText(getApplicationContext(),
"Information is loaded", Toast.LENGTH_LONG).show();
}
示例14: getProfileInformation2
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
public void getProfileInformation2() {
Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
Person currentPerson = Plus.PeopleApi
.getCurrentPerson(mGoogleApiClient);
String personName = currentPerson.getDisplayName();
String personPhotoUrl = currentPerson.getImage().getUrl();
String personGooglePlusProfile = currentPerson.getUrl();
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
Drawer_textView_name.setText(personName);
drawer_textView_email.setText(email);
// by default the profile url gives 50x50 px image only
// we can replace the value with whatever dimension we want by
// replacing sz=X
personPhotoUrl = personPhotoUrl.substring(0,
personPhotoUrl.length() - 2)
+ 400;
new LoadProfileImage3(drawerImageProfile).execute(personPhotoUrl);
Toast.makeText(getApplicationContext(),
"Information is loaded in Nav_drawer", Toast.LENGTH_LONG).show();
}
示例15: getProfileInformation
import com.google.android.gms.plus.model.people.Person; //導入依賴的package包/類
/**
* Fetching user's information name, email, profile pic
*/
private void getProfileInformation() {
try {
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi
.getCurrentPerson(mGoogleApiClient);
String personName = currentPerson.getDisplayName();
String[] wholeName = personName.split(" ", 2);
String firstName = wholeName[0];
String lastName = wholeName[1];
String personGooglePlusProfile = currentPerson.getUrl();
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
new SocialLoginTask(LoginFragment.this, getActivity())
.execute("google",
firstName,
lastName,
personGooglePlusProfile,
email);
} else {
Toast.makeText(mContext,
"Person information is null", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}