So, this is the relevant part of my refresh function, the part that causes the issue:
private fun refresh(root: View, refreshThing2: SwipeRefreshLayout, a