mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 21:25:35 +03:00
Merge pull request #13345 from nextcloud/npe-check-dispatchResultToOperationListeners
Check Nullability of mOperationsBinder
This commit is contained in:
commit
38cbae1724
1 changed files with 11 additions and 10 deletions
|
@ -775,23 +775,24 @@ public class OperationsService extends Service {
|
|||
* @param operation Finished operation.
|
||||
* @param result Result of the operation.
|
||||
*/
|
||||
protected void dispatchResultToOperationListeners(
|
||||
final RemoteOperation operation, final RemoteOperationResult result
|
||||
) {
|
||||
protected void dispatchResultToOperationListeners(final RemoteOperation operation, final RemoteOperationResult result) {
|
||||
int count = 0;
|
||||
Iterator<OnRemoteOperationListener> listeners = mOperationsBinder.mBoundListeners.keySet().iterator();
|
||||
while (listeners.hasNext()) {
|
||||
final OnRemoteOperationListener listener = listeners.next();
|
||||
final Handler handler = mOperationsBinder.mBoundListeners.get(listener);
|
||||
if (handler != null) {
|
||||
handler.post(() -> listener.onRemoteOperationFinish(operation, result));
|
||||
count += 1;
|
||||
|
||||
if (mOperationsBinder != null) {
|
||||
for (OnRemoteOperationListener listener : mOperationsBinder.mBoundListeners.keySet()) {
|
||||
final Handler handler = mOperationsBinder.mBoundListeners.get(listener);
|
||||
if (handler != null) {
|
||||
handler.post(() -> listener.onRemoteOperationFinish(operation, result));
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
Pair<RemoteOperation, RemoteOperationResult> undispatched = new Pair<>(operation, result);
|
||||
mUndispatchedFinishedOperations.put(operation.hashCode(), undispatched);
|
||||
}
|
||||
|
||||
Log_OC.d(TAG, "Called " + count + " listeners");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue