Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
Tobias Kaminsky 2024-08-01 02:32:52 +02:00
commit 288dd1ea42

View file

@ -775,23 +775,24 @@ public class OperationsService extends Service {
* @param operation Finished operation. * @param operation Finished operation.
* @param result Result of the operation. * @param result Result of the operation.
*/ */
protected void dispatchResultToOperationListeners( protected void dispatchResultToOperationListeners(final RemoteOperation operation, final RemoteOperationResult result) {
final RemoteOperation operation, final RemoteOperationResult result
) {
int count = 0; int count = 0;
Iterator<OnRemoteOperationListener> listeners = mOperationsBinder.mBoundListeners.keySet().iterator();
while (listeners.hasNext()) { if (mOperationsBinder != null) {
final OnRemoteOperationListener listener = listeners.next(); for (OnRemoteOperationListener listener : mOperationsBinder.mBoundListeners.keySet()) {
final Handler handler = mOperationsBinder.mBoundListeners.get(listener); final Handler handler = mOperationsBinder.mBoundListeners.get(listener);
if (handler != null) { if (handler != null) {
handler.post(() -> listener.onRemoteOperationFinish(operation, result)); handler.post(() -> listener.onRemoteOperationFinish(operation, result));
count += 1; count += 1;
}
} }
} }
if (count == 0) { if (count == 0) {
Pair<RemoteOperation, RemoteOperationResult> undispatched = new Pair<>(operation, result); Pair<RemoteOperation, RemoteOperationResult> undispatched = new Pair<>(operation, result);
mUndispatchedFinishedOperations.put(operation.hashCode(), undispatched); mUndispatchedFinishedOperations.put(operation.hashCode(), undispatched);
} }
Log_OC.d(TAG, "Called " + count + " listeners"); Log_OC.d(TAG, "Called " + count + " listeners");
} }
} }