use of com.owncloud.android.lib.common.UserInfo in project android by nextcloud.
the class GetUserProfileOperation method run.
/**
* Performs the operation.
*
* Target user account is implicit in 'client'.
*
* Stored account is implicit in {@link #getStorageManager()}.
*
* @return Result of the operation. If successful, includes an instance of
* {@link String} with the display name retrieved from the server.
* Call {@link RemoteOperationResult#getData()}.get(0) to get it.
*/
@Override
public RemoteOperationResult<UserInfo> run(NextcloudClient client) {
// get display name
RemoteOperationResult<UserInfo> result = new GetUserInfoRemoteOperation().execute(client);
if (result.isSuccess()) {
// store display name with account data
AccountManager accountManager = AccountManager.get(MainApp.getAppContext());
UserInfo userInfo = result.getResultData();
Account storedAccount = getStorageManager().getUser().toPlatformAccount();
accountManager.setUserData(storedAccount, AccountUtils.Constants.KEY_DISPLAY_NAME, userInfo.getDisplayName());
}
return result;
}
use of com.owncloud.android.lib.common.UserInfo in project android by nextcloud.
the class RefreshFolderOperation method updateUserProfile.
private void updateUserProfile() {
try {
NextcloudClient nextcloudClient = OwnCloudClientFactory.createNextcloudClient(user.toPlatformAccount(), mContext);
RemoteOperationResult<UserInfo> result = new GetUserProfileOperation(mStorageManager).execute(nextcloudClient);
if (!result.isSuccess()) {
Log_OC.w(TAG, "Couldn't update user profile from server");
} else {
Log_OC.i(TAG, "Got display name: " + result.getResultData());
}
} catch (AccountUtils.AccountNotFoundException | NullPointerException e) {
Log_OC.e(this, "Error updating profile", e);
}
}
Aggregations