Skip to content
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

Composable Diff syntax created. #40

Merged
merged 2 commits into from
Aug 8, 2020
Merged

Conversation

ibrahimyilmaz
Copy link
Owner

@ibrahimyilmaz ibrahimyilmaz commented Aug 8, 2020

Proposed Changes/Issues Fixed

In order to have more readable diff calculation:

val recyclerViewAdapter = adapterOf<MessageViewState> {
                diff(
                    areContentsTheSame = { old, new -> old == new },
                    areItemsTheSame = { old, new -> old.message.id == new.message.id },
                    getChangePayload = { oldItem, newItem ->
                        val diffBundle = Bundle()

                        if (oldItem.selectionState != newItem.selectionState) {
                            diffBundle.putParcelable(
                                MessageViewHolder.KEY_SELECTION,
                                newItem.selectionState
                            )
                        }

                        if (diffBundle.isEmpty) null else diffBundle
                    }
                )
             ...

General

Testing

  • [] Unit-Tests implemented
  • Monkey-Test done
  • Does your submission pass ./gradlew check?

@ibrahimyilmaz ibrahimyilmaz changed the title Composable Diff syntax created. [WIP] : Composable Diff syntax created. Aug 8, 2020
@ibrahimyilmaz ibrahimyilmaz linked an issue Aug 8, 2020 that may be closed by this pull request
@ibrahimyilmaz ibrahimyilmaz self-assigned this Aug 8, 2020
@ibrahimyilmaz ibrahimyilmaz added the enhancement New feature or request label Aug 8, 2020
@ibrahimyilmaz ibrahimyilmaz marked this pull request as draft August 8, 2020 20:05
@ibrahimyilmaz ibrahimyilmaz changed the title [WIP] : Composable Diff syntax created. Composable Diff syntax created. Aug 8, 2020
@ibrahimyilmaz ibrahimyilmaz marked this pull request as ready for review August 8, 2020 20:25
@ibrahimyilmaz ibrahimyilmaz merged commit 0782291 into develop Aug 8, 2020
@ibrahimyilmaz ibrahimyilmaz deleted the ibra/make_diff_composable branch August 8, 2020 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[kiel] : Make DiffUtil usage composable too
1 participant