Search in sources :

Example 26 with RemoteOperation

use of com.owncloud.android.lib.common.operations.RemoteOperation in project android by nextcloud.

the class UpdateNoteForShareOperation method run.

@Override
protected RemoteOperationResult run(OwnCloudClient client) {
    OCShare share = getStorageManager().getShareById(shareId);
    if (share == null) {
        return new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
    }
    UpdateShareRemoteOperation updateOperation = new UpdateShareRemoteOperation(share.getRemoteId());
    updateOperation.setNote(note);
    RemoteOperationResult result = updateOperation.execute(client);
    if (result.isSuccess()) {
        RemoteOperation getShareOp = new GetShareRemoteOperation(share.getRemoteId());
        result = getShareOp.execute(client);
        if (result.isSuccess()) {
            getStorageManager().saveShare((OCShare) result.getData().get(0));
        }
    }
    return result;
}
Also used : UpdateShareRemoteOperation(com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation) GetShareRemoteOperation(com.owncloud.android.lib.resources.shares.GetShareRemoteOperation) UpdateShareRemoteOperation(com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation) RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) GetShareRemoteOperation(com.owncloud.android.lib.resources.shares.GetShareRemoteOperation) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) OCShare(com.owncloud.android.lib.resources.shares.OCShare)

Example 27 with RemoteOperation

use of com.owncloud.android.lib.common.operations.RemoteOperation in project android by nextcloud.

the class OCFileListFragment method handleSearchEvent.

private void handleSearchEvent(SearchEvent event) {
    if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == event.getSearchType()) {
        return;
    }
    prepareCurrentSearch(event);
    searchFragment = true;
    setEmptyListLoadingMessage();
    mAdapter.setData(new ArrayList<>(), SearchType.NO_SEARCH, mContainerActivity.getStorageManager(), mFile, true);
    setFabVisible(false);
    Runnable switchViewsRunnable = () -> {
        if (isGridViewPreferred(mFile) && !isGridEnabled()) {
            switchToGridView();
        } else if (!isGridViewPreferred(mFile) && isGridEnabled()) {
            switchToListView();
        }
    };
    new Handler(Looper.getMainLooper()).post(switchViewsRunnable);
    final User currentUser = accountManager.getUser();
    final RemoteOperation remoteOperation;
    if (currentSearchType != SearchType.SHARED_FILTER) {
        boolean searchOnlyFolders = false;
        if (getArguments() != null && getArguments().getBoolean(ARG_SEARCH_ONLY_FOLDER, false)) {
            searchOnlyFolders = true;
        }
        OCCapability ocCapability = mContainerActivity.getStorageManager().getCapability(currentUser.getAccountName());
        remoteOperation = new SearchRemoteOperation(event.getSearchQuery(), event.getSearchType(), searchOnlyFolders, ocCapability);
    } else {
        remoteOperation = new GetSharesRemoteOperation();
    }
    remoteOperationAsyncTask = new AsyncTask<Void, Void, Boolean>() {

        @Override
        protected Boolean doInBackground(Void... voids) {
            setTitle();
            if (getContext() != null && !isCancelled()) {
                RemoteOperationResult remoteOperationResult = remoteOperation.execute(currentUser.toPlatformAccount(), getContext());
                FileDataStorageManager storageManager = null;
                if (mContainerActivity != null && mContainerActivity.getStorageManager() != null) {
                    storageManager = mContainerActivity.getStorageManager();
                }
                if (remoteOperationResult.isSuccess() && remoteOperationResult.getResultData() != null && !isCancelled() && searchFragment) {
                    searchEvent = event;
                    if (remoteOperationResult.getResultData() == null || ((List) remoteOperationResult.getResultData()).isEmpty()) {
                        setEmptyView(event);
                    } else {
                        mAdapter.setData(((RemoteOperationResult<List>) remoteOperationResult).getResultData(), currentSearchType, storageManager, mFile, true);
                    }
                    final ToolbarActivity fileDisplayActivity = (ToolbarActivity) getActivity();
                    if (fileDisplayActivity != null) {
                        fileDisplayActivity.runOnUiThread(() -> {
                            if (fileDisplayActivity != null) {
                                setLoading(false);
                            }
                        });
                    }
                }
                return remoteOperationResult.isSuccess();
            } else {
                return Boolean.FALSE;
            }
        }

        @Override
        protected void onPostExecute(Boolean bool) {
            if (!isCancelled()) {
                mAdapter.notifyDataSetChanged();
            }
        }
    };
    remoteOperationAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : ToolbarActivity(com.owncloud.android.ui.activity.ToolbarActivity) ToggleEncryptionRemoteOperation(com.owncloud.android.lib.resources.e2ee.ToggleEncryptionRemoteOperation) RichWorkspaceDirectEditingRemoteOperation(com.nextcloud.android.lib.richWorkspace.RichWorkspaceDirectEditingRemoteOperation) GetSharesRemoteOperation(com.owncloud.android.lib.resources.shares.GetSharesRemoteOperation) ToggleFavoriteRemoteOperation(com.owncloud.android.lib.resources.files.ToggleFavoriteRemoteOperation) SearchRemoteOperation(com.owncloud.android.lib.resources.files.SearchRemoteOperation) RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) User(com.nextcloud.client.account.User) OCCapability(com.owncloud.android.lib.resources.status.OCCapability) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) Handler(android.os.Handler) SearchRemoteOperation(com.owncloud.android.lib.resources.files.SearchRemoteOperation) GetSharesRemoteOperation(com.owncloud.android.lib.resources.shares.GetSharesRemoteOperation) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) ArrayList(java.util.ArrayList) List(java.util.List)

Example 28 with RemoteOperation

use of com.owncloud.android.lib.common.operations.RemoteOperation in project android by nextcloud.

the class FolderPickerActivity method startSyncFolderOperation.

public void startSyncFolderOperation(OCFile folder, boolean ignoreETag) {
    long currentSyncTime = System.currentTimeMillis();
    mSyncInProgress = true;
    // perform folder synchronization
    RemoteOperation refreshFolderOperation = new RefreshFolderOperation(folder, currentSyncTime, false, ignoreETag, getStorageManager(), getUser().orElseThrow(RuntimeException::new), getApplicationContext());
    refreshFolderOperation.execute(getAccount(), this, null, null);
    getListOfFilesFragment().setLoading(true);
    setBackgroundText();
}
Also used : RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) RefreshFolderOperation(com.owncloud.android.operations.RefreshFolderOperation)

Example 29 with RemoteOperation

use of com.owncloud.android.lib.common.operations.RemoteOperation in project android by nextcloud.

the class NotificationsActivity method fetchAndSetData.

private void fetchAndSetData() {
    Thread t = new Thread(() -> {
        initializeAdapter();
        RemoteOperation getRemoteNotificationOperation = new GetNotificationsRemoteOperation();
        final RemoteOperationResult result = getRemoteNotificationOperation.execute(client);
        if (result.isSuccess() && result.getNotificationData() != null) {
            final List<Notification> notifications = result.getNotificationData();
            runOnUiThread(() -> populateList(notifications));
        } else {
            Log_OC.d(TAG, result.getLogMessage());
            // show error
            runOnUiThread(() -> setEmptyContent(getString(R.string.notifications_no_results_headline), result.getLogMessage()));
        }
        hideRefreshLayoutLoader();
    });
    t.start();
}
Also used : RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) GetNotificationsRemoteOperation(com.owncloud.android.lib.resources.notifications.GetNotificationsRemoteOperation) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) GetNotificationsRemoteOperation(com.owncloud.android.lib.resources.notifications.GetNotificationsRemoteOperation) Notification(com.owncloud.android.lib.resources.notifications.models.Notification)

Example 30 with RemoteOperation

use of com.owncloud.android.lib.common.operations.RemoteOperation in project android by nextcloud.

the class ReceiveExternalFilesActivity method startSyncFolderOperation.

private void startSyncFolderOperation(OCFile folder) {
    long currentSyncTime = System.currentTimeMillis();
    mSyncInProgress = true;
    // perform folder synchronization
    RemoteOperation syncFolderOp = new RefreshFolderOperation(folder, currentSyncTime, false, false, getStorageManager(), getUser().orElseThrow(RuntimeException::new), getApplicationContext());
    syncFolderOp.execute(getAccount(), this, null, null);
}
Also used : RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) RefreshFolderOperation(com.owncloud.android.operations.RefreshFolderOperation)

Aggregations

RemoteOperation (com.owncloud.android.lib.common.operations.RemoteOperation)31 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)24 Account (android.accounts.Account)7 OCFile (com.owncloud.android.datamodel.OCFile)7 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)7 Pair (android.util.Pair)6 OCShare (com.owncloud.android.lib.resources.shares.OCShare)6 ArrayList (java.util.ArrayList)6 RefreshFolderOperation (com.owncloud.android.operations.RefreshFolderOperation)5 Handler (android.os.Handler)4 ExistenceCheckRemoteOperation (com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation)4 GetUserInfoRemoteOperation (com.owncloud.android.lib.resources.users.GetUserInfoRemoteOperation)4 User (com.nextcloud.client.account.User)3 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)3 ReadFileRemoteOperation (com.owncloud.android.lib.resources.files.ReadFileRemoteOperation)3 RestoreFileVersionRemoteOperation (com.owncloud.android.lib.resources.files.RestoreFileVersionRemoteOperation)3 SearchRemoteOperation (com.owncloud.android.lib.resources.files.SearchRemoteOperation)3 GetShareRemoteOperation (com.owncloud.android.lib.resources.shares.GetShareRemoteOperation)3 UpdateShareRemoteOperation (com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation)3 AuthenticatorException (android.accounts.AuthenticatorException)2