I have recycler view with datas that when it on the bottom with this code findLastCompletelyVisibleItemPosition()
it will load new data. my init data and my load data are the same function just add change the body request after recyclerview scroll to very bottom. My issue is when it load a new datas it will scroll back to top. how do I make it in the same place and not scroll back?
I already tried to impelemnt this in load data function
val recyclerViewState =list_view_history_program.layoutManager?.onSaveInstanceState()
if (loadMore > 0) {
listAdapter.notifyItemRangeChanged(loadMoreCount, listAdapter.itemCount, programNames)
listAdapter.notifyDataSetChanged()
list_view_history_program.layoutManager?.onRestoreInstanceState(recyclerViewState)
list_view_history_program.scrollToPosition(loadMoreCount)
}
but still it scroll back. please help