/** * 给区域和地铁的数据添加 不限的选项. * * @param resultBeanList * @param tag */ private void insetData(List<FilterAreaBean.ResultBean> resultBeanList, String tag) { if (resultBeanList != null && resultBeanList.size() != 0) { FilterAreaBean.ResultBean filterAreaBean = new FilterAreaBean.ResultBean(); filterAreaBean.setName("不限"); resultBeanList.add(0, filterAreaBean); for (int i = 0; i < resultBeanList.size(); i++) { // insertSubregion(resultBeanList, i ,tag); List<SubregionsBean> subregionsList = null; if (tag.equals(areaStr)) { subregionsList = resultBeanList.get(i).getSubregions(); } else if (tag.equals(metroStr)) { subregionsList = resultBeanList.get(i).getStations(); } if (subregionsList != null) { SubregionsBean subregionsBean = new SubregionsBean(); subregionsBean.setName("不限"); subregionsList.add(0, subregionsBean); } } } }
/** * 筛选 : 区域,metroStr * * @return */ private View createThreeListView( final int positionTitle, List<FilterAreaBean.ResultBean> areaList, List<FilterAreaBean.ResultBean> metroList) { ThreeListView<FilterAreaBean.ResultBean, SubregionsBean> threeList = new ThreeListView<FilterAreaBean.ResultBean, SubregionsBean>(mContext) .leftAdapter( new SimpleTextAdapter<FilterAreaBean.ResultBean>(null, mContext) { @Override public String provideText(FilterAreaBean.ResultBean filterType) { return filterType.getName(); } }) .midAdapter( new SimpleTextAdapter<FilterAreaBean.ResultBean>(null, mContext) { @Override public String provideText(FilterAreaBean.ResultBean resultBean) { return resultBean.getName(); } }) .rightAdapter( new SimpleTextAdapter<SubregionsBean>(null, mContext) { @Override public String provideText(SubregionsBean s) { return s.getName(); } }) .onLeftItemClickListener( new ThreeListView.OnLeftItemClickListener< FilterAreaBean.ResultBean, SubregionsBean>() { @Override public List<FilterAreaBean.ResultBean> provideMidList( FilterAreaBean.ResultBean item, int position) { List<FilterAreaBean.ResultBean> resultBeen = item.getMidList(); Logger.d( "onLeftItemClickListener " + " name : " + item.getName() + " size : " + resultBeen.size() + " position : " + position); return resultBeen; } }) .onMidItemClickListener( new ThreeListView.OnMidItemClickListener< FilterAreaBean.ResultBean, SubregionsBean>() { @Override public List<SubregionsBean> provideRightList( FilterAreaBean.ResultBean item, int position, int mLeftCurrentPosition) { List<SubregionsBean> childList = null; if (mLeftCurrentPosition == 0) { // 位置是0时显示区域.1显示地铁线路 childList = item.getSubregions(); } else { childList = item.getStations(); } Logger.d( "MiddleItemClickListener " + " position : " + position + " mLeftLastPosition " + mLeftCurrentPosition); if (childList != null) { Logger.d( "MiddleItemClickListener " + " name : " + item.getName() + " size : " + childList.size() + " position : " + position); return childList; } else { // 查询当前城市整个区域 onFilterDoneListener.onFilterAreaDone( positionTitle, mLeftCurrentPosition, item.getName(), ""); return null; } } }) .onRightItemClickListener( new ThreeListView.OnRightItemClickListener< FilterAreaBean.ResultBean, SubregionsBean>() { @Override public void onRightItemClick( int mLeftLastPosition, FilterAreaBean.ResultBean item, SubregionsBean subregionsBean) { Logger.d( "onRightItemClickListener " + " name : " + item.getName() + " string : " + subregionsBean.getName()); if (subregionsBean.getName().equals(NotLimit)) { onFilterDoneListener.onFilterAreaDone( positionTitle, mLeftLastPosition, NotLimit, item.getId()); } else { onFilterDoneListener.onFilterAreaDone( positionTitle, mLeftLastPosition, subregionsBean.getName(), subregionsBean.getId()); } } }); List<FilterAreaBean.ResultBean> leftList = new ArrayList<>(); FilterAreaBean.ResultBean area = new FilterAreaBean.ResultBean(); area.setName(areaStr); area.setMidList(areaList); leftList.add(area); FilterAreaBean.ResultBean metro = new FilterAreaBean.ResultBean(); metro.setName(metroStr); metro.setMidList(metroList); leftList.add(metro); threeList.setLeftList(leftList, 0); threeList.setMidList(leftList.get(0).getMidList(), 0); // threeList.setRightList(leftList.get(0).getMidList().get(0).getSubregions(), -1); // // threeList.getLeftListView().setBackgroundColor(mContext.getResources().getColor(R.color.b_c_fafafa)); // threeList.getLeftListView().performItemClick(threeList.getLeftListView(),0,0); return threeList; }