jaychang0917 / SimpleRecyclerView

A RecyclerView extension for building list more easily.
Apache License 2.0
935 stars 104 forks source link

Reloading SimpleRecyclerView causes extra cells #27

Closed ghost closed 7 years ago

ghost commented 7 years ago

When I hit a refresh button in my app to reload the SimpleRecyclerView with section headers, I use an AsyncTask to get the data to create the sections and cells. I run the .removeAllCells() onPreExecute, create the cells in the doInBackground, and add the cells to the recylerView in the onPostExecute. However, the recyclerView seems to do some sort of caching and adds an extraneous section to the beginning and then adds an extraneous cell to the end of each section after each refresh.

I've added images below for reference:

On initial load... screenshot_20170602-125143

After first refresh... screenshot_20170602-125148

After second refresh... screenshot_20170602-125153

You can see the pattern, and it continues with each refresh. Any thoughts on how to solve this issue? Thanks

jaychang0917 commented 7 years ago

Can you provide a simple demo project that can reproduce your issue?

ghost commented 7 years ago

@jaychang0917 I've posted an example showing the same issue at https://github.com/csimmonsbluebook/SimpleRecyclerViewTest

jaychang0917 commented 7 years ago

@csimmonsbluebook You should call setupRecyclerViewHeaders(); in on onCreate

ghost commented 7 years ago

@jaychang0917 That still didn't fix the issue when refreshing the recyclerView. After refreshing, it still creates the extraneous section and cells.

jaychang0917 commented 7 years ago

@csimmonsbluebook what's your new code? pls update https://github.com/csimmonsbluebook/SimpleRecyclerViewTest

ghost commented 7 years ago

@jaychang0917 Sorry I moved the wrong method call. But moving setupRecyclerViewHeaders(); to onCreate caused a NullPointerException for me. I just pushed the code

jaychang0917 commented 7 years ago

@csimmonsbluebook I just released a new version, pls try 1.1.17

ghost commented 7 years ago

@jaychang0917 Your fix in 1.1.17 worked. Thanks for the help and quick responses!