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

Fixed: PlayStore reported IndexOutOfBoundsException, when we are selecting the item from rightDrawer. #3797

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -678,16 +678,27 @@
}

override fun onSectionClick(view: View?, position: Int) {
loadUrlWithCurrentWebview(
"javascript:document.getElementById('" +
documentSections?.get(position)?.id?.replace("'", "\\'") +
"').scrollIntoView();"
)
if (hasItemForPositionInDocumentSectionsList(position)) { // Bug Fix #3796
loadUrlWithCurrentWebview(
"javascript:document.getElementById('" +

Check warning on line 683 in core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt#L682-L683

Added lines #L682 - L683 were not covered by tests
documentSections?.get(position)?.id?.replace("'", "\\'") +
"').scrollIntoView();"

Check warning on line 685 in core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt#L685

Added line #L685 was not covered by tests
)
}
drawerLayout?.closeDrawers()
}
})
}

private fun hasItemForPositionInDocumentSectionsList(position: Int): Boolean {
val documentListSize = documentSections?.size ?: return false
return when {

Check warning on line 695 in core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt#L695

Added line #L695 was not covered by tests
position < 0 -> false
position >= documentListSize -> false
else -> true

Check warning on line 698 in core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt#L698

Added line #L698 was not covered by tests
}
}

private fun showTabSwitcher() {
(requireActivity() as CoreMainActivity).disableDrawer()
actionBar?.apply {
Expand Down
Loading