jaychang0917 / SimpleRecyclerView

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

Calling setLoadingMore(false) immediately after setLoadingMore(true) breaks the state of the view #34

Closed rteterin closed 6 years ago

rteterin commented 6 years ago

When setLoadingMore(true) is called (which in turn calls showLoadMoreView()), a call to addCell method is added to the UI message queue and isLoadMoreViewShown is set to true.

If setLoadingMore(false) is called right after that, removeCell method is called immediately and isLoadMoreViewShown is set to false.

The problem is that at this moment the runnable that calls addCell is still in the message queue, therefore it will be called later. But when it's called, it adds this cell despite the fact that isLoadMoreViewShown is false. Now the cell is displayed, and it's not possible to hide it with another call to setLoadingMore(false), because hideLoadMoreView() thinks that it's already hidden.

jaychang0917 commented 6 years ago

hi @rteterin , i can't reproduce your case, and I tried the following code, the load more view will be hidden immediately as expected.

recyclerView.setLoadingMore(true);
recyclerView.setLoadingMore(false);
rteterin commented 6 years ago

Hello @jaychang0917, I created a simple app that reproduces the issue: https://github.com/rteterin/SimpleRecyclerView_issue34_demo

I tested on Android 5.1.1 and 6.0.1.

jaychang0917 commented 6 years ago

Thanks your report, the new release 1.2.7 should fix this issue.