// Path: gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/threading/BackgroundDiffUtilWorker.java
// @AllArgsConstructor
// public final class BackgroundDiffUtilWorker implements Runnable {
// 
//     private final List<? extends IGenericRecyclerViewLayout> mOldDataSet;
//     private final List<? extends IGenericRecyclerViewLayout> mNewDataSet;
//     private final Context mContext;
//     private final GenericMultipleLayoutAdapter mAdapter;
// 
//     /** {@inheritDoc} */
//     @WorkerThread
//     @Override
//     public void run() {
//         final DiffUtil.DiffResult diffResult
//                 = DiffUtil.calculateDiff(new GmlrvaDiffCallback(this.mOldDataSet, this.mNewDataSet));
//         if (mContext != null) {
//             ((Activity) mContext).runOnUiThread(new UpdateUiDiffUtilResult(this.mNewDataSet, diffResult, mAdapter));
//         }
//     }
// 
// }
// 
// Path: gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/diff/GenericPayload.java
// public static final String UPDATE_ITEM = "UPDATE_ITEM";


import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
import android.support.v7.util.DiffUtil;
import android.support.v7.widget.RecyclerView;
import android.util.SparseArray;
import android.view.ViewGroup;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import pt.simdea.gmlrva.lib.threading.BackgroundDiffUtilWorker;
import static pt.simdea.gmlrva.lib.diff.GenericPayload.UPDATE_ITEM;
    private void skipQueuedUpdates() {
        if (mPendingUpdates.size() > 1) {
            /* More than one update queued */
            final List<? extends IGenericRecyclerViewLayout> lastList = mPendingUpdates.peekLast();
            mPendingUpdates.clear();
            mPendingUpdates.add(lastList);
        }
    }

    /**
     * Procedure meant to apply a given payload to this adapter's data set.
     * @param payloads the payload list object with the updates.
     * @param position the adapter's position to be updated.
     */
    private void applyPayloads(@NonNull final List<Object> payloads, final int position) {
        for (final Object payload : payloads) {
            if (payload instanceof Bundle) {
                applyBundledPayloads((Bundle) payloads.get(0), position);
            }
        }
    }

    /**
     * Procedure meant to apply a {@link DiffUtil} result payload to this adapter's data set.
     * @param bundledPayloads the {@link Bundle} list object with the updates.
     * @param position the adapter's position to be updated.
     */
    private void applyBundledPayloads(@Nullable final Bundle bundledPayloads, final int position) {
        if (bundledPayloads != null && bundledPayloads.keySet() != null) {
            for (final String key : bundledPayloads.keySet()) {
// Path: gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/threading/BackgroundDiffUtilWorker.java
// @AllArgsConstructor
// public final class BackgroundDiffUtilWorker implements Runnable {
// 
//     private final List<? extends IGenericRecyclerViewLayout> mOldDataSet;
//     private final List<? extends IGenericRecyclerViewLayout> mNewDataSet;
//     private final Context mContext;
//     private final GenericMultipleLayoutAdapter mAdapter;
// 
//     /** {@inheritDoc} */
//     @WorkerThread
//     @Override
//     public void run() {
//         final DiffUtil.DiffResult diffResult
//                 = DiffUtil.calculateDiff(new GmlrvaDiffCallback(this.mOldDataSet, this.mNewDataSet));
//         if (mContext != null) {
//             ((Activity) mContext).runOnUiThread(new UpdateUiDiffUtilResult(this.mNewDataSet, diffResult, mAdapter));
//         }
//     }
// 
// }
// 
// Path: gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/diff/GenericPayload.java
// public static final String UPDATE_ITEM = "UPDATE_ITEM";


// Path: gmlrva-lib/src/main/java/pt/simdea/gmlrva/lib/GenericMultipleLayoutAdapter.java
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
import android.support.v7.util.DiffUtil;
import android.support.v7.widget.RecyclerView;
import android.util.SparseArray;
import android.view.ViewGroup;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import pt.simdea.gmlrva.lib.threading.BackgroundDiffUtilWorker;
import static pt.simdea.gmlrva.lib.diff.GenericPayload.UPDATE_ITEM;

    private void skipQueuedUpdates() {
        if (mPendingUpdates.size() > 1) {
            /* More than one update queued */
            final List<? extends IGenericRecyclerViewLayout> lastList = mPendingUpdates.peekLast();
            mPendingUpdates.clear();
            mPendingUpdates.add(lastList);
        }
    }

    /**
     * Procedure meant to apply a given payload to this adapter's data set.
     * @param payloads the payload list object with the updates.
     * @param position the adapter's position to be updated.
     */
    private void applyPayloads(@NonNull final List<Object> payloads, final int position) {
        for (final Object payload : payloads) {
            if (payload instanceof Bundle) {
                applyBundledPayloads((Bundle) payloads.get(0), position);
            }
        }
    }

    /**
     * Procedure meant to apply a {@link DiffUtil} result payload to this adapter's data set.
     * @param bundledPayloads the {@link Bundle} list object with the updates.
     * @param position the adapter's position to be updated.
     */
    private void applyBundledPayloads(@Nullable final Bundle bundledPayloads, final int position) {
        if (bundledPayloads != null && bundledPayloads.keySet() != null) {
            for (final String key : bundledPayloads.keySet()) {
                if (UPDATE_ITEM.equals(key)) {