use of me.devsaki.hentoid.adapters.AvailableAttributeAdapter in project Hentoid by avluis.
the class SearchBottomSheetFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.include_search_filter_category, container, false);
AttributeType mainAttr = selectedAttributeTypes.get(0);
// Image that displays current metadata type icon (e.g. face icon for character)
ImageView tagWaitImage = requireViewById(rootView, R.id.tag_wait_image);
tagWaitImage.setImageResource(mainAttr.getIcon());
// Image that displays current metadata type title (e.g. "Character search")
TextView tagWaitTitle = requireViewById(rootView, R.id.tag_wait_title);
tagWaitTitle.setText(getString(R.string.search_category, StringHelper.capitalizeString(getString(mainAttr.getDisplayName()))));
tagWaitPanel = requireViewById(rootView, R.id.tag_wait_panel);
tagWaitMessage = requireViewById(rootView, R.id.tag_wait_description);
RecyclerView attributeMosaic = requireViewById(rootView, R.id.tag_suggestion);
FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(this.getContext());
// layoutManager.setAlignContent(AlignContent.FLEX_START); <-- not supported
layoutManager.setAlignItems(AlignItems.STRETCH);
layoutManager.setFlexWrap(FlexWrap.WRAP);
attributeMosaic.setLayoutManager(layoutManager);
attributeAdapter = new AvailableAttributeAdapter();
attributeAdapter.setOnScrollToEndListener(this::loadMore);
attributeAdapter.setOnClickListener(this::onAttributeChosen);
attributeMosaic.setAdapter(attributeAdapter);
tagSearchView = requireViewById(rootView, R.id.tag_filter);
// Associate searchable configuration with the SearchView
tagSearchView.setSearchableInfo(getSearchableInfo(requireActivity()));
List<String> attrTypesNames = Stream.of(selectedAttributeTypes).map(AttributeType::getDisplayName).map(this::getString).toList();
tagSearchView.setQueryHint(getResources().getString(R.string.search_prompt, android.text.TextUtils.join(", ", attrTypesNames)));
tagSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
if (!s.isEmpty())
searchMasterData(s);
tagSearchView.clearFocus();
return true;
}
@Override
public boolean onQueryTextChange(String s) {
searchMasterDataDebouncer.submit(s);
return true;
}
});
return rootView;
}
Aggregations