private void render() { if (mHeaderView != null) { if (mExpandableListView.getHeaderViewsCount() <= 0) { mHeaderView.findViewById(R.id.filter_select_class).setOnClickListener(this); mHasGoodView.setOnClickListener(this); mExpandableListView.addHeaderView(mHeaderView); selectedViewContainer.setVisibility( null == mSearchCategoryModels ? View.GONE : View.VISIBLE); mHeaderView .findViewById(R.id.filter_select_topline) .setVisibility(selectedViewContainer.getVisibility()); } } if (null != selectedCategoryView) { if (!TextUtils.isEmpty(mSearchModel.getCategoryName())) { selectedCategoryView.setText(mSearchModel.getCategoryName()); } } refreshHasGoodView(); if (mSearchFilterAttributeModels.size() == 0 && null == mSearchCategoryModels && total_num <= 0) { findViewById(R.id.filter_relative_empty).setVisibility(View.VISIBLE); findViewById(R.id.global_container).setVisibility(View.GONE); return; } for (SearchFilterAttributeModel mSearchFilterAttributeModel : mSearchFilterAttributeModels) { String[] options = mSearchModel.getOptions(mSearchFilterAttributeModel.getId()); for (SearchFilterOptionModel mSearchFilterOptionModel : mSearchFilterAttributeModel.getSearchFilterOptionModels()) { if (options == null || options.length == 0) { mSearchFilterOptionModel.setSelect(false); } else { boolean found = false; for (String option : options) { if (mSearchFilterOptionModel.getId() == Integer.valueOf(option)) { found = true; mSearchFilterOptionModel.setSelect(true); } } if (!found) { mSearchFilterOptionModel.setSelect(false); } } } } if (null == mFilterAdapter) { mFilterAdapter = new FilterAdapter(this, mSearchFilterAttributeModels); mExpandableListView.setAdapter(mFilterAdapter); } else { mFilterAdapter.notifyDataSetChanged(); // 默认刷新数据时将ListView默认收缩 int groupCount = mExpandableListView.getCount(); for (int i = 0; i < groupCount; i++) { mExpandableListView.collapseGroup(i); } ; } }
@Override public void onClick(View view) { int id = view.getId(); String strPageId = getString(R.string.tag_FilterActivity); switch (id) { case R.id.filter_button_confirm: if (null != mSearchModel) { mSearchModel.setOption(null); if ((null != mSearchFilterAttributeModels) && (mSearchFilterAttributeModels.size() > 0)) { for (SearchFilterAttributeModel mSearchFilterAttributeModel : mSearchFilterAttributeModels) { for (SearchFilterOptionModel mSearchFilterOptionModel : mSearchFilterAttributeModel.getSearchFilterOptionModels()) { if (mSearchFilterOptionModel.isSelect()) { mSearchModel.setOption( mSearchFilterAttributeModel.getId(), mSearchFilterOptionModel.getId()); } } } } Intent intent = getIntent(); Bundle param = new Bundle(); param.putSerializable(RESULT_SEARCH_MODEL, mSearchModel); intent.putExtras(param); setResult(FLAG_RESULT_OK, intent); finish(); ToolUtil.sendTrack( this.getClass().getName(), strPageId, this.getClass().getName(), strPageId, "02011"); } break; case R.id.filter_button_clear: if (mSearchFilterAttributeModels != null) { for (SearchFilterAttributeModel mSearchFilterAttributeModel : mSearchFilterAttributeModels) { if (mSearchFilterAttributeModel != null && mSearchFilterAttributeModel.getSearchFilterOptionModels() != null) { for (SearchFilterOptionModel mSearchFilterOptionModel : mSearchFilterAttributeModel.getSearchFilterOptionModels()) { if (mSearchFilterOptionModel != null) { mSearchFilterOptionModel.setSelect(false); } } } } } if (mFilterAdapter != null) { mFilterAdapter.notifyDataSetInvalidated(); } mSearchModel.setHasGood(SearchModel.SORT_HASGOOD_OFF); refreshHasGoodView(); ToolUtil.sendTrack( this.getClass().getName(), strPageId, this.getClass().getName(), strPageId, "02012"); break; case R.id.filter_select_class: Bundle param = new Bundle(); param.putSerializable( FilterCategoryActivity.REQUEST_SEARCH_CATEGORY_MODEL, mSearchCategoryModels); param.putSerializable(FilterCategoryActivity.REQUEST_SEARCH_MODEL, mSearchModel); param.putInt(FilterCategoryActivity.TOTAL_COUNT, total_num); ToolUtil.startActivity( FilterActivity.this, FilterCategoryActivity.class, param, REQUEST_FLAG_CATEGORY_FILTER); break; case R.id.filter_sale_status: int hasGood = mSearchModel.getHasGood() == 0 ? 1 : 0; mSearchModel.setHasGood(hasGood); refreshHasGoodView(); break; } }