private void initView(InvestmentActivity context) { this.context = context; LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.layout_investment_rush, this); initSwipeRefresh(); rushListView = (ListView) this.findViewById(R.id.rushListView); qtLayout = new InvestmentQTLayout(this.context); rushListView.addHeaderView(qtLayout); rushAdapter = new VoteOfRushAdapter(this.context); swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(rushAdapter); swingBottomInAnimationAdapter.setAbsListView(rushListView); swingBottomInAnimationAdapter .getViewAnimator() .setInitialDelayMillis(Constants.INITIAL_DELAY_MILLIS); rushListView.setAdapter(swingBottomInAnimationAdapter); }
private void requestDebetListAction(final boolean isRefresh, String msg) { HashMap<String, String> tempMap = new HashMap<String, String>(); tempMap.put("pageNo", pageNo + ""); tempMap.put("pageSize", Constants.PAGESIZE + ""); tempMap.put("type", "QT"); JSONRequest request = new JSONRequest( this.context, RequestEnum.DEBTPACKAGE_LIST, tempMap, false, new Response.Listener<String>() { @Override public void onResponse(String jsonObject) { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure( DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); JavaType type = objectMapper .getTypeFactory() .constructParametricType(Paginable.class, DebtPackageAppDto.class); JavaType javaType = objectMapper .getTypeFactory() .constructParametricType(AppMessageDto.class, type); AppMessageDto<Paginable<DebtPackageAppDto>> dto = null; try { dto = objectMapper.readValue(jsonObject, javaType); if (dto.getStatus() == AppResponseStatus.SUCCESS) { totalPage = dto.getData().getTotalPage(); pageNo = dto.getData().getPageNo(); if (isRefresh) { deptList.clear(); } deptList.addAll(dto.getData().getList()); rushAdapter.setData(deptList); rushAdapter.notifyDataSetChanged(); swingBottomInAnimationAdapter.notifyDataSetChanged(); ActivityUtil.setEmptyView(InvestmentRushLayout.this, rushListView) .setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { refreshData("正在请求数据..."); } }); } } catch (Exception e) { e.printStackTrace(); } finally { mSwipeLayout.setRefreshing(false); mSwipeLayout.setLoading(false); if (pageNo == totalPage) { mSwipeLayout.setMode(SwipeRefreshLayout.Mode.PULL_FROM_START); } else { mSwipeLayout.setMode(SwipeRefreshLayout.Mode.BOTH); } } } }, new ResponseErrorListener(context) { @Override public void todo() { mSwipeLayout.setRefreshing(false); mSwipeLayout.setLoading(false); } }); if (!context.addToRequestQueue(request, msg)) { mSwipeLayout.setRefreshing(false); mSwipeLayout.setLoading(false); } }