/** * Synchronously executes the remote operation * * Do not call this method from the main thread. * * @param client Client object to reach an ownCloud server during the execution of * the operation. * @return Result of the operation. */ public RemoteOperationResult<T> execute(OkHttpClient client, Context context) { if (client == null) throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " + "OwnCloudClient"); mHttpClient = client; mContext = context; return runOperation(); }
/** * Synchronously executes the remote operation on the received ownCloud account. * * Do not call this method from the main thread. * * This method should be used whenever an ownCloud account is available, instead of * {@link #execute(OwnCloudClient)}. * * @param account ownCloud account in remote ownCloud server to reach during the * execution of the operation. * @param context Android context for the component calling the method. * @return Result of the operation. */ public RemoteOperationResult<T> execute(Account account, Context context) { if (account == null) throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " + "Account"); if (context == null) throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " + "Context"); mAccount = account; mContext = context.getApplicationContext(); return runOperation(); }
/** * Asynchronous execution of the operation * started by {@link RemoteOperation#execute(OwnCloudClient, * OnRemoteOperationListener, Handler)}, * and result posting. */ @Override public final void run() { final RemoteOperationResult resultToSend = runOperation(); if (mAccount != null && mContext != null) { // Save Client Cookies AccountUtils.saveClient(mClient, mAccount, mContext); } if (mListenerHandler != null && mListener != null) { mListenerHandler.post(() -> mListener.onRemoteOperationFinish(RemoteOperation.this, resultToSend)); } else if (mListener != null) { mListener.onRemoteOperationFinish(RemoteOperation.this, resultToSend); } } }
/** * Synchronously executes the remote operation * * Do not call this method from the main thread. * * @param client Client object to reach an ownCloud server during the execution of * the operation. * @return Result of the operation. */ public RemoteOperationResult<T> execute(OwnCloudClient client) { if (client == null) throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " + "OwnCloudClient"); mClient = client; if (client.getAccount() != null) { mAccount = client.getAccount().getSavedAccount(); } mContext = client.getContext(); return runOperation(); }