void setSelectionStrategy(SelectionStrategy selectionStrategy) { if (selectionStrategy != this.selectionStrategy) { this.selectionStrategy = selectionStrategy; if (adapter != null) { // Adapter should cause a re-render. adapter.notifyDataSetChanged(); } } }
private void onListItemClick(ListView listView, View v, int position) { @SuppressWarnings("unchecked") T graphObject = (T) listView.getItemAtPosition(position); String id = adapter.getIdOfGraphObject(graphObject); selectionStrategy.toggleSelection(id); adapter.notifyDataSetChanged(); if (onSelectionChangedListener != null) { onSelectionChangedListener.onSelectionChanged(PickerFragment.this); } }
private void clearResults() { if (adapter != null) { boolean wasSelection = !selectionStrategy.isEmpty(); boolean wasData = !adapter.isEmpty(); loadingStrategy.clearResults(); selectionStrategy.clear(); adapter.notifyDataSetChanged(); // Tell anyone who cares the data and selection has changed, if they have. if (wasData && onDataChangedListener != null) { onDataChangedListener.onDataChanged(PickerFragment.this); } if (wasSelection && onSelectionChangedListener != null) { onSelectionChangedListener.onSelectionChanged(PickerFragment.this); } } }