package com.bignerdranch.android.criminalintent;

import android.support.v7.widget.SelectableHolder;
import android.util.SparseBooleanArray;

public class Multiselector {
    private SparseBooleanArray mSelections = new SparseBooleanArray();
    private WeakHolderTracker mTracker = new WeakHolderTracker();

    private boolean mIsSelectable;

    public void setSelectable(boolean isSelectable) {
        mIsSelectable = isSelectable;
        refreshAllHolders();
    }

    public boolean isSelectable() {
        return mIsSelectable;
    }

    private void refreshAllHolders() {
        for (SelectableHolder holder : mTracker.getTrackedHolders()) {
            refreshHolder(holder);
        }
    }

    private void refreshHolder(SelectableHolder holder) {
        if (holder == null) {
            return;
        }
        holder.setSelectable(mIsSelectable);
        holder.setActivated(mSelections.get(holder.getPosition()));
    }

    public boolean isSelected(int position, long id) {
        return mSelections.get(position);
    }

    public void setSelected(int position, long id, boolean isSelected) {
        mSelections.put(position, isSelected);
        refreshHolder(mTracker.getHolder(position));
    }

    public void clearSelections() {
        mSelections.clear();
        refreshAllHolders();
    }

    public void bindHolder(SelectableHolder holder, int position, long id) {
        mTracker.bindHolder(holder, position);
        refreshHolder(holder);
    }
}

@@ -135,16 +135,68 @@
 Array;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 public c
@@ -1391,151 +1391,1060 @@
 lic 
-void bindHolder(SelectableHolder holder, int position, long id) %7B%0A        mTracker.bindHolder(holder, position);%0A        refreshHolder(holder);
+List%3CInteger%3E getSelectedPositions() %7B%0A        List%3CInteger%3E positions = new ArrayList%3CInteger%3E();%0A%0A        for (int i = 0; i %3C mSelections.size(); i++) %7B%0A            if (mSelections.valueAt(i)) %7B%0A                positions.add(mSelections.keyAt(i));%0A            %7D%0A        %7D%0A%0A        return positions;%0A    %7D%0A%0A    public void bindHolder(SelectableHolder holder, int position, long id) %7B%0A        mTracker.bindHolder(holder, position);%0A        refreshHolder(holder);%0A    %7D%0A%0A    public void setSelected(SelectableHolder holder, boolean isSelected) %7B%0A        setSelected(holder.getPosition(), holder.getItemId(), isSelected);%0A    %7D%0A%0A    public boolean tapSelection(SelectableHolder holder) %7B%0A        return tapSelection(holder.getPosition(), holder.getItemId());%0A    %7D%0A%0A    private boolean tapSelection(int position, long itemId) %7B%0A        if (mIsSelectable) %7B%0A            boolean isSelected = isSelected(position, itemId);%0A            setSelected(position, itemId, !isSelected);%0A            return true;%0A        %7D else %7B%0A            return false;%0A        %7D%0A
 %0A   

Add method to get all selections.