-
Notifications
You must be signed in to change notification settings - Fork 271
Adding separators to list of repositories #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1e54226 to
bc3ef1f
Compare
ce10dce to
e395f8e
Compare
c72c7b1 to
a4fee40
Compare
bde42c7 to
fcc0bae
Compare
fcc0bae to
781b2a9
Compare
98c2f41 to
8115111
Compare
| lastQueryValue = queryString | ||
| val newResult = repository.getSearchResultStream(queryString) | ||
| val newResult: Flow<PagingData<UiModel>> = repository.getSearchResultStream(queryString) | ||
| .map { pagingData -> pagingData.map { UiModel.RepoItem(it) as UiModel } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you skip this map, then the subsequent map shouldnt ahve to do the is checks - they'll always be true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disregard this and the below comment for now!
Realized this is a bug in the generics of this function that prevents you from doing this more cleanly: https://issuetracker.google.com/issues/151050495
| override fun areItemsTheSame(oldItem: Repo, newItem: Repo): Boolean = | ||
| oldItem.fullName == newItem.fullName | ||
| private val UIMODEL_COMPARATOR = object : DiffUtil.ItemCallback<UiModel>() { | ||
| override fun areItemsTheSame(oldItem: UiModel, newItem: UiModel): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will make separators always crossfade, this should check for SeparatorItem too.
| val newResult: Flow<PagingData<UiModel>> = repository.getSearchResultStream(queryString) | ||
| .map { pagingData -> pagingData.map { UiModel.RepoItem(it) as UiModel } } | ||
| .map { | ||
| it.insertSeparators { before, after -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without the above map, before/after will be RepoItems, so you don't need to do all the checks
you may end up needing to be specific about generics, but I think that's clearer than adding all the uses of 'is' as 'as'
b8eae01 to
d5711cc
Compare
8115111 to
a5be06e
Compare
a5be06e to
8e1f374
Compare
No description provided.