use of com.google.android.flexbox.FlexboxLayoutManager 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;
}
use of com.google.android.flexbox.FlexboxLayoutManager in project odysee-android by OdyseeTeam.
the class CustomizeTagsDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dialog_customize_tags, container, false);
noResultsView = view.findViewById(R.id.customize_no_tag_results);
noTagsView = view.findViewById(R.id.customize_no_followed_tags);
followedTagsAdapter = new TagListAdapter(Lbry.followedTags, getContext());
followedTagsAdapter.setCustomizeMode(TagListAdapter.CUSTOMIZE_MODE_REMOVE);
followedTagsAdapter.setClickListener(customizeTagClickListener);
suggestedTagsAdapter = new TagListAdapter(new ArrayList<>(), getContext());
suggestedTagsAdapter.setCustomizeMode(TagListAdapter.CUSTOMIZE_MODE_ADD);
suggestedTagsAdapter.setClickListener(customizeTagClickListener);
FlexboxLayoutManager flm1 = new FlexboxLayoutManager(getContext());
followedTagsList = view.findViewById(R.id.customize_tags_followed_list);
followedTagsList.setLayoutManager(flm1);
followedTagsList.setAdapter(followedTagsAdapter);
FlexboxLayoutManager flm2 = new FlexboxLayoutManager(getContext());
suggestedTagsList = view.findViewById(R.id.customize_tags_suggested_list);
suggestedTagsList.setLayoutManager(flm2);
suggestedTagsList.setAdapter(suggestedTagsAdapter);
TextInputEditText filterInput = view.findViewById(R.id.customize_tag_filter_input);
filterInput.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
String value = Helper.getValue(charSequence);
setFilter(value);
}
@Override
public void afterTextChanged(Editable editable) {
}
});
MaterialButton doneButton = view.findViewById(R.id.customize_done_button);
doneButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
checkNoTags();
return view;
}
use of com.google.android.flexbox.FlexboxLayoutManager in project RxMVP by Yumore.
the class CategoryAdapter method convert.
@Override
protected void convert(BaseViewHolder helper, KnowledgeSystem item) {
if (item == null) {
return;
}
helper.setText(R.id.item_life_title, item.getName());
FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(mContext);
flexboxLayoutManager.setFlexDirection(FlexDirection.ROW);
flexboxLayoutManager.setFlexWrap(FlexWrap.WRAP);
flexboxLayoutManager.setJustifyContent(JustifyContent.FLEX_START);
RecyclerView recyclerView = helper.getView(R.id.item_life_list);
recyclerView.setLayoutManager(flexboxLayoutManager);
CateTagAdapter childAdapter = new CateTagAdapter(R.layout.item_life_child_recycler_list, item.getChildren());
recyclerView.setAdapter(childAdapter);
childAdapter.setOnItemClickListener((adapter, view, position) -> {
if (onItemTagClickListener == null) {
return;
}
ChildrenBean data = item.getChildren().get(position);
if (item.getLastId() != data.getId()) {
for (ChildrenBean childrenBean : item.getChildren()) {
childrenBean.setSelected(childrenBean.getId() == data.getId());
}
item.setLastId(data.getId());
childAdapter.notifyDataSetChanged();
}
onItemTagClickListener.onItemTagClick(adapter, view, helper.getAdapterPosition(), position);
});
helper.setVisible(R.id.item_life_holder, helper.getAdapterPosition() == 0);
}
use of com.google.android.flexbox.FlexboxLayoutManager in project wanandroid by KnightAndroid.
the class KnowledgeLabelActivity method initData.
@Override
public void initData() {
myTagInfos.addAll(addTags("fix", fixDataList, TagInfo.TYPE_TAG_SERVICE));
myTagInfos.addAll(addTags("default", mDefaultList, TagInfo.TYPE_TAG_USER));
mDatabind.homeKnowledgetTag.setTags(myTagInfos);
mManager = new FlexboxLayoutManager(this);
mManager.setFlexDirection(FlexDirection.ROW);
// 左对齐
mManager.setJustifyContent(JustifyContent.FLEX_START);
mManager.setAlignItems(AlignItems.CENTER);
mDatabind.homeMoreknowledgeRv.setLayoutManager(mManager);
// 首先读取本地是否有保存
moreKnowLedgeList = CacheUtils.getDataInfo("moreknowledgeLabel", new TypeToken<List<TagInfo>>() {
}.getType());
if (moreKnowLedgeList == null || moreKnowLedgeList.size() == 0) {
moreKnowLedgeList = new ArrayList<>();
}
mMoreKnowLedgeAdapter = new MoreKnowLedgeAdapter(moreKnowLedgeList);
mDatabind.homeMoreknowledgeRv.setAdapter(mMoreKnowLedgeAdapter);
mDatabind.homeTvMorelabel.setText(getString(R.string.home_more_knowledge) + "(" + mMoreKnowLedgeAdapter.getData().size() + "/10)");
initLinstener();
}
use of com.google.android.flexbox.FlexboxLayoutManager in project wanandroid by KnightAndroid.
the class HierachyRightFragment method initView.
@Override
protected void initView(Bundle savedInstanceState) {
isNavigate = getArguments().getBoolean("isNavigate");
mDatabind.hierachyRightRv.addOnScrollListener(new RecyclerViewListener());
mManager = new FlexboxLayoutManager(getActivity());
mManager.setFlexDirection(FlexDirection.ROW);
// 左对齐
mManager.setJustifyContent(JustifyContent.FLEX_START);
mManager.setAlignItems(AlignItems.CENTER);
mDatabind.hierachyRightRv.setLayoutManager(mManager);
mHierachyClassifyDetailAdapter = new HierachyClassifyDetailAdapter(getActivity(), mDatas, new RvListener() {
@Override
public void onItemClick(int id, int position) {
if (id == R.id.hierachy_root) {
if (!isNavigate) {
ARouter.getInstance().build(RoutePathActivity.Hierachy.HierachyTab).withStringArrayList("childrenNames", mDatas.get(position).getChildrenName()).withIntegerArrayList("cids", mDatas.get(position).getCid()).withString("titleName", mDatas.get(position).getTitleName()).navigation();
}
} else if (id == R.id.hierachy_tv_content) {
if (isNavigate) {
ARouterUtils.startWeb(mDatas.get(position).getLink(), mDatas.get(position).getName(), mDatas.get(position).getId(), mDatas.get(position).isCollect(), "", "", mDatas.get(position).getName(), mDatas.get(position).getName());
} else {
ARouter.getInstance().build(RoutePathActivity.Hierachy.HierachyDetail).withInt("cid", mDatas.get(position).getId()).withString("titleName", mDatas.get(position).getName()).navigation();
}
}
}
});
}
Aggregations