private void loadData(String url) { if (getMyActivity().hasNetWork()) { loadNewList(url); } else { mListView.onBottomComplete(); mProgressBar.setVisibility(View.GONE); getMyActivity().showShortToast(getString(R.string.not_network)); String result = getMyActivity().getCacheStr("CBAFragment" + currentPagte); if (!StringUtils.isEmpty(result)) { getResult(result); } } }
@AfterViews protected void initView() { swipeLayout.setOnRefreshListener(this); InitView.instance().initSwipeRefreshLayout(swipeLayout); InitView.instance().initListView(mListView, getActivity()); View headView = LayoutInflater.from(getActivity()).inflate(R.layout.head_item, null); mDemoSlider = (SliderLayout) headView.findViewById(R.id.slider); // mListView.addHeaderView(headView); AnimationAdapter animationAdapter = new CardsAnimationAdapter(newAdapter); animationAdapter.setAbsListView(mListView); mListView.setAdapter(animationAdapter); loadData(getCommonUrl(index + "", Url.CBAId)); mListView.setOnBottomListener( new OnClickListener() { @Override public void onClick(View v) { currentPagte++; index = index + 20; loadData(getCommonUrl(index + "", Url.CBAId)); } }); }
@UiThread public void getResult(String result) { getMyActivity().setCacheStr("CBAFragment" + currentPagte, result); if (isRefresh) { isRefresh = false; newAdapter.clear(); listsModles.clear(); } mProgressBar.setVisibility(View.GONE); swipeLayout.setRefreshing(false); List<NewModle> list = NewListJson.instance(getActivity()).readJsonNewModles(result, Url.CBAId); // if (index == 0) { // initSliderLayout(list); // } else { newAdapter.appendList(list); // } listsModles.addAll(list); mListView.onBottomComplete(); }