private void setCarServicesIsError(boolean isError) { if (!isError) { prsScrollView.setVisibility(View.VISIBLE); llError.setVisibility(View.GONE); } else { prsScrollView.setVisibility(View.GONE); llError.setVisibility(View.VISIBLE); } }
private void setCarServices() { mServiceAdapter.clear(); mServiceAdapter.appendGroups(mGroups); mServiceAdapter.appendChild(mChildServices); for (int i = 0; i < mServiceAdapter.getGroupCount(); i++) { elvList.expandGroup(i); } prsScrollView.getRefreshableView().smoothScrollTo(0, 0); }
@Override protected void initView() { mContext = this; setContentView(R.layout.activity_car_services); llLocation = findView(R.id.llLocation); tvLocation = findView(R.id.tvLocation); TextView tvTitle = findView(R.id.tvTitle); prsScrollView = findView(R.id.svScrollView); llError = findView(R.id.llError); llAdvert = findView(R.id.llAdvert); llServices = findView(R.id.llServices); elvList = findView(R.id.elvList); tvTitle.setText(getResources().getString(R.string.car_services_title)); prsScrollView.setMode(PullToRefreshBase.Mode.PULL_FROM_START); prsScrollView.getLoadingLayoutProxy().setPullLabel("下拉刷新"); prsScrollView.getLoadingLayoutProxy().setRefreshingLabel("加载中..."); prsScrollView.getLoadingLayoutProxy().setReleaseLabel("释放更新"); prsScrollView.getLoadingLayoutProxy().setRefreshingLabelIm("刷新成功"); prsScrollView.getLoadingLayoutProxy().setmEndLabel("刷新成功"); mServiceAdapter = new GLExpandableAdapter(mContext, null, null); elvList.setAdapter(mServiceAdapter); elvList.setGroupIndicator(null); prsScrollView.setOnRefreshListener( new PullToRefreshBase.OnRefreshListener<ScrollView>() { @Override public void onRefresh(PullToRefreshBase<ScrollView> refreshView) { fetchCarServices(getSelectCityId()); } }); elvList.setOnGroupClickListener( new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick( ExpandableListView parent, View v, int groupPosition, long id) { CarServiceGroup group = mServiceAdapter.getGroup(groupPosition); // 是否显示分组名称 boolean showName = (null == group.getShowName() ? false : group.getShowName()); // 首页展示数 NOTICE 0 表示不限,全部显示 int indexServiceCount = (null == group.getIndexServiceCount() ? 0 : group.getIndexServiceCount()); // 包含服务数 int serviceCount = (null == group.getServiceCount() ? 0 : group.getServiceCount()); // 不显示分组名称时,要全部加载数据 boolean isOnClick = showName && !(indexServiceCount == 0 || serviceCount <= indexServiceCount); if (isOnClick) { Intent intent = new Intent(mContext, CarMoreServiceActivity.class); intent.putExtra(CarServicesUtil.KEY_PARAM_VALUE, group); mContext.startActivity(intent); } return true; } }); elvList.setOnChildClickListener( new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick( ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { CarService carService = mServiceAdapter.getChild(groupPosition, childPosition); // 点击服务 CarServicesUtil.onClickCarServiceItem(mContext, carService); return true; } }); prsScrollView.getRefreshableView().smoothScrollTo(0, 0); }