Search in sources :

Example 6 with NextcloudClient

use of com.nextcloud.common.NextcloudClient 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);
    }
}
Also used : NextcloudClient(com.nextcloud.common.NextcloudClient) UserInfo(com.owncloud.android.lib.common.UserInfo)

Example 7 with NextcloudClient

use of com.nextcloud.common.NextcloudClient in project android by nextcloud.

the class RetrieveHoverCardAsyncTask method doInBackground.

@Override
protected HoverCard doInBackground(Void... voids) {
    try {
        NextcloudClient client = clientFactory.createNextcloudClient(user);
        RemoteOperationResult<HoverCard> result = new GetHoverCardRemoteOperation(userId).execute(client);
        if (result.isSuccess()) {
            return result.getResultData();
        } else {
            return null;
        }
    } catch (ClientFactory.CreationException | NullPointerException e) {
        return null;
    }
}
Also used : GetHoverCardRemoteOperation(com.nextcloud.android.lib.resources.profile.GetHoverCardRemoteOperation) NextcloudClient(com.nextcloud.common.NextcloudClient) HoverCard(com.nextcloud.android.lib.resources.profile.HoverCard)

Example 8 with NextcloudClient

use of com.nextcloud.common.NextcloudClient in project android by nextcloud.

the class RetrieveStatusAsyncTask method doInBackground.

@Override
protected com.owncloud.android.lib.resources.users.Status doInBackground(Void... voids) {
    try {
        NextcloudClient client = clientFactory.createNextcloudClient(user);
        RemoteOperationResult<com.owncloud.android.lib.resources.users.Status> result = new GetStatusRemoteOperation().execute(client);
        if (result.isSuccess()) {
            return result.getResultData();
        } else {
            return new com.owncloud.android.lib.resources.users.Status(StatusType.OFFLINE, "", "", -1);
        }
    } catch (ClientFactory.CreationException | NullPointerException e) {
        return new com.owncloud.android.lib.resources.users.Status(StatusType.OFFLINE, "", "", -1);
    }
}
Also used : Status(com.owncloud.android.lib.resources.users.Status) GetStatusRemoteOperation(com.owncloud.android.lib.resources.users.GetStatusRemoteOperation) NextcloudClient(com.nextcloud.common.NextcloudClient) Status(com.owncloud.android.lib.resources.users.Status)

Aggregations

NextcloudClient (com.nextcloud.common.NextcloudClient)8 UserInfo (com.owncloud.android.lib.common.UserInfo)5 GetUserInfoRemoteOperation (com.owncloud.android.lib.resources.users.GetUserInfoRemoteOperation)4 AuthenticatorException (android.accounts.AuthenticatorException)2 OperationCanceledException (android.accounts.OperationCanceledException)2 Context (android.content.Context)2 IOException (java.io.IOException)2 Account (android.accounts.Account)1 Uri (android.net.Uri)1 Gson (com.google.gson.Gson)1 GetHoverCardRemoteOperation (com.nextcloud.android.lib.resources.profile.GetHoverCardRemoteOperation)1 HoverCard (com.nextcloud.android.lib.resources.profile.HoverCard)1 User (com.nextcloud.client.account.User)1 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)1 OwnCloudClient (com.owncloud.android.lib.common.OwnCloudClient)1 OwnCloudCredentials (com.owncloud.android.lib.common.OwnCloudCredentials)1 Quota (com.owncloud.android.lib.common.Quota)1 AccountUtils (com.owncloud.android.lib.common.accounts.AccountUtils)1 RedirectionPath (com.owncloud.android.lib.common.network.RedirectionPath)1 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)1