From 945a250609fab0afe3ff49349193f478ebc28bab Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Mon, 11 Jan 2016 17:56:44 +0100 Subject: [PATCH] * add new method to get selected items FIX #18 --- .../java/com/mikepenz/fastadapter/FastAdapter.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/library/src/main/java/com/mikepenz/fastadapter/FastAdapter.java b/library/src/main/java/com/mikepenz/fastadapter/FastAdapter.java index 3c36eb81d..83c1b5620 100644 --- a/library/src/main/java/com/mikepenz/fastadapter/FastAdapter.java +++ b/library/src/main/java/com/mikepenz/fastadapter/FastAdapter.java @@ -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; @@ -466,6 +467,17 @@ public Set getSelections() { return mSelections; } + /** + * @return a set with the items which are currently selected + */ + public Set getSelectedItems() { + Set items = new HashSet<>(); + for (Integer position : getSelections()) { + items.add(getItem(position)); + } + return items; + } + /** * toggles the selection of the item at the given position *