Okay, so it wasnβt particularly difficult - I think my main problem was what I was thinking about the script ...
So, the first thing I do is to get the relevant data (in this case via JSON) and save it in a JSON array for manipulation later - at the moment I am still getting the complete set (Ie 5000), but it is easily replaced.
This is done through AsyncTask with an undefined progress bar. After its completion, I parse JSON to 20 elements and load them into the adapter.
As soon as I finished, I have a Recyclerview.onScrollListener ....
mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); mOnScreenItems = mRecyclerView.getChildCount(); mTotalItemsInList = llm.getItemCount(); mFirstVisibleItem = llm.findFirstVisibleItemPosition(); if (mLoadingItems) { if (mTotalItemsInList > mPreviousTotal) { mLoadingItems = false; mPreviousTotal = mTotalItemsInList; } } if (!mLoadingItems && (mTotalItemsInList - mOnScreenItems) <= (mFirstVisibleItem + mVisibleThreshold)) { new AsyncLoadTask().execute(); mLoadingItems = true; } } @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); } });
When it approaches the end or falls to the bottom, a new AsynTask is launched to load additional items into the list. Then onPostExecute() updates the adapter using the mMyAdapter.notifyDataSetChanged(); method mMyAdapter.notifyDataSetChanged(); that gives a nice smooth update. Many utilities to do, but the basics exist.
Thanks for the guys guidance!
source share