Skip to content

Commit

Permalink
App crashes when deleting annotation Closes #181
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima-Android committed Oct 31, 2024
1 parent 6ceca1f commit 20e59cd
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,8 @@ class PdfReaderViewModel @Inject constructor(
select(annotation = annotation, pageIndex = pageIndex, document = this.document)
}
} else {
select(annotation = null, pageIndex = pdfUiFragment.pageIndex, document = this.document)
//no need to provide pageIndex during a deselection.
select(annotation = null, pageIndex = null, document = this.document)
}
}

Expand Down Expand Up @@ -1671,13 +1672,13 @@ class PdfReaderViewModel @Inject constructor(

private fun select(
annotation: org.zotero.android.pdf.data.PDFAnnotation?,
pageIndex: Int,
pageIndex: Int?,
document: PdfDocument
) {

//TODO updateSelection

if (annotation != null) {
if (annotation != null && pageIndex != null) {
val pdfAnnotation = document.annotation(pageIndex, annotation.key)
if (pdfAnnotation != null) {
if (!pdfFragment.selectedAnnotations.contains(pdfAnnotation)) {
Expand Down

0 comments on commit 20e59cd

Please sign in to comment.