Skip to content

Conversation

@florina-muntenescu
Copy link
Collaborator

No description provided.

@florina-muntenescu florina-muntenescu force-pushed the fm/paging_separators branch 2 times, most recently from c72c7b1 to a4fee40 Compare March 4, 2020 16:48
@florina-muntenescu florina-muntenescu force-pushed the fm/network_paging branch 2 times, most recently from bde42c7 to fcc0bae Compare March 4, 2020 17:42
@florina-muntenescu florina-muntenescu force-pushed the fm/paging_separators branch 3 times, most recently from 98c2f41 to 8115111 Compare March 4, 2020 18:22
lastQueryValue = queryString
val newResult = repository.getSearchResultStream(queryString)
val newResult: Flow<PagingData<UiModel>> = repository.getSearchResultStream(queryString)
.map { pagingData -> pagingData.map { UiModel.RepoItem(it) as UiModel } }

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

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 {

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 ->

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'

@florina-muntenescu florina-muntenescu deleted the fm/paging_separators branch May 5, 2020 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants