mLinearLayoutManager = new LinearLayoutManager(getActivity()); mRecyclerView = (RecyclerView)rootView.findViewById(R.id.recycleralda); mRecyclerView.setLayoutManager(mLinearLayoutManager); mRecyclerView.setItemAnimator(new DefaultItemAnimator()); mSwipeRefreshLayout = (SwipeRefreshLayout)rootView.findViewById(R.id.swipeRefreshLayout); mSwipeRefreshLayout.setRefreshing(false); mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); visibleItemCount = mRecyclerView.getChildCount(); totalItemCount = mLinearLayoutManager.getItemCount(); firstVisibleItem = mLinearLayoutManager.findFirstVisibleItemPosition(); if (loading) { if (totalItemCount > previousTotal) { loading = false; previousTotal = totalItemCount; } } if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) { currentPage++; populateData(); // End has been reached Log.i("...", "end called"); // Do something loading = true; } } }); public void init() { mRecyclerviewAdapter = new RecyclerViewAdapter(lNews,getActivity()); mRecyclerView.setAdapter(mRecyclerviewAdapter); mRecyclerviewAdapter.notifyDataSetChanged(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)