Skip to content

Commit

Permalink
Fix #4186: Uncheck all selection on developer options not working (#4383
Browse files Browse the repository at this point in the history
)

* Fix #4186 Uncheck all selection on developer options not working

* Fix #4186 Add changes to code as suggested on code review.

* Fix #4186 Undo changes on line wrap as advised by code reviewer.

* Add tests for #4186.

* Add tests for #4186, Undo changes on build.gradle.

* Update and makes changes as advised by code reviewer.

* Update test names to deselect from unselect.

* Fix broken tests after update.

* Move the 'scrollToPosition' call inside of 'verifyItemCheckedOnRecyclerViewItemAtPosition', to reduce boilerplate code.

* Add changes to run tests directly by removing unnecessary verification on initial click #2658.

* Updates tests and fix missed issues supposed to be updated.

* Update tests to assert if Checkbox is actually Unchecked after unchecking.

* Add testCoroutinesDispatchers.runCurrent() line to avoid MarkChaptersCompletedFragmentTest.kt deselectsAllChapters test from failing.

* Fix lint failing test, after update.

* Fix broken view models.

Co-authored-by: Ben Henning <[email protected]>
  • Loading branch information
KevinGitonga and BenHenning authored Oct 10, 2022
1 parent 49babed commit d1f5309
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 221 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ class MarkChaptersCompletedFragmentPresenter @Inject constructor(
)
}
}
} else if (binding.isAllChecked == true) {
binding.isAllChecked = false
viewModel.getItemList().forEach { viewModel ->
if (viewModel is ChapterSummaryViewModel) {
if (!viewModel.checkIfChapterIsCompleted()) {
chapterUnselected(viewModel.chapterIndex, viewModel.nextStoryIndex)
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ class MarkStoriesCompletedFragmentPresenter @Inject constructor(
}

binding.markStoriesCompletedAllCheckBoxContainer.setOnClickListener {
if (binding.isAllChecked == null || binding.isAllChecked == false)
if (binding.isAllChecked == null || binding.isAllChecked == false) {
binding.isAllChecked = true
} else if (binding.isAllChecked == true) {
binding.isAllChecked = false
}
}

binding.markStoriesCompletedAllCheckBox.setOnCheckedChangeListener { _, isChecked ->
Expand All @@ -74,6 +77,10 @@ class MarkStoriesCompletedFragmentPresenter @Inject constructor(
if (!viewModel.isCompleted)
storySelected(viewModel.storySummary.storyId)
}
} else {
viewModel.getStorySummaryMap().values.forEach { viewModel ->
if (!viewModel.isCompleted) storyUnselected(viewModel.storySummary.storyId)
}
}
bindingAdapter.notifyDataSetChanged()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,18 @@ class MarkTopicsCompletedFragmentPresenter @Inject constructor(
}

binding.markTopicsCompletedAllCheckBoxContainer.setOnClickListener {
if (binding.isAllChecked == null || binding.isAllChecked == false)
binding.isAllChecked = true
binding.isAllChecked = !(binding.isAllChecked ?: false)
}

binding.markTopicsCompletedAllCheckBox.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
viewModel.getTopicList().forEach { viewModel ->
if (!viewModel.isCompleted) topicSelected(viewModel.topic.topicId)
}
} else {
viewModel.getTopicList().forEach { viewModel ->
if (!viewModel.isCompleted) topicUnselected(viewModel.topic.topicId)
}
}
bindingAdapter.notifyDataSetChanged()
}
Expand Down
Loading

0 comments on commit d1f5309

Please sign in to comment.