Search in sources :

Example 1 with FlexboxLayoutManager

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;
}
Also used : SearchView(androidx.appcompat.widget.SearchView) AvailableAttributeAdapter(me.devsaki.hentoid.adapters.AvailableAttributeAdapter) AttributeType(me.devsaki.hentoid.enums.AttributeType) FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) TextView(android.widget.TextView) RecyclerView(androidx.recyclerview.widget.RecyclerView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SearchView(androidx.appcompat.widget.SearchView) TextView(android.widget.TextView)

Example 2 with FlexboxLayoutManager

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;
}
Also used : TagListAdapter(com.odysee.app.adapter.TagListAdapter) FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) ArrayList(java.util.ArrayList) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) MaterialButton(com.google.android.material.button.MaterialButton) TextInputEditText(com.google.android.material.textfield.TextInputEditText) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

Example 3 with FlexboxLayoutManager

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);
}
Also used : FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) ChildrenBean(com.yumore.provider.entity.reseult.ChildrenBean) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 4 with FlexboxLayoutManager

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();
}
Also used : FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) ArrayList(java.util.ArrayList) List(java.util.List) MoreKnowLedgeAdapter(com.knight.wanandroid.module_home.module_adapter.MoreKnowLedgeAdapter)

Example 5 with FlexboxLayoutManager

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();
                }
            }
        }
    });
}
Also used : RvListener(com.knight.wanandroid.module_hierachy.module_listener.RvListener) FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) HierachyClassifyDetailAdapter(com.knight.wanandroid.module_hierachy.module_adapter.HierachyClassifyDetailAdapter)

Aggregations

FlexboxLayoutManager (com.google.android.flexbox.FlexboxLayoutManager)20 View (android.view.View)8 RecyclerView (androidx.recyclerview.widget.RecyclerView)8 TextView (android.widget.TextView)7 ImageView (android.widget.ImageView)5 ArrayList (java.util.ArrayList)5 Context (android.content.Context)4 TagListAdapter (com.odysee.app.adapter.TagListAdapter)4 NestedScrollView (androidx.core.widget.NestedScrollView)3 SuppressLint (android.annotation.SuppressLint)2 Editable (android.text.Editable)2 TextWatcher (android.text.TextWatcher)2 AdapterView (android.widget.AdapterView)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)2 MaterialButton (com.google.android.material.button.MaterialButton)2 MainActivity (com.odysee.app.MainActivity)2 Claim (com.odysee.app.model.Claim)2 Intent (android.content.Intent)1 PackageManager (android.content.pm.PackageManager)1 Paint (android.graphics.Paint)1