diff --git a/src/com/owncloud/android/lib/common/operations/RemoteOperation.java b/src/com/owncloud/android/lib/common/operations/RemoteOperation.java index 4943dd41..bb8ea421 100644 --- a/src/com/owncloud/android/lib/common/operations/RemoteOperation.java +++ b/src/com/owncloud/android/lib/common/operations/RemoteOperation.java @@ -224,7 +224,7 @@ public abstract class RemoteOperation implements Runnable { * @param client Client object to reach an ownCloud server * during the execution of the operation. * @param listener Listener to be notified about the execution of the operation. - * @param listenerHandler Handler associated to the thread where the methods of + * @param listenerHandler Handler, if passed in, associated to the thread where the methods of * the listener objects must be called. * @return Thread were the remote operation is executed. */ @@ -243,18 +243,17 @@ public abstract class RemoteOperation implements Runnable { } mListener = listener; - if (listenerHandler == null) { - throw new IllegalArgumentException - ("Trying to execute a remote operation asynchronously " + - "without a handler to the listener's thread"); + if (listenerHandler != null) { + mListenerHandler = listenerHandler; } - mListenerHandler = listenerHandler; + Thread runnerThread = new Thread(this); runnerThread.start(); return runnerThread; } - + + /** * Asynchronous execution of the operation * started by {@link RemoteOperation#execute(OwnCloudClient, @@ -347,6 +346,9 @@ public abstract class RemoteOperation implements Runnable { } }); } + else if(mListener != null) { + mListener.onRemoteOperationFinish(RemoteOperation.this, resultToSend); + } }