Skip to content

Commit

Permalink
Just referring to the adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 committed Nov 8, 2024
1 parent e9d6b24 commit e9ed78e
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public class GsFileBrowserListAdapter extends RecyclerView.Adapter<GsFileBrowser
private File _fileToShowAfterNextLoad;
private File _currentFolder;
private final Context _context;
private StringFilter _filter;
private final StringFilter _filter;
private RecyclerView _recyclerView;
private LinearLayoutManager _layoutManager;
private final Map<File, File> _virtualMapping;
Expand Down Expand Up @@ -138,6 +138,7 @@ public GsFileBrowserListAdapter(GsFileBrowserOptions.Options options, Context co
_virtualMapping = Collections.unmodifiableMap(getVirtualFolders());
_reverseVirtualMapping = Collections.unmodifiableMap(GsCollectionUtils.reverse(_virtualMapping));
loadFolder(_dopt.startFolder != null ? _dopt.startFolder : _dopt.rootFolder, null);
_filter = new StringFilter(this);
}

public Map<File, File> getVirtualFolders() {
Expand Down Expand Up @@ -364,9 +365,6 @@ public int getItemCount() {

@Override
public Filter getFilter() {
if (_filter == null) {
_filter = new StringFilter(this, _adapterData);
}
return _filter;
}

Expand Down Expand Up @@ -817,14 +815,12 @@ public boolean isCurrentFolderHome() {
//########################
private static class StringFilter extends Filter {
private final GsFileBrowserListAdapter _adapter;
private final List<File> _originalList;
private final List<File> _filteredList;
public String _lastFilter = "";

private StringFilter(GsFileBrowserListAdapter adapter, List<File> adapterData) {
private StringFilter(final GsFileBrowserListAdapter adapter) {
super();
_adapter = adapter;
_originalList = adapterData;
_filteredList = new ArrayList<>();
}

Expand All @@ -833,7 +829,7 @@ protected FilterResults performFiltering(CharSequence constraint) {
final FilterResults results = new FilterResults();

_lastFilter = constraint.toString().toLowerCase().trim();
_filter(_originalList, _filteredList);
_filter(_adapter._adapterData, _filteredList);

results.values = _filteredList;
results.count = _filteredList.size();
Expand Down

0 comments on commit e9ed78e

Please sign in to comment.