Skip to content

Commit

Permalink
* add new method to get selected items
Browse files Browse the repository at this point in the history
FIX #18
  • Loading branch information
mikepenz committed Jan 11, 2016
1 parent 745ef7f commit 945a250
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions library/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import com.mikepenz.fastadapter.utils.AdapterUtil;

import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -466,6 +467,17 @@ public Set<Integer> getSelections() {
return mSelections;
}

/**
* @return a set with the items which are currently selected
*/
public Set<Item> getSelectedItems() {
Set<Item> items = new HashSet<>();
for (Integer position : getSelections()) {
items.add(getItem(position));
}
return items;
}

/**
* toggles the selection of the item at the given position
*
Expand Down

0 comments on commit 945a250

Please sign in to comment.