@Override public View createView(Context context, LayoutInflater inflater) { if (fragmentView == null) { fragmentView = super.createView(context, inflater); layoutManager = new LinearLayoutManager(getParentActivity()); mNodeListView = (LoadMoreRecyclerView) fragmentView.findViewById(R.id.recycleview); mNodeListView.setLayoutManager(layoutManager); mEmptyContainer = (RelativeLayout) fragmentView.findViewById(R.id.swipe_refresh_empty_container); footerContainer = (FrameLayout) fragmentView.findViewById(R.id.swipe_refresh_footer_container); init(); mNodeListView.setAdapter(mListAdapter); // 控制手动加载更多 mListAdapter.setOnLoadMoreListener(this); // 控制自动加载更多 mNodeListView.setOnLoadMoreListener(this); onRefresh(); } else { ViewGroup parent = (ViewGroup) fragmentView.getParent(); if (parent != null) { parent.removeView(fragmentView); } } return fragmentView; }
public void appendItemsData(ArrayList<T> paramArrayList) { mListAdapter.appendItemsData(paramArrayList); onRefreshingStateChanged(false); // 通过页面Number控制ListView是否自动加载更多 if (pageNumber <= 3) { mNodeListView.setAutoLoadMore(true); mListAdapter.isLoading = true; } else { mNodeListView.setAutoLoadMore(false); mListAdapter.isLoading = false; } mNodeListView.onLoadMoreComplete(); }
public void hasNoMoreData() { onRefreshingStateChanged(false); mNodeListView.setAutoLoadMore(false); mListAdapter.hasMoreItems = false; mListAdapter.isLoading = false; mListAdapter.notifyDataSetChanged(); }
public void refreshNewItemsData(ArrayList<T> paramArrayList) { mNodeListView.setAutoLoadMore(true); mListAdapter.hasMoreItems = true; mListAdapter.isLoading = true; mListAdapter.refreshNewItemsData(paramArrayList); onRefreshingStateChanged(false); }