I am trying to implement CardView
in a list using RecyclerView.Adapter
. Creating cards in a list was pretty straightforward using RecyvlerView.Adapter. I am using parse.com
as my back end so queries for cards data are made using its APIs.
Now I want to add pagination to this list. If I use Parse's ParseQueryAdapter
, I can get built in pagination from that API. But then I would have to ditch RecyclerView.Adapter
(or not?) and fall back to old BaseAdapter method. However, I don't want to do that and work with this new RecyclerView.Adapter
provided by Android (because of the efficiency it promises).
My question: What is the better approach?
ParseQueryAdapter
with old BaseAdapter
methodRecyclerView.Adapter
with normal data fetch method and write my own paginationYou can try making a shim between the two adapters. It would extend RecyclerView.Adapter and contain a ParseQueryAdapter. Then it basically just proxies all the methods. So, for example, the onBindViewHolder just calls the ParseAdapter.getItemView. The tricky part is setting up the listener for when the parse data comes down, using addOnQueryLoadListener, and having it trigger a refresh of the RecyclerView.
Here's a stub: https://gist.github.com/mrowl/0ab027b5f84e25f51102
It seems to work for the basic case, but it can probably be improved upon significantly. I'm pretty new to this side of the api.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With