@Override void toggleSelection(String id) { if (id != null) { if (selectedIds.contains(id)) { selectedIds.remove(id); } else { selectedIds.add(id); } } }
public List<T> getGraphObjectsById(Collection<String> ids) { Set<String> idSet = new HashSet<String>(); idSet.addAll(ids); ArrayList<T> result = new ArrayList<T>(idSet.size()); for (String id : idSet) { T graphObject = graphObjectsById.get(id); if (graphObject != null) { result.add(graphObject); } } return result; }
@Override void saveSelectionToBundle(Bundle outBundle, String key) { if (!selectedIds.isEmpty()) { String ids = TextUtils.join(",", selectedIds); outBundle.putString(key, ids); } }
@Override void readSelectionFromBundle(Bundle inBundle, String key) { if (inBundle != null) { String ids = inBundle.getString(key); if (ids != null) { String[] splitIds = TextUtils.split(ids, ","); selectedIds.clear(); Collections.addAll(selectedIds, splitIds); } } }
@Override boolean isEmpty() { return selectedIds.isEmpty(); }
@Override public void clear() { selectedIds.clear(); }
@Override boolean isSelected(String id) { return id != null && selectedIds.contains(id); }