public void processNextInQueueMutation()

in aws-android-sdk-appsync/src/main/java/com/amazonaws/mobileconnectors/appsync/AppSyncOfflineMutationManager.java [146:195]


    public void processNextInQueueMutation() {

        //Check to make sure we do have network connectivity.
        final NetworkInfo info = ((ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();

        if (info == null || !info.isConnected()) {
            Log.v(TAG,"Thread:[" + Thread.currentThread().getId() +"]: Internet wasn't available. Exiting");
            return;
        }

        //Internet is available. Check if there is anything in the queue to process
        if (!persistentOfflineMutationManager.isQueueEmpty()) {
            if (queueHandler.setMutationInProgress()) {
                Log.d(TAG, "Thread:[" + Thread.currentThread().getId() +"]: Processing next from persistent queue");
                PersistentOfflineMutationObject p = persistentOfflineMutationManager.processNextMutationObject();
                //Tag this as being the currently executed mutation in the QueueHandler
                if ( p != null ) {
                    queueHandler.setPersistentOfflineMutationObjectBeingExecuted(p);
                }
            }
            return;
        }

        Log.v(TAG,"Thread:[" + Thread.currentThread().getId() +"]:Persistent mutations queue is EMPTY!. Will check inMemory Queue next");

        if (!inMemoryOfflineMutationManager.isQueueEmpty()) {
            if (queueHandler.setMutationInProgress()) {
                Log.v(TAG, "Thread:[" + Thread.currentThread().getId() + "]: Processing next from in Memory queue");
                currentMutation = inMemoryOfflineMutationManager.processNextMutation();
                if (currentMutation == null ) {
                    return;
                }

                //Tag this as being the currently executed mutation in the QueueHandler
                queueHandler.setInMemoryOfflineMutationObjectBeingExecuted( currentMutation);

                //If this mutation was already canceled, remove it from the queues and signal queueHandler to move on to the next one in the queue.
                if ( inMemoryOfflineMutationManager.getCancelledMutations().contains((Mutation) currentMutation.request.operation)) {
                    Log.v(TAG, "Thread:[" + Thread.currentThread().getId() + "]: Handling cancellation for mutation [" + currentMutation.recordIdentifier + "] ");
                    setInProgressMutationAsCompleted(currentMutation.recordIdentifier);
                    inMemoryOfflineMutationManager.removeCancelledMutation((Mutation) currentMutation.request.operation);
                    queueHandler.sendEmptyMessage(MessageNumberUtil.FAIL_EXEC);
                }
            }
        }
        else {
            Log.v(TAG, "Thread:[" + Thread.currentThread().getId() + "]: In Memory mutations queue was EMPTY!. Nothing to process, exiting");
        }
    }