Skip to content

Commit

Permalink
Merge pull request #3797 from kiwix/Fix#3796
Browse files Browse the repository at this point in the history
Fixed: PlayStore reported IndexOutOfBoundsException, when we are selecting the item from rightDrawer.
  • Loading branch information
kelson42 authored Apr 17, 2024
2 parents 65591d2 + 5e9962b commit 29c3962
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -678,16 +678,27 @@ abstract class CoreReaderFragment :
}

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('" +
documentSections?.get(position)?.id?.replace("'", "\\'") +
"').scrollIntoView();"
)
}
drawerLayout?.closeDrawers()
}
})
}

private fun hasItemForPositionInDocumentSectionsList(position: Int): Boolean {
val documentListSize = documentSections?.size ?: return false
return when {
position < 0 -> false
position >= documentListSize -> false
else -> true
}
}

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

0 comments on commit 29c3962

Please sign in to comment.