sangcomz / StickyTimeLine

:book:StickyTimeLine is timeline view for android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Item positions are shifted with each update

jurgen178 opened this issue · comments

Hi there, displayed items are shifted to the right bottom side each time the view is updated.

When data is updated in a loop using
recyclerView.addItemDecoration(getSectionCallback(dataList))
the display items have the correct position during the first iteration, but start to shift to the right/bottom with each iteration.

As a test, setting the defaultOffset to 0 stops the shifting, so it seems an offset accumulates each time.
private var defaultOffset: Int = 0.DP(context).toInt()

Screenshot_20210325-145724

Screenshot_20210325-145730

Screenshot_20210325-145737

There is nothing wrong with the timeline code itself. The problem seems to be the accumulated item decorations of the underlying recyclerview. The problem resolves if all existing items decorations are removed before the new item decoration is added.
Maybe you could add this to the example code?

        for (i in 0 until recyclerView.itemDecorationCount) {
          recyclerView.removeItemDecorationAt(0)
        }