日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

PopsTabView--filter容器

發(fā)布時間:2023/12/9 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PopsTabView--filter容器 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

PopsTabView是個filter容器,他可以自動,快速,構(gòu)建不同篩選樣式,自由組合成一組tab.

Download

Download
Author
License

篩選樣式篩選種類可自定義屬性
單列單選,多選初始數(shù)據(jù)bean,篩選結(jié)果bean,tab樣式,篩選樣式
多排單選,多選初始數(shù)據(jù)bean,篩選結(jié)果beantab樣式,篩選樣式
雙列單項單選,單項多選初始數(shù)據(jù)bean,篩選結(jié)果bean,tab樣式,篩選樣式
復(fù)雜單項單選,單項多選初始數(shù)據(jù)bean,篩選結(jié)果bean,tab樣式,篩選樣式
自定義單項單選,單項多選初始數(shù)據(jù)bean,篩選結(jié)果bean,tab樣式,篩選樣式

詳情請參考代碼,以及實例
后續(xù)篩選會不斷完善補(bǔ)充.

PopTabView.java API

方法名功能是否必須
setOnPopTabSetListener()外部回調(diào)的監(jiān)聽
setPopEntityLoader()篩選樣式加載類,新增類型可在此擴(kuò)展
setResultLoader()結(jié)果集加載器,可自定義進(jìn)行配置
addFilterItem()增加篩選項
setClickedItem()設(shè)置默認(rèn)選中的狀態(tài),并主動回調(diào)
removeItem()清空容器

項目地址傳送門 https://github.com/ccj659/PopsTabView

進(jìn)階

  • 支持自定義參數(shù)傳送門

  • 支持自定義樣式傳送門

Show











Introduction

用戶只需要,知道自己需要哪種filter,將數(shù)據(jù)轉(zhuǎn)化FilterTabBean,然后addFilterItem(),最后自己在onPopTabSet()回調(diào),即可使用,簡單粗暴.

優(yōu)點:

  • 支持快速,構(gòu)建不同篩選樣式,順序,自由組合成一組filter的tab.
  • 用接口抽象出filter樣式配置器loader,與功能代碼解耦.
  • 支持自定義配置 篩選結(jié)果ResultLoader<T>
  • 支持自定義數(shù)據(jù)bean.
  • 可以自由擴(kuò)展,其他類型的Filter類型.

待完善:

  • 逐漸增加其他類型的篩選樣式
  • view的樣式可配置為可自定義

TO USE

添加依賴

In Gradle

compile 'me.ccj.PopsTabView:poptabview_lib:1.4.0'復(fù)制代碼

In Maven

<dependency><groupId>me.ccj.PopsTabView</groupId><artifactId>poptabview_lib</artifactId><version>1.4.0</version><type>pom</type> </dependency>復(fù)制代碼

簡單方式

如果業(yè)務(wù)需求很簡單,用lib自帶的篩選即可.

1.設(shè)定,篩選器類型. 將PopTypeLoader暴露,用于用戶 篩選器類型.

需要自己按照該模式進(jìn)行擴(kuò)展.創(chuàng)建 具體 popwindow 實體對象. 創(chuàng)建對象和 功能代碼解耦和,細(xì)節(jié)在PopTabView.addItem()中.若有需要,需要自由擴(kuò)展,配置.

public class PopTypeLoaderImp implements PopTypeLoader {@Overridepublic PopupWindow getPopEntity(Context context, List data, OnMultipeFilterSetListener filterSetListener, int tag, int type) {PopupWindow popupWindow = null;switch (tag) {case FilterConfig.TYPE_POPWINDOW_LINKED:popupWindow = new LinkFilterPopupWindow(context, data, filterSetListener,type);break;case FilterConfig.TYPE_POPWINDOW_SORT:popupWindow = new SortPopupWindow(context, data, filterSetListener, tag,type);break;default:popupWindow = new MSingleFilterWindow(context, data, filterSetListener,type);break;}return popupWindow;} }復(fù)制代碼

2.使用方式

####2.1 Builder模式,完成篩選器的創(chuàng)建.

private void addMyMethod() {FilterGroup filterGroup1 = getMyData("篩選1", FilterConfig.TYPE_POPWINDOW_ROWS,FilterConfig.FILTER_TYPE_SINGLE);FilterGroup filterGroup2 = getMyData("篩選2", FilterConfig.TYPE_POPWINDOW_LINKED,FilterConfig.FILTER_TYPE_MUTIFY);FilterGroup filterGroup3 = getMyData("篩選3", FilterConfig.TYPE_POPWINDOW_SINGLE,FilterConfig.FILTER_TYPE_SINGLE);FilterGroup filterGroup4 = getMyData("篩選4", FilterConfig.TYPE_POPWINDOW_SORT,FilterConfig.FILTER_TYPE_MUTIFY);popTabView.setOnPopTabSetListener(this).setPopEntityLoader(new PopEntityLoaderImp()).setResultLoader(new ResultLoaderImp()) //配置 {篩選類型} 方式/**** @param title 篩選標(biāo)題* @param data 篩選數(shù)據(jù)* @param tag 篩選類別- 一級篩選,二級篩選,復(fù)雜篩選* @param type 篩選方式-單選or多選* @return*/.addFilterItem(filterGroup1.getTab_group_name(), filterGroup1.getFilter_tab(), filterGroup1.getTab_group_type(), filterGroup1.getSingle_or_mutiply()).addFilterItem(filterGroup2.getTab_group_name(), filterGroup2.getFilter_tab(), filterGroup2.getTab_group_type(), filterGroup2.getSingle_or_mutiply()).addFilterItem(filterGroup3.getTab_group_name(), filterGroup3.getFilter_tab(), filterGroup3.getTab_group_type(), filterGroup3.getSingle_or_mutiply()).addFilterItem(filterGroup4.getTab_group_name(), filterGroup4.getFilter_tab(), filterGroup4.getTab_group_type(), filterGroup4.getSingle_or_mutiply());}復(fù)制代碼

3.配置篩選后的返回值樣式ResultLoader<T>

/*** 如果 遇到復(fù)雜的 業(yè)務(wù)需求, 只需要在這里,對篩選結(jié)果進(jìn)行構(gòu)建即可.* Created by chenchangjun on 17/7/25.*/public class ResultLoaderImp implements ResultLoader<String> {@Overridepublic String getResultParamsIds(List<BaseFilterTabBean> selectedList, int filterType) {StringBuilder stringValues = new StringBuilder();for (int i = 0; i < selectedList.size(); i++) {FilterTabBean filterTabBean= (FilterTabBean) selectedList.get(i);stringValues.append( filterTabBean.getTab_id()+ ",");}return PopsTabUtils.builderToString(stringValues);}@Overridepublic String getResultShowValues(List<BaseFilterTabBean> selectedList, int filterType) {StringBuilder stringValues = new StringBuilder();for (int i = 0; i < selectedList.size(); i++) {stringValues.append(selectedList.get(i).getTab_name() + ",");}return PopsTabUtils.builderToString(stringValues);}復(fù)制代碼

4.成功的回調(diào),可配置為借口傳參.此處回調(diào),可以自主修改,擴(kuò)展.

/*** @param index 操作的 filter的下標(biāo)號 0.1.2.3* @param lable 操作的 filter的對應(yīng)的標(biāo)簽title* @param params 選中的 參數(shù)(需要傳參)* @param value 選中的 值*/@Overridepublic void onPopTabSet(int index, String lable, String params, String value) {Toast.makeText(this, "lable=" + index + "\n&value=" + value, Toast.LENGTH_SHORT).show();tv_content.setText("&篩選項=" + index + "\n&篩選傳參=" + params + "\n&篩選值=" + value);}復(fù)制代碼

進(jìn)階用法

  • 自定義參數(shù)傳送門

  • 自定義樣式傳送門

樣式調(diào)整--待優(yōu)化

1.可在各級Adapter.ViewHolder 中自己定義.

2.可在xml文件中自定義修改

3.O__O "….....好吧,還是我太懶了....以后會補(bǔ)充的~~

About Me

===
CSDN:http://blog.csdn.net/ccj659/article/

簡書:http://www.jianshu.com/u/94423b4ef5cf

github: https//github.com/ccj659/

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的PopsTabView--filter容器的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。