Skip to content

Commit

Permalink
[Sample] Handle crash issue after tapping on the Search Tab. (#2339)
Browse files Browse the repository at this point in the history
  • Loading branch information
way2jatin committed Jul 18, 2023
1 parent 0c8e05c commit 6c26b9f
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ class LottiefilesDataSource(
}

override fun getRefreshKey(state: PagingState<Int, AnimationData>): Int? {
return state.closestItemToPosition(state.anchorPosition ?: return null)?.id as Int?
return state.anchorPosition?.let { anchorPosition ->
state.closestPageToPosition(anchorPosition)?.prevKey?.plus(1)
?: state.closestPageToPosition(anchorPosition)?.nextKey?.minus(1)
}
}
}

Expand Down Expand Up @@ -163,4 +166,4 @@ class LottiefilesFragment : BaseMvRxFragment(R.layout.lottiefiles_fragment) {
binding.searchView.isVisible = state.mode == LottiefilesMode.Search
binding.tabBar.setMode(state.mode)
}
}
}

0 comments on commit 6c26b9f

Please sign in to comment.