Skip to content

Commit

Permalink
Merge pull request #3791 from kiwix/Fix#3790
Browse files Browse the repository at this point in the history
Fixed: Play Store reported a crash error when closing the tabs.
  • Loading branch information
kelson42 authored Apr 17, 2024
2 parents cf745d3 + 40e86d0 commit 236f695
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,10 @@ abstract class CoreReaderFragment :
if (currentTtsWebViewIndex == index) {
onReadAloudStop()
}
// Check if the index is valid; RecyclerView gives the index -1 for already removed views.
// Address those issues when the user frequently clicks on the close icon of the same tab.
// See https://github.com/kiwix/kiwix-android/issues/3790 for more details.
if (index == RecyclerView.NO_POSITION) return
tempZimFileForUndo = zimReaderContainer?.zimFile
tempWebViewForUndo = webViewList[index]
webViewList.removeAt(index)
Expand All @@ -1211,7 +1215,10 @@ abstract class CoreReaderFragment :
snackBarRoot?.let {
it.bringToFront()
Snackbar.make(it, R.string.tab_closed, Snackbar.LENGTH_LONG)
.setAction(R.string.undo) { restoreDeletedTab(index) }.show()
.setAction(R.string.undo) { undoButton ->
undoButton.isEnabled = false
restoreDeletedTab(index)
}.show()
}
openHomeScreen()
}
Expand Down

0 comments on commit 236f695

Please sign in to comment.